Merge "Cap launcher swipe animations to max duration" into jb-mr1-dev
diff --git a/res/drawable-xhdpi/wallpaper_01.jpg b/res/drawable-xhdpi/wallpaper_01.jpg
index 5b8d1d5..da9fa91 100644
--- a/res/drawable-xhdpi/wallpaper_01.jpg
+++ b/res/drawable-xhdpi/wallpaper_01.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/wallpaper_02.jpg b/res/drawable-xhdpi/wallpaper_02.jpg
index 29cba13..ee949aa 100644
--- a/res/drawable-xhdpi/wallpaper_02.jpg
+++ b/res/drawable-xhdpi/wallpaper_02.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/wallpaper_03.jpg b/res/drawable-xhdpi/wallpaper_03.jpg
index 5c165cf..9931ca2 100644
--- a/res/drawable-xhdpi/wallpaper_03.jpg
+++ b/res/drawable-xhdpi/wallpaper_03.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/wallpaper_04.jpg b/res/drawable-xhdpi/wallpaper_04.jpg
index 2f0da9d..306c8cd 100644
--- a/res/drawable-xhdpi/wallpaper_04.jpg
+++ b/res/drawable-xhdpi/wallpaper_04.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/wallpaper_05.jpg b/res/drawable-xhdpi/wallpaper_05.jpg
index 4ae7bb9..0735f5f 100644
--- a/res/drawable-xhdpi/wallpaper_05.jpg
+++ b/res/drawable-xhdpi/wallpaper_05.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/wallpaper_08.jpg b/res/drawable-xhdpi/wallpaper_08.jpg
index d091cb7..3fa6811 100644
--- a/res/drawable-xhdpi/wallpaper_08.jpg
+++ b/res/drawable-xhdpi/wallpaper_08.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/wallpaper_09.jpg b/res/drawable-xhdpi/wallpaper_09.jpg
index 7990d4c..cd062a6 100644
--- a/res/drawable-xhdpi/wallpaper_09.jpg
+++ b/res/drawable-xhdpi/wallpaper_09.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/wallpaper_10.jpg b/res/drawable-xhdpi/wallpaper_10.jpg
index 1fd1388..02b441e 100644
--- a/res/drawable-xhdpi/wallpaper_10.jpg
+++ b/res/drawable-xhdpi/wallpaper_10.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/wallpaper_11.jpg b/res/drawable-xhdpi/wallpaper_11.jpg
index b1609b9..39490ac 100644
--- a/res/drawable-xhdpi/wallpaper_11.jpg
+++ b/res/drawable-xhdpi/wallpaper_11.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/wallpaper_12.jpg b/res/drawable-xhdpi/wallpaper_12.jpg
index ed7fa0f..d1ca450 100644
--- a/res/drawable-xhdpi/wallpaper_12.jpg
+++ b/res/drawable-xhdpi/wallpaper_12.jpg
Binary files differ
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 5b33c31..96ec33e 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -352,11 +352,6 @@
             // force building the layer, so you don't get a blip early in an animation
             // when the layer is created layer
             buildLayer();
-
-            // Let the GC system know that now is a good time to do any garbage
-            // collection; makes it less likely we'll get a GC during the all apps
-            // to workspace animation
-            System.gc();
         }
     }
 
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 56fdbb6..0225d28 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1384,39 +1384,54 @@
             // also will cancel mWaitingForResult.
             closeSystemDialogs();
 
-            boolean alreadyOnHome = ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
+            final boolean alreadyOnHome =
+                    ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
                         != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
 
-            Folder openFolder = mWorkspace.getOpenFolder();
-            // In all these cases, only animate if we're already on home
-            mWorkspace.exitWidgetResizeMode();
-            if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() &&
-                    openFolder == null) {
-                mWorkspace.moveToDefaultScreen(true);
-            }
+            Runnable processIntent = new Runnable() {
+                public void run() {
+                    Folder openFolder = mWorkspace.getOpenFolder();
+                    // In all these cases, only animate if we're already on home
+                    mWorkspace.exitWidgetResizeMode();
+                    if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() &&
+                            openFolder == null) {
+                        mWorkspace.moveToDefaultScreen(true);
+                    }
 
-            closeFolder();
-            exitSpringLoadedDragMode();
+                    closeFolder();
+                    exitSpringLoadedDragMode();
 
-            // If we are already on home, then just animate back to the workspace, otherwise, just
-            // wait until onResume to set the state back to Workspace
-            if (alreadyOnHome) {
-                showWorkspace(true);
+                    // If we are already on home, then just animate back to the workspace,
+                    // otherwise, just wait until onResume to set the state back to Workspace
+                    if (alreadyOnHome) {
+                        showWorkspace(true);
+                    } else {
+                        mOnResumeState = State.WORKSPACE;
+                    }
+
+                    final View v = getWindow().peekDecorView();
+                    if (v != null && v.getWindowToken() != null) {
+                        InputMethodManager imm = (InputMethodManager)getSystemService(
+                                INPUT_METHOD_SERVICE);
+                        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
+                    }
+
+                    // Reset AllApps to its initial state
+                    if (!alreadyOnHome && mAppsCustomizeTabHost != null) {
+                        mAppsCustomizeTabHost.reset();
+                    }
+                }
+            };
+
+            if (alreadyOnHome && !mWorkspace.hasWindowFocus()) {
+                // Delay processing of the intent to allow the status bar animation to finish
+                // first in order to avoid janky animations.
+                mWorkspace.postDelayed(processIntent, 350);
             } else {
-                mOnResumeState = State.WORKSPACE;
+                // Process the intent immediately.
+                processIntent.run();
             }
 
-            final View v = getWindow().peekDecorView();
-            if (v != null && v.getWindowToken() != null) {
-                InputMethodManager imm = (InputMethodManager)getSystemService(
-                        INPUT_METHOD_SERVICE);
-                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
-            }
-
-            // Reset AllApps to its initial state
-            if (!alreadyOnHome && mAppsCustomizeTabHost != null) {
-                mAppsCustomizeTabHost.reset();
-            }
         }
     }