From 94d6768c65929efa21bb893fdef7f269d65da3c3 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 25 Sep 2013 16:29:40 -0700 Subject: [PATCH] Restoring INSTALL_SHORTCUT receiver (Bug. 10343529) Change-Id: Icd6a97c1d7877241aa9c71bd80dfdbe6e44ca7ee --- AndroidManifest.xml | 4 +- .../launcher3/InstallShortcutReceiver.java | 2 +- src/com/android/launcher3/Launcher.java | 28 ++++++------ src/com/android/launcher3/LauncherModel.java | 43 +++++++++++-------- .../launcher3/UninstallShortcutReceiver.java | 2 +- 5 files changed, 45 insertions(+), 34 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c6263fb873..901b63838d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -26,13 +26,13 @@ android:permissionGroup="android.permission-group.SYSTEM_TOOLS" android:protectionLevel="system|signature" /> -1) { long currentScreenId = mWorkspace.getScreenIdForPageIndex(mWorkspace.getNextPage()); - int newScreenIndex = mWorkspace.getPageIndexForScreenId(newShortcutsScreenId); + final int newScreenIndex = mWorkspace.getPageIndexForScreenId(newShortcutsScreenId); if (newShortcutsScreenId != currentScreenId) { - mWorkspace.snapToPage(newScreenIndex); + // We post the animation slightly delayed to prevent slowdowns + // when we are loading right after we return to launcher. + mWorkspace.postDelayed(new Runnable() { + public void run() { + mWorkspace.snapToPage(newScreenIndex); + mWorkspace.postDelayed(new Runnable() { + public void run() { + anim.playTogether(bounceAnims); + anim.start(); + } + }, NEW_APPS_ANIMATION_DELAY); + } + }, NEW_APPS_PAGE_MOVE_DELAY); } } - - // We post the animation slightly delayed to prevent slowdowns when we are loading - // right after we return to launcher. - mWorkspace.postDelayed(new Runnable() { - public void run() { - anim.playTogether(bounceAnims); - anim.start(); - } - }, NEW_APPS_ANIMATION_DELAY); } workspace.requestLayout(); } diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 1d264aa551..eead0855e3 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -281,14 +281,14 @@ public class LauncherModel extends BroadcastReceiver { return null; } - public void addAndBindAddedApps(final Context context, final ArrayList added, - final ArrayList addedApps) { + public void addAndBindAddedApps(final Context context, final ArrayList workspaceApps, + final ArrayList allAppsApps) { Callbacks cb = mCallbacks != null ? mCallbacks.get() : null; - addAndBindAddedApps(context, added, cb, addedApps); + addAndBindAddedApps(context, workspaceApps, cb, allAppsApps); } - public void addAndBindAddedApps(final Context context, final ArrayList added, - final Callbacks callbacks, final ArrayList addedApps) { - if (added.isEmpty()) { + public void addAndBindAddedApps(final Context context, final ArrayList workspaceApps, + final Callbacks callbacks, final ArrayList allAppsApps) { + if (workspaceApps.isEmpty() && allAppsApps.isEmpty()) { return; } // Process the newly added applications and add them to the database first @@ -308,7 +308,7 @@ public class LauncherModel extends BroadcastReceiver { } synchronized(sBgLock) { - Iterator iter = added.iterator(); + Iterator iter = workspaceApps.iterator(); while (iter.hasNext()) { ItemInfo a = iter.next(); final String name = a.title.toString(); @@ -356,6 +356,7 @@ public class LauncherModel extends BroadcastReceiver { } else { throw new RuntimeException("Unexpected info type"); } + // Add the shortcut to the db addItemToDatabase(context, shortcutInfo, LauncherSettings.Favorites.CONTAINER_DESKTOP, @@ -368,24 +369,26 @@ public class LauncherModel extends BroadcastReceiver { // Update the workspace screens updateWorkspaceScreenOrder(context, workspaceScreens); - if (!addedShortcutsFinal.isEmpty()) { + if (!addedShortcutsFinal.isEmpty() || !allAppsApps.isEmpty()) { runOnMainThread(new Runnable() { public void run() { Callbacks cb = mCallbacks != null ? mCallbacks.get() : null; if (callbacks == cb && cb != null) { - ItemInfo info = addedShortcutsFinal.get(addedShortcutsFinal.size() - 1); - long lastScreenId = info.screenId; final ArrayList addAnimated = new ArrayList(); final ArrayList addNotAnimated = new ArrayList(); - for (ItemInfo i : addedShortcutsFinal) { - if (i.screenId == lastScreenId) { - addAnimated.add(i); - } else { - addNotAnimated.add(i); + if (!addedShortcutsFinal.isEmpty()) { + ItemInfo info = addedShortcutsFinal.get(addedShortcutsFinal.size() - 1); + long lastScreenId = info.screenId; + for (ItemInfo i : addedShortcutsFinal) { + if (i.screenId == lastScreenId) { + addAnimated.add(i); + } else { + addNotAnimated.add(i); + } } } callbacks.bindAppsAdded(addedWorkspaceScreensFinal, - addNotAnimated, addAnimated, addedApps); + addNotAnimated, addAnimated, allAppsApps); } } }); @@ -2514,9 +2517,13 @@ public class LauncherModel extends BroadcastReceiver { if (added != null) { // Ensure that we add all the workspace applications to the db - final ArrayList addedInfos = new ArrayList(added); Callbacks cb = mCallbacks != null ? mCallbacks.get() : null; - addAndBindAddedApps(context, addedInfos, cb, added); + if (!AppsCustomizePagedView.DISABLE_ALL_APPS) { + addAndBindAddedApps(context, new ArrayList(), cb, added); + } else { + final ArrayList addedInfos = new ArrayList(added); + addAndBindAddedApps(context, addedInfos, cb, added); + } } if (modified != null) { final ArrayList modifiedFinal = modified; diff --git a/src/com/android/launcher3/UninstallShortcutReceiver.java b/src/com/android/launcher3/UninstallShortcutReceiver.java index d92963abe5..00fa631bc2 100644 --- a/src/com/android/launcher3/UninstallShortcutReceiver.java +++ b/src/com/android/launcher3/UninstallShortcutReceiver.java @@ -30,7 +30,7 @@ import java.util.Iterator; public class UninstallShortcutReceiver extends BroadcastReceiver { private static final String ACTION_UNINSTALL_SHORTCUT = - "com.android.launcher3.action.UNINSTALL_SHORTCUT"; + "com.android.launcher.action.UNINSTALL_SHORTCUT"; // The set of shortcuts that are pending uninstall private static ArrayList mUninstallQueue =