Merge "Preventing screen rotations when dragging." into honeycomb
diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java
index 3e97315..8ed1f46 100644
--- a/src/com/android/launcher2/AllAppsPagedView.java
+++ b/src/com/android/launcher2/AllAppsPagedView.java
@@ -221,11 +221,13 @@
             public void run() {
                 DeleteZone allAppsDeleteZone =
                         (DeleteZone) mLauncher.findViewById(R.id.all_apps_delete_zone);
-                allAppsDeleteZone.setDragAndDropEnabled(false);
+                // if onDestroy was called on Launcher, we might have already deleted the
+                // all apps delete zone / info button, so check if they are null
+                if (allAppsDeleteZone != null) allAppsDeleteZone.setDragAndDropEnabled(false);
 
                 ApplicationInfoDropTarget allAppsInfoButton =
                     (ApplicationInfoDropTarget) mLauncher.findViewById(R.id.all_apps_info_target);
-                allAppsInfoButton.setDragAndDropEnabled(false);
+                if (allAppsInfoButton != null) allAppsInfoButton.setDragAndDropEnabled(false);
             }
         });
         resetCheckedGrandchildren();
diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java
index 2cc0a6b..47a5bf7 100644
--- a/src/com/android/launcher2/AllAppsTabbed.java
+++ b/src/com/android/launcher2/AllAppsTabbed.java
@@ -48,6 +48,7 @@
     private AllAppsPagedView mAllApps;
     private Context mContext;
     private final LayoutInflater mInflater;
+    private boolean mFirstLayout = true;
 
     public AllAppsTabbed(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -135,6 +136,11 @@
 
     @Override
     public void setVisibility(int visibility) {
+        if (visibility == View.GONE && mFirstLayout) {
+            // It needs to be INVISIBLE so that it will be measured in the layout.
+            // Otherwise the animations is messed up when we show it for the first time.
+            visibility = View.INVISIBLE;
+        }
         final boolean isVisible = (visibility == View.VISIBLE); 
         super.setVisibility(visibility);
         float zoom = (isVisible ? 1.0f : 0.0f);
@@ -147,6 +153,12 @@
     }
 
     @Override
+    protected void onLayout(boolean changed, int l, int t, int r, int b) {
+        mFirstLayout = false;
+        super.onLayout(changed, l, t, r, b);
+    }
+
+    @Override
     public boolean isAnimating() {
         return (getAnimation() != null);
     }
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index e5c11de..4b8b682 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1525,6 +1525,8 @@
         mWorkspace.removeAllViews();
         mWorkspace = null;
         mDragController = null;
+
+        ValueAnimator.clearAllAnimations();
     }
 
     @Override
@@ -2685,7 +2687,6 @@
 
         if (toAllApps) {
             mWorkspace.shrink(ShrinkState.BOTTOM_HIDDEN, animated);
-            toView.setAlpha(0f);
         } else {
             mWorkspace.shrink(ShrinkState.TOP, animated);
         }
@@ -2698,6 +2699,7 @@
             scaleAnim.setDuration(duration);
 
             if (toAllApps) {
+                toView.setAlpha(0f);
                 ObjectAnimator alphaAnim = ObjectAnimator.ofPropertyValuesHolder(toView,
                         PropertyValuesHolder.ofFloat("alpha", 1.0f));
                 alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f));
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index a40b7e8..058885f 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -287,6 +287,7 @@
                     mDrawCustomizeTrayBackground = false;
                 }
                 enableCacheUpdates();
+                mAnimator = null;
             }
         };
         mShrinkAnimationListener = new AnimatorListenerAdapter() {
@@ -297,6 +298,7 @@
             @Override
             public void onAnimationEnd(Animator animation) {
                 enableCacheUpdates();
+                mAnimator = null;
             }
         };
         mSnapVelocity = 600;
@@ -1437,6 +1439,7 @@
     }
 
     void unshrink(boolean animated, boolean springLoaded) {
+        mWaitingToShrink = false;
         if (mIsSmall) {
             float finalScaleFactor = 1.0f;
             float finalBackgroundAlpha = 0.0f;