OSDN Git Service

Fix UI bugs when dragging items
authorMichael Jurka <mikejurka@google.com>
Wed, 3 Aug 2011 03:19:24 +0000 (20:19 -0700)
committerMichael Jurka <mikejurka@google.com>
Wed, 3 Aug 2011 18:19:58 +0000 (11:19 -0700)
- 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

src/com/android/launcher2/CellLayout.java
src/com/android/launcher2/Workspace.java

index 9440b89..0a3c96d 100644 (file)
@@ -661,8 +661,10 @@ public class CellLayout extends ViewGroup {
 
     @Override
     public void removeAllViewsInLayout() {
-        clearOccupiedCells();
-        mChildren.removeAllViewsInLayout();
+        if (mChildren.getChildCount() > 0) {
+            clearOccupiedCells();
+            mChildren.removeAllViewsInLayout();
+        }
     }
 
     public void removeViewWithoutMarkingCells(View view) {
index 3901594..560448e 100644 (file)
@@ -1137,16 +1137,18 @@ public class Workspace extends SmoothPagedView
                 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 @@ public class Workspace extends SmoothPagedView
                 // 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 @@ public class Workspace extends SmoothPagedView
             }
         }
 
-        // 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 @@ public class Workspace extends SmoothPagedView
                         (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);
                 }