diff options
author | Adam Cohen <adamcohen@google.com> | 2014-08-19 17:43:05 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2014-08-19 22:17:10 -0700 |
commit | c50438c802355dff714b04f42a32e518cb9e91d8 (patch) | |
tree | 25b5a44733599d4a83def82e3d3a5e2fb6bb35a0 /src/com/android/launcher3/DragLayer.java | |
parent | f8177d383a86bf0e5230f70c1635fa044ed4b0be (diff) | |
download | android_packages_apps_Trebuchet-c50438c802355dff714b04f42a32e518cb9e91d8.tar.gz android_packages_apps_Trebuchet-c50438c802355dff714b04f42a32e518cb9e91d8.tar.bz2 android_packages_apps_Trebuchet-c50438c802355dff714b04f42a32e518cb9e91d8.zip |
Unify next / prev page hints for drag and drop across devices
-> 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
Diffstat (limited to 'src/com/android/launcher3/DragLayer.java')
-rw-r--r-- | src/com/android/launcher3/DragLayer.java | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java index 80f8dfce8..72d33dae8 100644 --- a/src/com/android/launcher3/DragLayer.java +++ b/src/com/android/launcher3/DragLayer.java @@ -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); } } } |