Fixing transition issues from AppsCustomize.

- Preventing weird space when hitting home while configuring
- Workaround for issue with all workspace items disappearing when going out of AllApps (depends on 5052094 for proper fix)
- Fixing isuse where any multi-finger tap on AppsCustomize would dismiss it

Change-Id: Ibfa8607a66e81703bd78736b72fd7f021e5971d9
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index ca11c1e..714e7f9 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -40,12 +40,12 @@
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.LayoutInflater;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.AccelerateInterpolator;
 import android.widget.GridLayout;
 import android.widget.ImageView;
-import android.widget.TextView;
 import android.widget.Toast;
 
 import com.android.launcher.R;
@@ -244,8 +244,12 @@
     }
 
     @Override
-    protected void onWallpaperTap(android.view.MotionEvent ev) {
-        mLauncher.showWorkspace(true);
+    protected void onWallpaperTap(MotionEvent ev) {
+        int action = ev.getAction();
+        if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) {
+            // Dismiss AppsCustomize if we tap
+            mLauncher.showWorkspace(true);
+        }
     }
 
     /**
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 996d321..af8d986 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1233,11 +1233,11 @@
                         != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
 
             // In all these cases, only animate if we're already on home
-            mWorkspace.unshrink(alreadyOnHome);
             mWorkspace.exitWidgetResizeMode();
             if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive()) {
                 mWorkspace.moveToDefaultScreen(true);
             }
+            exitSpringLoadedDragMode();
             showWorkspace(alreadyOnHome);
 
             final View v = getWindow().peekDecorView();
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 66bb2ab..9913a6b 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -164,6 +164,10 @@
     private AnimatorSet mAnimator;
     private AnimatorListener mShrinkAnimationListener;
     private AnimatorListener mUnshrinkAnimationListener;
+    // Working around the face that cancelled animations may not actually be cancelled if they
+    // are cancelled before starting
+    private boolean mShrinkAnimationEnabled;
+    private boolean mUnshrinkAnimationEnabled;
 
     boolean mAnimatingViewIntoPlace = false;
     boolean mIsDragOccuring = false;
@@ -1394,6 +1398,9 @@
         }
 
         mAnimator = new AnimatorSet();
+        // Workaround the AnimatorSet cancel bug...
+        mUnshrinkAnimationEnabled = false;
+        mShrinkAnimationEnabled = true;
 
         final int childCount = getChildCount();
         initAnimationArrays();
@@ -1484,6 +1491,7 @@
             final float newVerticalWallpaperOffset = wallpaperOffset;
             animWithInterpolator.addUpdateListener(new LauncherAnimatorUpdateListener() {
                 public void onAnimationUpdate(float a, float b) {
+                    if (!mShrinkAnimationEnabled) return;
                     mTransitionProgress = b;
                     if (b == 0f) {
                         // an optimization, and required for correct behavior.
@@ -1695,6 +1703,11 @@
             }
 
             mAnimator = new AnimatorSet();
+
+            // Workaround the AnimatorSet cancel bug...
+            mShrinkAnimationEnabled = false;
+            mUnshrinkAnimationEnabled = true;
+
             final int screenCount = getChildCount();
             initAnimationArrays();
 
@@ -1797,6 +1810,7 @@
                 final float newVerticalWallpaperOffset = enableWallpaperEffects ? 0.5f : 0;
                 animWithInterpolator.addUpdateListener(new LauncherAnimatorUpdateListener() {
                     public void onAnimationUpdate(float a, float b) {
+                        if (!mUnshrinkAnimationEnabled) return;
                         mTransitionProgress = b;
                         if (b == 0f) {
                             // an optimization, but not required
@@ -1832,6 +1846,7 @@
                 rotationAnim.setInterpolator(new DecelerateInterpolator(2.0f));
                 rotationAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
                     public void onAnimationUpdate(float a, float b) {
+                        if (!mUnshrinkAnimationEnabled) return;
                         // don't invalidate workspace because we did it above
                         if (b == 0f) {
                             // an optimization, but not required
@@ -3469,12 +3484,12 @@
     }
 
     void moveToDefaultScreen(boolean animate) {
-        if (isSmall() || mIsSwitchingState) {
-            mLauncher.showWorkspace(animate, (CellLayout) getChildAt(mDefaultPage));
-        } else if (animate) {
-            snapToPage(mDefaultPage);
-        } else {
-            setCurrentPage(mDefaultPage);
+        if (!isSmall()) {
+            if (animate) {
+                snapToPage(mDefaultPage);
+            } else {
+                setCurrentPage(mDefaultPage);
+            }
         }
         getChildAt(mDefaultPage).requestFocus();
     }