From 94d6768c65929efa21bb893fdef7f269d65da3c3 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 25 Sep 2013 16:29:40 -0700 Subject: Restoring INSTALL_SHORTCUT receiver (Bug. 10343529) Change-Id: Icd6a97c1d7877241aa9c71bd80dfdbe6e44ca7ee --- .../android/launcher3/InstallShortcutReceiver.java | 2 +- src/com/android/launcher3/Launcher.java | 28 ++++++++------ src/com/android/launcher3/LauncherModel.java | 43 +++++++++++++--------- .../launcher3/UninstallShortcutReceiver.java | 2 +- 4 files changed, 43 insertions(+), 32 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java index b31f45d57..fd580081b 100644 --- a/src/com/android/launcher3/InstallShortcutReceiver.java +++ b/src/com/android/launcher3/InstallShortcutReceiver.java @@ -37,7 +37,7 @@ import org.json.*; public class InstallShortcutReceiver extends BroadcastReceiver { public static final String ACTION_INSTALL_SHORTCUT = - "com.android.launcher3.action.INSTALL_SHORTCUT"; + "com.android.launcher.action.INSTALL_SHORTCUT"; public static final String DATA_INTENT_KEY = "intent.data"; public static final String LAUNCH_INTENT_KEY = "intent.launch"; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 84d5a09f7..102f4c272 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -209,7 +209,8 @@ public class Launcher extends Activity private static int sScreen = DEFAULT_SCREEN; // How long to wait before the new-shortcut animation automatically pans the workspace - private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 10; + private static int NEW_APPS_PAGE_MOVE_DELAY = 500; + private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5; private static int NEW_APPS_ANIMATION_DELAY = 500; private final BroadcastReceiver mCloseSystemDialogsReceiver @@ -3694,20 +3695,23 @@ public class Launcher extends Activity // Animate to the correct page if (newShortcutsScreenId > -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 1d264aa55..eead0855e 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 d92963abe..00fa631bc 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 = -- cgit v1.2.3