OSDN Git Service

Unify next / prev page hints for drag and drop across devices
authorAdam Cohen <adamcohen@google.com>
Wed, 20 Aug 2014 00:43:05 +0000 (17:43 -0700)
committerAdam Cohen <adamcohen@google.com>
Wed, 20 Aug 2014 05:17:10 +0000 (22:17 -0700)
-> Eliminate the white bgs on tablets during drag (issue 15880213)
-> Add stateful (active and rest) next / prev page hints (issue 15937059)
-> Fix recent regression which allowed overscroll in custom content area

Change-Id: I1198dc88ca8570cb9e1afd3ca939be06a8dea92e

43 files changed:
res/drawable-hdpi/ic_pageindicator_add.png
res/drawable-hdpi/ic_pageindicator_current.png
res/drawable-hdpi/ic_pageindicator_default.png
res/drawable-hdpi/page_hover_left.9.png [new file with mode: 0644]
res/drawable-hdpi/page_hover_left_active.9.png [new file with mode: 0644]
res/drawable-hdpi/page_hover_left_holo.9.png [deleted file]
res/drawable-hdpi/page_hover_right.9.png [new file with mode: 0644]
res/drawable-hdpi/page_hover_right_active.9.png [new file with mode: 0644]
res/drawable-hdpi/page_hover_right_holo.9.png [deleted file]
res/drawable-hdpi/quantum_panel.9.png
res/drawable-mdpi/ic_pageindicator_add.png
res/drawable-mdpi/ic_pageindicator_current.png
res/drawable-mdpi/ic_pageindicator_default.png
res/drawable-mdpi/page_hover_left.9.png [new file with mode: 0644]
res/drawable-mdpi/page_hover_left_active.9.png [new file with mode: 0644]
res/drawable-mdpi/page_hover_left_holo.9.png [deleted file]
res/drawable-mdpi/page_hover_right.9.png [new file with mode: 0644]
res/drawable-mdpi/page_hover_right_active.9.png [new file with mode: 0644]
res/drawable-mdpi/page_hover_right_holo.9.png [deleted file]
res/drawable-mdpi/quantum_panel.9.png
res/drawable-xhdpi/ic_pageindicator_add.png
res/drawable-xhdpi/ic_pageindicator_current.png
res/drawable-xhdpi/ic_pageindicator_default.png
res/drawable-xhdpi/page_hover_left.9.png [new file with mode: 0644]
res/drawable-xhdpi/page_hover_left_active.9.png [new file with mode: 0644]
res/drawable-xhdpi/page_hover_left_holo.9.png [deleted file]
res/drawable-xhdpi/page_hover_right.9.png [new file with mode: 0644]
res/drawable-xhdpi/page_hover_right_active.9.png [new file with mode: 0644]
res/drawable-xhdpi/page_hover_right_holo.9.png [deleted file]
res/drawable-xhdpi/quantum_panel.9.png
res/drawable-xxhdpi/ic_pageindicator_add.png
res/drawable-xxhdpi/ic_pageindicator_current.png
res/drawable-xxhdpi/ic_pageindicator_default.png
res/drawable-xxhdpi/page_hover_left.9.png [new file with mode: 0644]
res/drawable-xxhdpi/page_hover_left_active.9.png [new file with mode: 0644]
res/drawable-xxhdpi/page_hover_left_holo.9.png [deleted file]
res/drawable-xxhdpi/page_hover_right.9.png [new file with mode: 0644]
res/drawable-xxhdpi/page_hover_right_active.9.png [new file with mode: 0644]
res/drawable-xxhdpi/page_hover_right_holo.9.png [deleted file]
res/drawable-xxhdpi/quantum_panel.9.png
src/com/android/launcher3/CellLayout.java
src/com/android/launcher3/DragLayer.java
src/com/android/launcher3/Workspace.java

index 4bb8bfa..ab0e5db 100644 (file)
Binary files a/res/drawable-hdpi/ic_pageindicator_add.png and b/res/drawable-hdpi/ic_pageindicator_add.png differ
index bd15fb4..2e841f5 100644 (file)
Binary files a/res/drawable-hdpi/ic_pageindicator_current.png and b/res/drawable-hdpi/ic_pageindicator_current.png differ
index 2386cd8..07ab948 100644 (file)
Binary files a/res/drawable-hdpi/ic_pageindicator_default.png and b/res/drawable-hdpi/ic_pageindicator_default.png differ
diff --git a/res/drawable-hdpi/page_hover_left.9.png b/res/drawable-hdpi/page_hover_left.9.png
new file mode 100644 (file)
index 0000000..5f7087c
Binary files /dev/null and b/res/drawable-hdpi/page_hover_left.9.png differ
diff --git a/res/drawable-hdpi/page_hover_left_active.9.png b/res/drawable-hdpi/page_hover_left_active.9.png
new file mode 100644 (file)
index 0000000..8787126
Binary files /dev/null and b/res/drawable-hdpi/page_hover_left_active.9.png differ
diff --git a/res/drawable-hdpi/page_hover_left_holo.9.png b/res/drawable-hdpi/page_hover_left_holo.9.png
deleted file mode 100644 (file)
index 8a1aa5f..0000000
Binary files a/res/drawable-hdpi/page_hover_left_holo.9.png and /dev/null differ
diff --git a/res/drawable-hdpi/page_hover_right.9.png b/res/drawable-hdpi/page_hover_right.9.png
new file mode 100644 (file)
index 0000000..ef991b7
Binary files /dev/null and b/res/drawable-hdpi/page_hover_right.9.png differ
diff --git a/res/drawable-hdpi/page_hover_right_active.9.png b/res/drawable-hdpi/page_hover_right_active.9.png
new file mode 100644 (file)
index 0000000..cd5b42d
Binary files /dev/null and b/res/drawable-hdpi/page_hover_right_active.9.png differ
diff --git a/res/drawable-hdpi/page_hover_right_holo.9.png b/res/drawable-hdpi/page_hover_right_holo.9.png
deleted file mode 100644 (file)
index abf8f51..0000000
Binary files a/res/drawable-hdpi/page_hover_right_holo.9.png and /dev/null differ
index a005e0b..914961a 100644 (file)
Binary files a/res/drawable-hdpi/quantum_panel.9.png and b/res/drawable-hdpi/quantum_panel.9.png differ
index e20ffa7..11659a3 100644 (file)
Binary files a/res/drawable-mdpi/ic_pageindicator_add.png and b/res/drawable-mdpi/ic_pageindicator_add.png differ
index bb49d31..08f43b4 100644 (file)
Binary files a/res/drawable-mdpi/ic_pageindicator_current.png and b/res/drawable-mdpi/ic_pageindicator_current.png differ
index 50d0989..635be4a 100644 (file)
Binary files a/res/drawable-mdpi/ic_pageindicator_default.png and b/res/drawable-mdpi/ic_pageindicator_default.png differ
diff --git a/res/drawable-mdpi/page_hover_left.9.png b/res/drawable-mdpi/page_hover_left.9.png
new file mode 100644 (file)
index 0000000..0d537e6
Binary files /dev/null and b/res/drawable-mdpi/page_hover_left.9.png differ
diff --git a/res/drawable-mdpi/page_hover_left_active.9.png b/res/drawable-mdpi/page_hover_left_active.9.png
new file mode 100644 (file)
index 0000000..3004f9e
Binary files /dev/null and b/res/drawable-mdpi/page_hover_left_active.9.png differ
diff --git a/res/drawable-mdpi/page_hover_left_holo.9.png b/res/drawable-mdpi/page_hover_left_holo.9.png
deleted file mode 100644 (file)
index 561d3cd..0000000
Binary files a/res/drawable-mdpi/page_hover_left_holo.9.png and /dev/null differ
diff --git a/res/drawable-mdpi/page_hover_right.9.png b/res/drawable-mdpi/page_hover_right.9.png
new file mode 100644 (file)
index 0000000..c0fbb7d
Binary files /dev/null and b/res/drawable-mdpi/page_hover_right.9.png differ
diff --git a/res/drawable-mdpi/page_hover_right_active.9.png b/res/drawable-mdpi/page_hover_right_active.9.png
new file mode 100644 (file)
index 0000000..6d39687
Binary files /dev/null and b/res/drawable-mdpi/page_hover_right_active.9.png differ
diff --git a/res/drawable-mdpi/page_hover_right_holo.9.png b/res/drawable-mdpi/page_hover_right_holo.9.png
deleted file mode 100644 (file)
index 2681f23..0000000
Binary files a/res/drawable-mdpi/page_hover_right_holo.9.png and /dev/null differ
index 785f573..b9b9506 100644 (file)
Binary files a/res/drawable-mdpi/quantum_panel.9.png and b/res/drawable-mdpi/quantum_panel.9.png differ
index 9659e6f..af1da2d 100644 (file)
Binary files a/res/drawable-xhdpi/ic_pageindicator_add.png and b/res/drawable-xhdpi/ic_pageindicator_add.png differ
index 07b3137..0e9a52f 100644 (file)
Binary files a/res/drawable-xhdpi/ic_pageindicator_current.png and b/res/drawable-xhdpi/ic_pageindicator_current.png differ
index 0351d57..d0f14cd 100644 (file)
Binary files a/res/drawable-xhdpi/ic_pageindicator_default.png and b/res/drawable-xhdpi/ic_pageindicator_default.png differ
diff --git a/res/drawable-xhdpi/page_hover_left.9.png b/res/drawable-xhdpi/page_hover_left.9.png
new file mode 100644 (file)
index 0000000..9b0def8
Binary files /dev/null and b/res/drawable-xhdpi/page_hover_left.9.png differ
diff --git a/res/drawable-xhdpi/page_hover_left_active.9.png b/res/drawable-xhdpi/page_hover_left_active.9.png
new file mode 100644 (file)
index 0000000..6440bdf
Binary files /dev/null and b/res/drawable-xhdpi/page_hover_left_active.9.png differ
diff --git a/res/drawable-xhdpi/page_hover_left_holo.9.png b/res/drawable-xhdpi/page_hover_left_holo.9.png
deleted file mode 100644 (file)
index 4972a2e..0000000
Binary files a/res/drawable-xhdpi/page_hover_left_holo.9.png and /dev/null differ
diff --git a/res/drawable-xhdpi/page_hover_right.9.png b/res/drawable-xhdpi/page_hover_right.9.png
new file mode 100644 (file)
index 0000000..c7bdfe9
Binary files /dev/null and b/res/drawable-xhdpi/page_hover_right.9.png differ
diff --git a/res/drawable-xhdpi/page_hover_right_active.9.png b/res/drawable-xhdpi/page_hover_right_active.9.png
new file mode 100644 (file)
index 0000000..43660e5
Binary files /dev/null and b/res/drawable-xhdpi/page_hover_right_active.9.png differ
diff --git a/res/drawable-xhdpi/page_hover_right_holo.9.png b/res/drawable-xhdpi/page_hover_right_holo.9.png
deleted file mode 100644 (file)
index b99461f..0000000
Binary files a/res/drawable-xhdpi/page_hover_right_holo.9.png and /dev/null differ
index 5726fd2..1bbb937 100644 (file)
Binary files a/res/drawable-xhdpi/quantum_panel.9.png and b/res/drawable-xhdpi/quantum_panel.9.png differ
index 591b189..c288952 100644 (file)
Binary files a/res/drawable-xxhdpi/ic_pageindicator_add.png and b/res/drawable-xxhdpi/ic_pageindicator_add.png differ
index 4e4660f..b74e92e 100644 (file)
Binary files a/res/drawable-xxhdpi/ic_pageindicator_current.png and b/res/drawable-xxhdpi/ic_pageindicator_current.png differ
index 1cccb17..e362ece 100644 (file)
Binary files a/res/drawable-xxhdpi/ic_pageindicator_default.png and b/res/drawable-xxhdpi/ic_pageindicator_default.png differ
diff --git a/res/drawable-xxhdpi/page_hover_left.9.png b/res/drawable-xxhdpi/page_hover_left.9.png
new file mode 100644 (file)
index 0000000..0c0eddd
Binary files /dev/null and b/res/drawable-xxhdpi/page_hover_left.9.png differ
diff --git a/res/drawable-xxhdpi/page_hover_left_active.9.png b/res/drawable-xxhdpi/page_hover_left_active.9.png
new file mode 100644 (file)
index 0000000..a9ae222
Binary files /dev/null and b/res/drawable-xxhdpi/page_hover_left_active.9.png differ
diff --git a/res/drawable-xxhdpi/page_hover_left_holo.9.png b/res/drawable-xxhdpi/page_hover_left_holo.9.png
deleted file mode 100644 (file)
index 626aafb..0000000
Binary files a/res/drawable-xxhdpi/page_hover_left_holo.9.png and /dev/null differ
diff --git a/res/drawable-xxhdpi/page_hover_right.9.png b/res/drawable-xxhdpi/page_hover_right.9.png
new file mode 100644 (file)
index 0000000..d61f94f
Binary files /dev/null and b/res/drawable-xxhdpi/page_hover_right.9.png differ
diff --git a/res/drawable-xxhdpi/page_hover_right_active.9.png b/res/drawable-xxhdpi/page_hover_right_active.9.png
new file mode 100644 (file)
index 0000000..079ee1e
Binary files /dev/null and b/res/drawable-xxhdpi/page_hover_right_active.9.png differ
diff --git a/res/drawable-xxhdpi/page_hover_right_holo.9.png b/res/drawable-xxhdpi/page_hover_right_holo.9.png
deleted file mode 100644 (file)
index 66257dc..0000000
Binary files a/res/drawable-xxhdpi/page_hover_right_holo.9.png and /dev/null differ
index 035cdc4..4392aa0 100644 (file)
Binary files a/res/drawable-xxhdpi/quantum_panel.9.png and b/res/drawable-xxhdpi/quantum_panel.9.png differ
index 93006b3..89473c8 100644 (file)
@@ -72,6 +72,7 @@ public class CellLayout extends ViewGroup {
     private int mHeightGap;
     private int mMaxGap;
     private boolean mDropPending = false;
+    private boolean mIsDragTarget = true;
 
     // These are temporary variables to prevent having to allocate a new object just to
     // return an (x, y) value from helper functions. Do NOT use them to maintain other state.
@@ -367,14 +368,6 @@ public class CellLayout extends ViewGroup {
         }
     }
 
-    void setIsDragOverlapping(boolean isDragOverlapping) {
-        if (mIsDragOverlapping != isDragOverlapping) {
-            mIsDragOverlapping = isDragOverlapping;
-            setUseActiveGlowBackground(mIsDragOverlapping);
-            invalidate();
-        }
-    }
-
     void setUseActiveGlowBackground(boolean use) {
         mUseActiveGlowBackground = use;
     }
@@ -383,6 +376,22 @@ public class CellLayout extends ViewGroup {
         mDrawBackground = false;
     }
 
+    void disableDragTarget() {
+        mIsDragTarget = false;
+    }
+
+    boolean isDragTarget() {
+        return mIsDragTarget;
+    }
+
+    void setIsDragOverlapping(boolean isDragOverlapping) {
+        if (mIsDragOverlapping != isDragOverlapping) {
+            mIsDragOverlapping = isDragOverlapping;
+            setUseActiveGlowBackground(mIsDragOverlapping);
+            invalidate();
+        }
+    }
+
     boolean getIsDragOverlapping() {
         return mIsDragOverlapping;
     }
@@ -946,6 +955,7 @@ public class CellLayout extends ViewGroup {
     }
 
     public void setBackgroundAlphaMultiplier(float multiplier) {
+
         if (mBackgroundAlphaMultiplier != multiplier) {
             mBackgroundAlphaMultiplier = multiplier;
             invalidate();
index 80f8dfc..72d33da 100644 (file)
@@ -96,8 +96,10 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
         setOnHierarchyChangeListener(this);
 
         final Resources res = getResources();
-        mLeftHoverDrawable = res.getDrawable(R.drawable.page_hover_left_holo);
-        mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right_holo);
+        mLeftHoverDrawable = res.getDrawable(R.drawable.page_hover_left);
+        mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right);
+        mLeftHoverDrawableActive = res.getDrawable(R.drawable.page_hover_left_active);
+        mRightHoverDrawableActive = res.getDrawable(R.drawable.page_hover_right_active);
         mBackground = res.getDrawable(R.drawable.apps_customize_bg);
     }
 
@@ -850,8 +852,11 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
     }
 
     private boolean mInScrollArea;
+    private boolean mShowPageHints;
     private Drawable mLeftHoverDrawable;
     private Drawable mRightHoverDrawable;
+    private Drawable mLeftHoverDrawableActive;
+    private Drawable mRightHoverDrawableActive;
 
     void onEnterScrollArea(int direction) {
         mInScrollArea = true;
@@ -863,6 +868,16 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
         invalidate();
     }
 
+    void showPageHints() {
+        mShowPageHints = true;
+        invalidate();
+    }
+
+    void hidePageHints() {
+        mShowPageHints = false;
+        invalidate();
+    }
+
     /**
      * Note: this is a reimplementation of View.isLayoutRtl() since that is currently hidden api.
      */
@@ -883,25 +898,32 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang
         super.dispatchDraw(canvas);
 
         // Draw screen hover indicators above children.
-        if (mInScrollArea && !LauncherAppState.getInstance().isScreenLarge()) {
+        if (mShowPageHints) {
             Workspace workspace = mLauncher.getWorkspace();
             int width = getMeasuredWidth();
             Rect childRect = new Rect();
-            getDescendantRectRelativeToSelf(workspace.getChildAt(0), childRect);
+            getDescendantRectRelativeToSelf(workspace.getChildAt(workspace.getChildCount() - 1),
+                    childRect);
 
             int page = workspace.getNextPage();
             final boolean isRtl = isLayoutRtl();
             CellLayout leftPage = (CellLayout) workspace.getChildAt(isRtl ? page + 1 : page - 1);
             CellLayout rightPage = (CellLayout) workspace.getChildAt(isRtl ? page - 1 : page + 1);
 
-            if (leftPage != null && leftPage.getIsDragOverlapping()) {
-                mLeftHoverDrawable.setBounds(0, childRect.top,
-                        mLeftHoverDrawable.getIntrinsicWidth(), childRect.bottom);
-                mLeftHoverDrawable.draw(canvas);
-            } else if (rightPage != null && rightPage.getIsDragOverlapping()) {
-                mRightHoverDrawable.setBounds(width - mRightHoverDrawable.getIntrinsicWidth(),
+            if (leftPage != null && leftPage.isDragTarget()) {
+                Drawable left = mInScrollArea && leftPage.getIsDragOverlapping() ?
+                        mLeftHoverDrawableActive : mLeftHoverDrawable;
+                left.setBounds(0, childRect.top,
+                        left.getIntrinsicWidth(), childRect.bottom);
+                left.draw(canvas);
+            }
+            if (rightPage != null && rightPage.isDragTarget()) {
+                Drawable right = mInScrollArea && rightPage.getIsDragOverlapping() ?
+                        mRightHoverDrawableActive : mRightHoverDrawable;
+
+                right.setBounds(width - right.getIntrinsicWidth(),
                         childRect.top, width, childRect.bottom);
-                mRightHoverDrawable.draw(canvas);
+                right.draw(canvas);
             }
         }
     }
index 53a3f94..a6cce93 100644 (file)
@@ -585,6 +585,7 @@ public class Workspace extends SmoothPagedView
         CellLayout customScreen = (CellLayout)
                 mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null);
         customScreen.disableBackground();
+        customScreen.disableDragTarget();
 
         mWorkspaceScreens.put(CUSTOM_CONTENT_SCREEN_ID, customScreen);
         mScreenOrder.add(0, CUSTOM_CONTENT_SCREEN_ID);
@@ -1583,7 +1584,7 @@ public class Workspace extends SmoothPagedView
     private void updatePageAlphaValues(int screenCenter) {
         boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
         if (mWorkspaceFadeInAdjacentScreens &&
-                mState == State.NORMAL &&
+                !workspaceInModalState() &&
                 !mIsSwitchingState &&
                 !isInOverscroll) {
             for (int i = numCustomPages(); i < getChildCount(); i++) {
@@ -1592,6 +1593,7 @@ public class Workspace extends SmoothPagedView
                     float scrollProgress = getScrollProgress(screenCenter, child, i);
                     float alpha = 1 - Math.abs(scrollProgress);
                     child.getShortcutsAndWidgets().setAlpha(alpha);
+                    //child.setBackgroundAlphaMultiplier(1 - alpha);
                 }
             }
         }
@@ -1685,8 +1687,7 @@ public class Workspace extends SmoothPagedView
         updateStateForCustomContent(screenCenter);
         enableHwLayersOnVisiblePages();
 
-        boolean shouldOverScroll = (mOverScrollEffect < 0 && (!hasCustomContent() || isLayoutRtl())) ||
-                (mOverScrollEffect > 0 && (!hasCustomContent() || !isLayoutRtl()));
+        boolean shouldOverScroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
 
         if (shouldOverScroll) {
             int index = 0;
@@ -1710,14 +1711,16 @@ public class Workspace extends SmoothPagedView
         }
     }
 
-    private void computeOverScrollEffect(float amount) {
-        mOverScrollEffect = acceleratedOverFactor(amount);
-    }
-
     @Override
     protected void overScroll(float amount) {
-        computeOverScrollEffect(amount);
-        dampedOverScroll(amount);
+        boolean shouldOverScroll = (amount < 0 && (!hasCustomContent() || isLayoutRtl())) ||
+                (amount > 0 && (!hasCustomContent() || !isLayoutRtl()));
+        if (shouldOverScroll) {
+            dampedOverScroll(amount);
+            mOverScrollEffect = acceleratedOverFactor(amount);
+        } else {
+            mOverScrollEffect = 0;
+        }
     }
 
     protected void onAttachedToWindow() {
@@ -3242,10 +3245,8 @@ public class Workspace extends SmoothPagedView
         setCurrentDropLayout(layout);
         setCurrentDragOverlappingLayout(layout);
 
-        // Because we don't have space in the Phone UI (the CellLayouts run to the edge) we
-        // don't need to show the outlines
-        if (LauncherAppState.getInstance().isScreenLarge()) {
-            showOutlines();
+        if (!workspaceInModalState()) {
+            mLauncher.getDragLayer().showPageHints();
         }
     }
 
@@ -3320,6 +3321,7 @@ public class Workspace extends SmoothPagedView
         if (!mIsPageMoving) {
             hideOutlines();
         }
+        mLauncher.getDragLayer().hidePageHints();
     }
 
     void setCurrentDropLayout(CellLayout layout) {