Fix UI bugs when dragging items

- On large devices, snap to next screen when you drag an item to the next screen (matches behavior on phones)
- Do not fade out outlines of Workspace pages while using spring loaded mode
- Keep all icons on all pages opaque in spring loaded mode
- Optimize call to clear a CellLayout

Change-Id: Ia15e0e9da499d7835a77218985de47a1f195e4ef
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 9440b89..0a3c96d 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -661,8 +661,10 @@
 
     @Override
     public void removeAllViewsInLayout() {
-        clearOccupiedCells();
-        mChildren.removeAllViewsInLayout();
+        if (mChildren.getChildCount() > 0) {
+            clearOccupiedCells();
+            mChildren.removeAllViewsInLayout();
+        }
     }
 
     public void removeViewWithoutMarkingCells(View view) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 3901594..560448e 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1137,16 +1137,18 @@
                 scrollProgress = Math.min(scrollProgress, 1.0f);
                 scrollProgress = Math.max(scrollProgress, -1.0f);
 
-                // If the current page (i) is being overscrolled, we use a different
-                // set of rules for setting the background alpha multiplier.
-                if ((mScrollX < 0 && i == 0) || (mScrollX > mMaxScrollX &&
-                        i == getChildCount() -1 )) {
-                    cl.setBackgroundAlphaMultiplier(
-                            overScrollBackgroundAlphaInterpolator(Math.abs(scrollProgress)));
-                    mOverScrollPageIndex = i;
-                } else if (mOverScrollPageIndex != i) {
-                    cl.setBackgroundAlphaMultiplier(
-                            backgroundAlphaInterpolator(Math.abs(scrollProgress)));
+                if (mState != State.SPRING_LOADED) {
+                    // If the current page (i) is being overscrolled, we use a different
+                    // set of rules for setting the background alpha multiplier.
+                    if ((mScrollX < 0 && i == 0) || (mScrollX > mMaxScrollX &&
+                            i == getChildCount() -1 )) {
+                        cl.setBackgroundAlphaMultiplier(
+                                overScrollBackgroundAlphaInterpolator(Math.abs(scrollProgress)));
+                        mOverScrollPageIndex = i;
+                    } else if (mOverScrollPageIndex != i) {
+                        cl.setBackgroundAlphaMultiplier(
+                                backgroundAlphaInterpolator(Math.abs(scrollProgress)));
+                    }
                 }
 
                 float rotation = WORKSPACE_ROTATION * scrollProgress;
@@ -1758,7 +1760,7 @@
                 // Set the final alpha depending on whether we are fading side pages.  On phone ui,
                 // we don't do any of the rotation, or the fading alpha in portrait.  See the
                 // ctor and screenScrolled().
-                if (mFadeInAdjacentScreens) {
+                if (mFadeInAdjacentScreens && !springLoaded) {
                     finalAlphaValue = (i == mCurrentPage) ? 1f : 0f;
                 } else {
                     finalAlphaValue = 1f;
@@ -2279,15 +2281,6 @@
             }
         }
 
-        // When you are in customization mode and drag to a particular screen, make that the
-        // new current/default screen, so any subsequent taps add items to that screen
-        if (!mLauncher.isAllAppsVisible()) {
-            int dragTargetIndex = indexOfChild(mDragTargetLayout);
-            if (dragTargetIndex > -1 && mCurrentPage != dragTargetIndex &&
-                    (isSmall() || mIsSwitchingState)) {
-                scrollToNewPageWithoutMovingPages(dragTargetIndex);
-            }
-        }
         CellLayout dropTargetLayout = mDragTargetLayout;
 
         int snapScreen = -1;
@@ -2340,7 +2333,7 @@
                         (int) mDragViewVisualCenter[1], mDragInfo.spanX, mDragInfo.spanY, cell,
                         dropTargetLayout, mTargetCell);
 
-                if (mInScrollArea && !hasMovedIntoHotseat && mState != State.SPRING_LOADED) {
+                if (mCurrentPage != screen && !hasMovedIntoHotseat) {
                     snapScreen = screen;
                     snapToPage(screen);
                 }