summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Workspace.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-05-04 11:56:37 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-04 11:56:37 -0700
commit8e21bc54113bf361d959f2c5934035b15f949379 (patch)
tree94389d43152d81026afd34ababb4386fc4e8331b /src/com/android/launcher2/Workspace.java
parenta8458c8cb9e12baeda7ad374a1e7a379c14f3e5d (diff)
parent2efec4e29f80db4293664d3ed4a89d37454510e1 (diff)
downloadandroid_packages_apps_Trebuchet-8e21bc54113bf361d959f2c5934035b15f949379.tar.gz
android_packages_apps_Trebuchet-8e21bc54113bf361d959f2c5934035b15f949379.tar.bz2
android_packages_apps_Trebuchet-8e21bc54113bf361d959f2c5934035b15f949379.zip
Merge "Fixing issue where items that were not yet added were not removed from the db. (Bug 6428418)" into jb-dev
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r--src/com/android/launcher2/Workspace.java62
1 files changed, 48 insertions, 14 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index ab8c26c85..e946095f7 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -29,6 +29,7 @@ import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -58,8 +59,11 @@ import com.android.launcher.R;
import com.android.launcher2.FolderIcon.FolderRingAnimator;
import com.android.launcher2.LauncherSettings.Favorites;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
/**
* The workspace is a wide area with a wallpaper and a finite number of pages.
@@ -3620,11 +3624,9 @@ public class Workspace extends SmoothPagedView
final ComponentName name = intent.getComponent();
if (name != null) {
- for (String packageName: packageNames) {
- if (packageName.equals(name.getPackageName())) {
- LauncherModel.deleteItemFromDatabase(mLauncher, info);
- childrenToRemove.add(view);
- }
+ if (packageNames.contains(name.getPackageName())) {
+ LauncherModel.deleteItemFromDatabase(mLauncher, info);
+ childrenToRemove.add(view);
}
}
} else if (tag instanceof FolderInfo) {
@@ -3640,10 +3642,8 @@ public class Workspace extends SmoothPagedView
final ComponentName name = intent.getComponent();
if (name != null) {
- for (String packageName: packageNames) {
- if (packageName.equals(name.getPackageName())) {
- appsToRemoveFromFolder.add(appInfo);
- }
+ if (packageNames.contains(name.getPackageName())) {
+ appsToRemoveFromFolder.add(appInfo);
}
}
}
@@ -3655,11 +3655,9 @@ public class Workspace extends SmoothPagedView
final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) tag;
final ComponentName provider = info.providerName;
if (provider != null) {
- for (String packageName: packageNames) {
- if (packageName.equals(provider.getPackageName())) {
- LauncherModel.deleteItemFromDatabase(mLauncher, info);
- childrenToRemove.add(view);
- }
+ if (packageNames.contains(provider.getPackageName())) {
+ LauncherModel.deleteItemFromDatabase(mLauncher, info);
+ childrenToRemove.add(view);
}
}
}
@@ -3683,6 +3681,42 @@ public class Workspace extends SmoothPagedView
}
});
}
+
+ // It is no longer the case the BubbleTextViews correspond 1:1 with the workspace items in
+ // the database (and LauncherModel) since shortcuts are not added and animated in until
+ // the user returns to launcher. As a result, we really should be cleaning up the Db
+ // regardless of whether the item was added or not (unlike the logic above). This is only
+ // relevant for direct workspace items.
+ post(new Runnable() {
+ @Override
+ public void run() {
+ String spKey = LauncherApplication.getSharedPreferencesKey();
+ SharedPreferences sp = getContext().getSharedPreferences(spKey,
+ Context.MODE_PRIVATE);
+ Set<String> newApps = sp.getStringSet(InstallShortcutReceiver.NEW_APPS_LIST_KEY,
+ null);
+
+ for (String packageName: packageNames) {
+ // Remove all items that have the same package, but were not removed above
+ ArrayList<ShortcutInfo> infos =
+ mLauncher.getModel().getShortcutInfosForPackage(packageName);
+ for (ShortcutInfo info : infos) {
+ LauncherModel.deleteItemFromDatabase(mLauncher, info);
+ }
+ // Remove all queued items that match the same package
+ if (newApps != null) {
+ for (String intentStr : newApps) {
+ try {
+ Intent intent = Intent.parseUri(intentStr, 0);
+ if (packageNames.contains(intent.getPackage())) {
+ newApps.remove(intentStr);
+ }
+ } catch (URISyntaxException e) {}
+ }
+ }
+ }
+ }
+ });
}
void updateShortcuts(ArrayList<ApplicationInfo> apps) {