summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-06-21 14:29:52 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-06-21 14:29:52 -0700
commitacb5f99c64c24421cdaca1474f83871f9a2ba33c (patch)
tree3094f7b7856e4fa90c9b405f654e942a1462152e
parentb21f7cf20ef0d37a934df2622cc1596c13a4a723 (diff)
parentcd81073eac537e9f85eeee14588d513ea8a56e17 (diff)
downloadandroid_packages_apps_Trebuchet-acb5f99c64c24421cdaca1474f83871f9a2ba33c.zip
android_packages_apps_Trebuchet-acb5f99c64c24421cdaca1474f83871f9a2ba33c.tar.gz
android_packages_apps_Trebuchet-acb5f99c64c24421cdaca1474f83871f9a2ba33c.tar.bz2
Merge "Decoupling launcher/workspace package cleanup from the application list (Bug 6602756)"
-rw-r--r--src/com/android/launcher2/AllAppsView.java48
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java46
-rw-r--r--src/com/android/launcher2/DragController.java10
-rw-r--r--src/com/android/launcher2/Launcher.java17
-rw-r--r--src/com/android/launcher2/LauncherModel.java23
-rw-r--r--src/com/android/launcher2/Workspace.java7
6 files changed, 45 insertions, 106 deletions
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java
deleted file mode 100644
index e8ca61f..0000000
--- a/src/com/android/launcher2/AllAppsView.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher2;
-
-import java.util.ArrayList;
-
-public interface AllAppsView {
- public interface Watcher {
- public void zoomed(float zoom);
- }
-
- public void setup(Launcher launcher, DragController dragController);
-
- public void zoom(float zoom, boolean animate);
-
- public boolean isVisible();
-
- public boolean isAnimating();
-
- public void setApps(ArrayList<ApplicationInfo> list);
-
- public void addApps(ArrayList<ApplicationInfo> list);
-
- public void removeApps(ArrayList<ApplicationInfo> list);
-
- public void updateApps(ArrayList<ApplicationInfo> list);
-
- // Resets the AllApps page to the front
- public void reset();
-
- public void dumpState();
-
- public void surrender();
-}
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 547080a..d7bb438 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -230,7 +230,7 @@ class RectCache extends WeakReferenceThreadLocal<Rect> {
* 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";
@@ -1667,23 +1667,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
@@ -1702,7 +1689,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
- @Override
public void setApps(ArrayList<ApplicationInfo> list) {
mApps = list;
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
@@ -1720,7 +1706,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
}
- @Override
public void addApps(ArrayList<ApplicationInfo> list) {
addAppsWithoutInvalidate(list);
updatePageCounts();
@@ -1737,6 +1722,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
return -1;
}
+ private int findAppByPackage(List<ApplicationInfo> 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<ApplicationInfo> list) {
// loop through all the apps and remove apps that have the same component
int length = list.size();
@@ -1748,13 +1743,21 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
}
- @Override
- public void removeApps(ArrayList<ApplicationInfo> list) {
- removeAppsWithoutInvalidate(list);
+ private void removeAppsWithPackageNameWithoutInvalidate(ArrayList<String> 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<String> packageNames) {
+ removeAppsWithPackageNameWithoutInvalidate(packageNames);
updatePageCounts();
invalidateOnDataChange();
}
- @Override
public void updateApps(ArrayList<ApplicationInfo> 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
@@ -1765,7 +1768,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;
@@ -1787,7 +1789,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);
@@ -1812,7 +1813,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.
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index 84f1515..4c42953 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -326,19 +326,17 @@ public class DragController {
}
endDrag();
}
- public void onAppsRemoved(ArrayList<ApplicationInfo> apps, Context context) {
+ public void onAppsRemoved(ArrayList<String> packageNames, Context context) {
// Cancel the current drag if we are removing an app that we are dragging
if (mDragObject != null) {
Object rawDragInfo = mDragObject.dragInfo;
if (rawDragInfo instanceof ShortcutInfo) {
ShortcutInfo dragInfo = (ShortcutInfo) rawDragInfo;
- for (ApplicationInfo info : apps) {
+ for (String pn : packageNames) {
// Added null checks to prevent NPE we've seen in the wild
if (dragInfo != null &&
- dragInfo.intent != null &&
- info.intent != null) {
- boolean isSamePackage = dragInfo.getPackageName().equals(
- info.getPackageName());
+ dragInfo.intent != null) {
+ boolean isSamePackage = dragInfo.getPackageName().equals(pn);
if (isSamePackage) {
cancelDrag();
return;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 4906e81..3e8c7aa 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -117,7 +117,7 @@ import java.util.Set;
*/
public final class Launcher extends Activity
implements View.OnClickListener, OnLongClickListener, LauncherModel.Callbacks,
- AllAppsView.Watcher, View.OnTouchListener {
+ View.OnTouchListener {
static final String TAG = "Launcher";
static final boolean LOGD = false;
@@ -2300,13 +2300,6 @@ public final class Launcher extends Activity
return mHotseat.isAllAppsButtonRank(rank);
}
- // AllAppsView.Watcher
- public void zoomed(float zoom) {
- if (zoom == 1.0f) {
- mWorkspace.setVisibility(View.GONE);
- }
- }
-
/**
* Helper method for the cameraZoomIn/cameraZoomOut animations
* @param view The view being animated
@@ -3520,17 +3513,17 @@ public final class Launcher extends Activity
*
* Implementation of the method from LauncherModel.Callbacks.
*/
- public void bindAppsRemoved(ArrayList<ApplicationInfo> apps, boolean permanent) {
+ public void bindAppsRemoved(ArrayList<String> packageNames, boolean permanent) {
if (permanent) {
- mWorkspace.removeItems(apps);
+ mWorkspace.removeItems(packageNames);
}
if (mAppsCustomizeContent != null) {
- mAppsCustomizeContent.removeApps(apps);
+ mAppsCustomizeContent.removeApps(packageNames);
}
// Notify the drag controller
- mDragController.onAppsRemoved(apps, this);
+ mDragController.onAppsRemoved(packageNames, this);
}
/**
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index fc1a26d..bada5cb 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -135,7 +135,7 @@ public class LauncherModel extends BroadcastReceiver {
public void bindAllApplications(ArrayList<ApplicationInfo> apps);
public void bindAppsAdded(ArrayList<ApplicationInfo> apps);
public void bindAppsUpdated(ArrayList<ApplicationInfo> apps);
- public void bindAppsRemoved(ArrayList<ApplicationInfo> apps, boolean permanent);
+ public void bindAppsRemoved(ArrayList<String> packageNames, boolean permanent);
public void bindPackagesUpdated();
public boolean isAllAppsVisible();
public boolean isAllAppsButtonRank(int rank);
@@ -1623,25 +1623,25 @@ public class LauncherModel extends BroadcastReceiver {
}
ArrayList<ApplicationInfo> added = null;
- ArrayList<ApplicationInfo> removed = null;
ArrayList<ApplicationInfo> modified = null;
if (mAllAppsList.added.size() > 0) {
added = mAllAppsList.added;
mAllAppsList.added = new ArrayList<ApplicationInfo>();
}
- if (mAllAppsList.removed.size() > 0) {
- removed = mAllAppsList.removed;
- mAllAppsList.removed = new ArrayList<ApplicationInfo>();
- for (ApplicationInfo info: removed) {
- mIconCache.remove(info.intent.getComponent());
- }
- }
if (mAllAppsList.modified.size() > 0) {
modified = mAllAppsList.modified;
mAllAppsList.modified = new ArrayList<ApplicationInfo>();
}
+ // We may be removing packages that have no associated launcher application, so we
+ // pass through the removed package names directly.
+ // NOTE: We flush the icon cache aggressively in removePackage() above.
+ final ArrayList<String> removedPackageNames = new ArrayList<String>();
+ for (int i = 0; i < N; ++i) {
+ removedPackageNames.add(packages[i]);
+ }
+
final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
if (callbacks == null) {
Log.w(TAG, "Nobody to tell about the new app. Launcher is probably loading.");
@@ -1670,14 +1670,13 @@ public class LauncherModel extends BroadcastReceiver {
}
});
}
- if (removed != null) {
+ if (!removedPackageNames.isEmpty()) {
final boolean permanent = mOp != OP_UNAVAILABLE;
- final ArrayList<ApplicationInfo> removedFinal = removed;
mHandler.post(new Runnable() {
public void run() {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
if (callbacks == cb && cb != null) {
- callbacks.bindAppsRemoved(removedFinal, permanent);
+ callbacks.bindAppsRemoved(removedPackageNames, permanent);
}
}
});
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 1347511..83b0329 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -3553,12 +3553,9 @@ public class Workspace extends SmoothPagedView
}
}
- void removeItems(final ArrayList<ApplicationInfo> apps) {
+ void removeItems(final ArrayList<String> packages) {
final HashSet<String> packageNames = new HashSet<String>();
- final int appCount = apps.size();
- for (int i = 0; i < appCount; i++) {
- packageNames.add(apps.get(i).componentName.getPackageName());
- }
+ packageNames.addAll(packages);
ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts();
for (final CellLayout layoutParent: cellLayouts) {