diff options
author | Romain Guy <romainguy@android.com> | 2009-06-01 15:34:04 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2009-06-01 15:34:04 -0700 |
commit | 574d20ec84551370987dde530c27ec493bdef564 (patch) | |
tree | 2d3febf5d1e108816e32cdfdfee452ea5abd8fd0 /src | |
parent | 8283ccff7c44e3f2a62496167159228eb50706b6 (diff) | |
download | android_packages_apps_Trebuchet-574d20ec84551370987dde530c27ec493bdef564.tar.gz android_packages_apps_Trebuchet-574d20ec84551370987dde530c27ec493bdef564.tar.bz2 android_packages_apps_Trebuchet-574d20ec84551370987dde530c27ec493bdef564.zip |
Fixes #1890155.
Remove shortcuts from folders (closed and opened) whenever the user
uninstalls an application. Home was removing shortcuts from the
workspace and the database but was not updating the UI correctly
when running.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher/Folder.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher/Workspace.java | 34 |
2 files changed, 39 insertions, 3 deletions
diff --git a/src/com/android/launcher/Folder.java b/src/com/android/launcher/Folder.java index bcbccf71b..fb4e8d6c5 100644 --- a/src/com/android/launcher/Folder.java +++ b/src/com/android/launcher/Folder.java @@ -24,7 +24,7 @@ import android.widget.AdapterView; import android.widget.Button; import android.widget.LinearLayout; import android.widget.AbsListView; -import android.widget.ListAdapter; +import android.widget.BaseAdapter; import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemLongClickListener; @@ -122,10 +122,14 @@ public class Folder extends LinearLayout implements DragSource, OnItemLongClickL * * @param adapter The list of applications to display in the folder. */ - void setContentAdapter(ListAdapter adapter) { + void setContentAdapter(BaseAdapter adapter) { mContent.setAdapter(adapter); } + void notifyDataSetChanged() { + ((BaseAdapter) mContent.getAdapter()).notifyDataSetChanged(); + } + void setLauncher(Launcher launcher) { mLauncher = launcher; } diff --git a/src/com/android/launcher/Workspace.java b/src/com/android/launcher/Workspace.java index fe309dedb..e4d256028 100644 --- a/src/com/android/launcher/Workspace.java +++ b/src/com/android/launcher/Workspace.java @@ -1222,32 +1222,64 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag final ArrayList<View> childrenToRemove = new ArrayList<View>(); final LauncherModel model = Launcher.getModel(); final int count = getChildCount(); + for (int i = 0; i < count; i++) { final CellLayout layout = (CellLayout) getChildAt(i); int childCount = layout.getChildCount(); + childrenToRemove.clear(); + for (int j = 0; j < childCount; j++) { final View view = layout.getChildAt(j); Object tag = view.getTag(); + if (tag instanceof ApplicationInfo) { - ApplicationInfo info = (ApplicationInfo) tag; + final ApplicationInfo info = (ApplicationInfo) tag; // We need to check for ACTION_MAIN otherwise getComponent() might // return null for some shortcuts (for instance, for shortcuts to // web pages.) final Intent intent = info.intent; final ComponentName name = intent.getComponent(); + if (Intent.ACTION_MAIN.equals(intent.getAction()) && name != null && packageName.equals(name.getPackageName())) { model.removeDesktopItem(info); LauncherModel.deleteItemFromDatabase(mLauncher, info); childrenToRemove.add(view); } + } else if (tag instanceof UserFolderInfo) { + final UserFolderInfo info = (UserFolderInfo) tag; + final ArrayList<ApplicationInfo> contents = info.contents; + final ArrayList<ApplicationInfo> toRemove = new ArrayList<ApplicationInfo>(1); + final int contentsCount = contents.size(); + boolean removedFromFolder = false; + + for (int k = 0; k < contentsCount; k++) { + final ApplicationInfo appInfo = contents.get(k); + final Intent intent = appInfo.intent; + final ComponentName name = intent.getComponent(); + + if (Intent.ACTION_MAIN.equals(intent.getAction()) && + name != null && packageName.equals(name.getPackageName())) { + toRemove.add(appInfo); + LauncherModel.deleteItemFromDatabase(mLauncher, appInfo); + removedFromFolder = true; + } + } + + contents.removeAll(toRemove); + if (removedFromFolder) { + final Folder folder = getOpenFolder(); + if (folder != null) folder.notifyDataSetChanged(); + } } } + childCount = childrenToRemove.size(); for (int j = 0; j < childCount; j++) { layout.removeViewInLayout(childrenToRemove.get(j)); } + if (childCount > 0) { layout.requestLayout(); layout.invalidate(); |