diff options
author | Joe Onorato <joeo@android.com> | 2010-03-05 15:05:52 -0500 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2010-03-10 13:42:32 -0800 |
commit | 64e6be78dc72e1a89fe8fb95c502586f9260df28 (patch) | |
tree | 3836e1dfd9891a5fc0b900b99f5158b7fa729c85 /src/com/android/launcher2/LauncherModel.java | |
parent | c36f2455aba21448a130b9a5e2a118a379745c37 (diff) | |
download | android_packages_apps_Trebuchet-64e6be78dc72e1a89fe8fb95c502586f9260df28.tar.gz android_packages_apps_Trebuchet-64e6be78dc72e1a89fe8fb95c502586f9260df28.tar.bz2 android_packages_apps_Trebuchet-64e6be78dc72e1a89fe8fb95c502586f9260df28.zip |
Refactor the app updates so that it doesn't rely on the package name.
This will be needed for the upcoming change to update the icons with the
grayed out when the SD card goes away.
Diffstat (limited to 'src/com/android/launcher2/LauncherModel.java')
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 70 |
1 files changed, 46 insertions, 24 deletions
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index 8790fd7bd..228b7a59f 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -82,9 +82,9 @@ public class LauncherModel extends BroadcastReceiver { public void finishBindingItems(); public void bindAppWidget(LauncherAppWidgetInfo info); public void bindAllApplications(ArrayList<ApplicationInfo> apps); - public void bindPackageAdded(ArrayList<ApplicationInfo> apps); - public void bindPackageUpdated(String packageName, ArrayList<ApplicationInfo> apps); - public void bindPackageRemoved(String packageName, ArrayList<ApplicationInfo> apps); + public void bindAppsAdded(ArrayList<ApplicationInfo> apps); + public void bindAppsUpdated(ArrayList<ApplicationInfo> apps); + public void bindAppsRemoved(ArrayList<ApplicationInfo> apps); } LauncherModel(LauncherApplication app, IconCache iconCache) { @@ -291,11 +291,11 @@ public class LauncherModel extends BroadcastReceiver { * ACTION_PACKAGE_CHANGED. */ public void onReceive(Context context, Intent intent) { + Log.d(TAG, "onReceive intent=" + intent); + // Use the app as the context. context = mApp; - final String packageName = intent.getData().getSchemeSpecificPart(); - ArrayList<ApplicationInfo> added = null; ArrayList<ApplicationInfo> removed = null; ArrayList<ApplicationInfo> modified = null; @@ -308,26 +308,48 @@ public class LauncherModel extends BroadcastReceiver { } final String action = intent.getAction(); - final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); - if (packageName == null || packageName.length() == 0) { - // they sent us a bad intent - return; - } + if (Intent.ACTION_PACKAGE_CHANGED.equals(action) + || Intent.ACTION_PACKAGE_REMOVED.equals(action) + || Intent.ACTION_PACKAGE_ADDED.equals(action)) { + final String packageName = intent.getData().getSchemeSpecificPart(); + final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false); - if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) { - mAllAppsList.updatePackage(context, packageName); - } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) { - if (!replacing) { - mAllAppsList.removePackage(packageName); + if (packageName == null || packageName.length() == 0) { + // they sent us a bad intent + return; } - // else, we are replacing the package, so a PACKAGE_ADDED will be sent - // later, we will update the package at this time - } else { - if (!replacing) { - mAllAppsList.addPackage(context, packageName); - } else { + + if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) { mAllAppsList.updatePackage(context, packageName); + } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) { + if (!replacing) { + mAllAppsList.removePackage(packageName); + } + // else, we are replacing the package, so a PACKAGE_ADDED will be sent + // later, we will update the package at this time + } else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) { + if (!replacing) { + mAllAppsList.addPackage(context, packageName); + } else { + mAllAppsList.updatePackage(context, packageName); + } + } + } else { + if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action)) { + String packages[] = intent.getStringArrayExtra( + Intent.EXTRA_CHANGED_PACKAGE_LIST); + if (packages == null || packages.length == 0) { + return; + } + Log.d(TAG, "they're back! " + packages); + } else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) { + String packages[] = intent.getStringArrayExtra( + Intent.EXTRA_CHANGED_PACKAGE_LIST); + if (packages == null || packages.length == 0) { + return; + } + Log.d(TAG, "they're gone! " + packages); } } @@ -357,7 +379,7 @@ public class LauncherModel extends BroadcastReceiver { final ArrayList<ApplicationInfo> addedFinal = added; mHandler.post(new Runnable() { public void run() { - callbacks.bindPackageAdded(addedFinal); + callbacks.bindAppsAdded(addedFinal); } }); } @@ -365,7 +387,7 @@ public class LauncherModel extends BroadcastReceiver { final ArrayList<ApplicationInfo> modifiedFinal = modified; mHandler.post(new Runnable() { public void run() { - callbacks.bindPackageUpdated(packageName, modifiedFinal); + callbacks.bindAppsUpdated(modifiedFinal); } }); } @@ -373,7 +395,7 @@ public class LauncherModel extends BroadcastReceiver { final ArrayList<ApplicationInfo> removedFinal = removed; mHandler.post(new Runnable() { public void run() { - callbacks.bindPackageRemoved(packageName, removedFinal); + callbacks.bindAppsRemoved(removedFinal); } }); } |