From cd81073eac537e9f85eeee14588d513ea8a56e17 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 18 Jun 2012 16:45:43 -0700 Subject: Decoupling launcher/workspace package cleanup from the application list (Bug 6602756) - Fixes issues where shortcuts created by wallpaper/widget-only apps are uninstalled. Change-Id: I94c9d1d71fc34aa2fb7f0660534e616a82ac6f36 --- .../android/launcher2/AppsCustomizePagedView.java | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/com/android/launcher2/AppsCustomizePagedView.java') diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index ef3327295..11ae8f239 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -231,7 +231,7 @@ class RectCache extends WeakReferenceThreadLocal { * The Apps/Customize page that displays all the applications, widgets, and shortcuts. */ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implements - AllAppsView, View.OnClickListener, View.OnKeyListener, DragSource, + View.OnClickListener, View.OnKeyListener, DragSource, PagedViewIcon.PressedCallback, PagedViewWidget.ShortPressListener, LauncherTransitionable { static final String TAG = "AppsCustomizePagedView"; @@ -1668,23 +1668,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen /* * AllAppsView implementation */ - @Override public void setup(Launcher launcher, DragController dragController) { mLauncher = launcher; mDragController = dragController; } - @Override - public void zoom(float zoom, boolean animate) { - // TODO-APPS_CUSTOMIZE: Call back to mLauncher.zoomed() - } - @Override - public boolean isVisible() { - return (getVisibility() == VISIBLE); - } - @Override - public boolean isAnimating() { - return false; - } /** * We should call thise method whenever the core data changes (mApps, mWidgets) so that we can @@ -1703,7 +1690,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } } - @Override public void setApps(ArrayList list) { mApps = list; Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR); @@ -1721,7 +1707,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } } } - @Override public void addApps(ArrayList list) { addAppsWithoutInvalidate(list); updatePageCounts(); @@ -1738,6 +1723,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } return -1; } + private int findAppByPackage(List list, String packageName) { + int length = list.size(); + for (int i = 0; i < length; ++i) { + ApplicationInfo info = list.get(i); + if (ItemInfo.getPackageName(info.intent).equals(packageName)) { + return i; + } + } + return -1; + } private void removeAppsWithoutInvalidate(ArrayList list) { // loop through all the apps and remove apps that have the same component int length = list.size(); @@ -1749,13 +1744,21 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } } } - @Override - public void removeApps(ArrayList list) { - removeAppsWithoutInvalidate(list); + private void removeAppsWithPackageNameWithoutInvalidate(ArrayList packageNames) { + // loop through all the package names and remove apps that have the same package name + for (String pn : packageNames) { + int removeIndex = findAppByPackage(mApps, pn); + while (removeIndex > -1) { + mApps.remove(removeIndex); + removeIndex = findAppByPackage(mApps, pn); + } + } + } + public void removeApps(ArrayList packageNames) { + removeAppsWithPackageNameWithoutInvalidate(packageNames); updatePageCounts(); invalidateOnDataChange(); } - @Override public void updateApps(ArrayList list) { // We remove and re-add the updated applications list because it's properties may have // changed (ie. the title), and this will ensure that the items will be in their proper @@ -1766,7 +1769,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen invalidateOnDataChange(); } - @Override public void reset() { // If we have reset, then we should not continue to restore the previous state mSaveInstanceStateItemIndex = -1; @@ -1788,7 +1790,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen return (AppsCustomizeTabHost) mLauncher.findViewById(R.id.apps_customize_pane); } - @Override public void dumpState() { // TODO: Dump information related to current list of Applications, Widgets, etc. ApplicationInfo.dumpApplicationInfoList(TAG, "mApps", mApps); @@ -1813,7 +1814,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } } - @Override public void surrender() { // TODO: If we are in the middle of any process (ie. for holographic outlines, etc) we // should stop this now. -- cgit v1.2.3