Restoring INSTALL_SHORTCUT receiver (Bug. 10343529)

Change-Id: Icd6a97c1d7877241aa9c71bd80dfdbe6e44ca7ee
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index b31f45d..fd58008 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -37,7 +37,7 @@
 
 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 84d5a09..102f4c2 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -209,7 +209,8 @@
     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 @@
             // 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 1d264aa..eead085 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -281,14 +281,14 @@
         return null;
     }
 
-    public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> added,
-                                    final ArrayList<AppInfo> addedApps) {
+    public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> workspaceApps,
+                                    final ArrayList<AppInfo> 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<ItemInfo> added,
-                                    final Callbacks callbacks, final ArrayList<AppInfo> addedApps) {
-        if (added.isEmpty()) {
+    public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> workspaceApps,
+                                    final Callbacks callbacks, final ArrayList<AppInfo> allAppsApps) {
+        if (workspaceApps.isEmpty() && allAppsApps.isEmpty()) {
             return;
         }
         // Process the newly added applications and add them to the database first
@@ -308,7 +308,7 @@
                 }
 
                 synchronized(sBgLock) {
-                    Iterator<ItemInfo> iter = added.iterator();
+                    Iterator<ItemInfo> iter = workspaceApps.iterator();
                     while (iter.hasNext()) {
                         ItemInfo a = iter.next();
                         final String name = a.title.toString();
@@ -356,6 +356,7 @@
                         } else {
                             throw new RuntimeException("Unexpected info type");
                         }
+
                         // Add the shortcut to the db
                         addItemToDatabase(context, shortcutInfo,
                                 LauncherSettings.Favorites.CONTAINER_DESKTOP,
@@ -368,24 +369,26 @@
                 // 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<ItemInfo> addAnimated = new ArrayList<ItemInfo>();
                                 final ArrayList<ItemInfo> addNotAnimated = new ArrayList<ItemInfo>();
-                                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 @@
 
             if (added != null) {
                 // Ensure that we add all the workspace applications to the db
-                final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
                 Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
-                addAndBindAddedApps(context, addedInfos, cb, added);
+                if (!AppsCustomizePagedView.DISABLE_ALL_APPS) {
+                    addAndBindAddedApps(context, new ArrayList<ItemInfo>(), cb, added);
+                } else {
+                    final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
+                    addAndBindAddedApps(context, addedInfos, cb, added);
+                }
             }
             if (modified != null) {
                 final ArrayList<AppInfo> modifiedFinal = modified;
diff --git a/src/com/android/launcher3/UninstallShortcutReceiver.java b/src/com/android/launcher3/UninstallShortcutReceiver.java
index d92963a..00fa631 100644
--- a/src/com/android/launcher3/UninstallShortcutReceiver.java
+++ b/src/com/android/launcher3/UninstallShortcutReceiver.java
@@ -30,7 +30,7 @@
 
 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<PendingUninstallShortcutInfo> mUninstallQueue =