diff options
author | Winson Chung <winsonc@google.com> | 2012-04-27 15:10:44 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-04-27 15:10:44 -0700 |
commit | 0ea66f5c0d981a2caed951ba66a4339990f98ac8 (patch) | |
tree | fce33ea861dc7e45ecc68eb26b9b8922bf3a789c | |
parent | d4540067aef5a5e264f8a3d6a0a7105e65784849 (diff) | |
parent | 873ad10401bede22aa72339996e70710a4807c32 (diff) | |
download | packages_apps_trebuchet-0ea66f5c0d981a2caed951ba66a4339990f98ac8.zip packages_apps_trebuchet-0ea66f5c0d981a2caed951ba66a4339990f98ac8.tar.gz packages_apps_trebuchet-0ea66f5c0d981a2caed951ba66a4339990f98ac8.tar.bz2 |
am 873ad104: Merge "Moving side-page indicators to DragLayer to ensure it draws above hotseat gradient. (Bug 5117499)" into jb-dev
* commit '873ad10401bede22aa72339996e70710a4807c32':
Moving side-page indicators to DragLayer to ensure it draws above hotseat gradient. (Bug 5117499)
-rw-r--r-- | src/com/android/launcher2/DragController.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/DragLayer.java | 47 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedView.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 40 |
4 files changed, 60 insertions, 37 deletions
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java index c9bebe3..d63743f 100644 --- a/src/com/android/launcher2/DragController.java +++ b/src/com/android/launcher2/DragController.java @@ -517,6 +517,7 @@ public class DragController { mScrollState = SCROLL_OUTSIDE_ZONE; mScrollRunnable.setDirection(SCROLL_RIGHT); mDragScroller.onExitScrollArea(); + mLauncher.getDragLayer().onExitScrollArea(); } } @@ -561,6 +562,7 @@ public class DragController { if (mScrollState == SCROLL_OUTSIDE_ZONE) { mScrollState = SCROLL_WAITING_IN_ZONE; if (mDragScroller.onEnterScrollArea(x, y, SCROLL_LEFT)) { + mLauncher.getDragLayer().onEnterScrollArea(SCROLL_LEFT); mScrollRunnable.setDirection(SCROLL_LEFT); mHandler.postDelayed(mScrollRunnable, delay); } @@ -569,6 +571,7 @@ public class DragController { if (mScrollState == SCROLL_OUTSIDE_ZONE) { mScrollState = SCROLL_WAITING_IN_ZONE; if (mDragScroller.onEnterScrollArea(x, y, SCROLL_RIGHT)) { + mLauncher.getDragLayer().onEnterScrollArea(SCROLL_RIGHT); mScrollRunnable.setDirection(SCROLL_RIGHT); mHandler.postDelayed(mScrollRunnable, delay); } @@ -831,6 +834,7 @@ public class DragController { mScrollState = SCROLL_OUTSIDE_ZONE; mDistanceSinceScroll = 0; mDragScroller.onExitScrollArea(); + mLauncher.getDragLayer().onExitScrollArea(); if (isDragging()) { // Force an update so that we can requeue the scroller if necessary diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java index 69ed053..379e599 100644 --- a/src/com/android/launcher2/DragLayer.java +++ b/src/com/android/launcher2/DragLayer.java @@ -23,7 +23,11 @@ import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.content.Context; import android.content.res.Resources; +import android.graphics.Canvas; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; @@ -85,6 +89,9 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang setMotionEventSplittingEnabled(false); setChildrenDrawingOrderEnabled(true); setOnHierarchyChangeListener(this); + + mLeftHoverDrawable = getResources().getDrawable(R.drawable.page_hover_left_holo); + mRightHoverDrawable = getResources().getDrawable(R.drawable.page_hover_right_holo); } public void setup(Launcher launcher, DragController controller) { @@ -720,4 +727,44 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang return i; } } + + private boolean mInScrollArea; + private Drawable mLeftHoverDrawable; + private Drawable mRightHoverDrawable; + + void onEnterScrollArea(int direction) { + mInScrollArea = true; + invalidate(); + } + + void onExitScrollArea() { + mInScrollArea = false; + invalidate(); + } + + @Override + protected void dispatchDraw(Canvas canvas) { + super.dispatchDraw(canvas); + + if (mInScrollArea && !LauncherApplication.isScreenLarge()) { + Workspace workspace = mLauncher.getWorkspace(); + int width = workspace.getWidth(); + Rect childRect = new Rect(); + getDescendantRectRelativeToSelf(workspace.getChildAt(0), childRect); + + int page = workspace.getNextPage(); + CellLayout leftPage = (CellLayout) workspace.getChildAt(page - 1); + CellLayout rightPage = (CellLayout) workspace.getChildAt(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(), + childRect.top, width, childRect.bottom); + mRightHoverDrawable.draw(canvas); + } + } + } } diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index 83b688d..4bcb4c7 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -270,6 +270,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc int getCurrentPage() { return mCurrentPage; } + int getNextPage() { + return (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage; + } int getPageCount() { return getChildCount(); @@ -1858,9 +1861,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc } protected String getCurrentPageDescription() { - int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage; return String.format(getContext().getString(R.string.default_scroll_format), - page + 1, getChildCount()); + getNextPage() + 1, getChildCount()); } @Override diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 892000d..e9dffc5 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -38,6 +38,8 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Point; import android.graphics.PointF; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.Region.Op; import android.graphics.drawable.Drawable; @@ -1314,38 +1316,6 @@ public class Workspace extends SmoothPagedView } @Override - protected void dispatchDraw(Canvas canvas) { - super.dispatchDraw(canvas); - - if (mInScrollArea && !LauncherApplication.isScreenLarge()) { - final int width = getWidth(); - final int height = getHeight(); - final int pageHeight = getChildAt(0).getHeight(); - - // Set the height of the outline to be the height of the page - final int offset = (height - pageHeight - getPaddingTop() - getPaddingBottom()) / 2; - final int paddingTop = getPaddingTop() + offset; - final int paddingBottom = getPaddingBottom() + offset; - - final int page = (mNextPage != INVALID_PAGE ? mNextPage : mCurrentPage); - final CellLayout leftPage = (CellLayout) getChildAt(page - 1); - final CellLayout rightPage = (CellLayout) getChildAt(page + 1); - - if (leftPage != null && leftPage.getIsDragOverlapping()) { - final Drawable d = getResources().getDrawable(R.drawable.page_hover_left_holo); - d.setBounds(getScrollX(), paddingTop, getScrollX() + d.getIntrinsicWidth(), - height - paddingBottom); - d.draw(canvas); - } else if (rightPage != null && rightPage.getIsDragOverlapping()) { - final Drawable d = getResources().getDrawable(R.drawable.page_hover_right_holo); - d.setBounds(getScrollX() + width - d.getIntrinsicWidth(), paddingTop, - getScrollX() + width, height - paddingBottom); - d.draw(canvas); - } - } - } - - @Override protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) { if (!mLauncher.isAllAppsVisible()) { final Folder openFolder = getOpenFolder(); @@ -1564,7 +1534,7 @@ public class Workspace extends SmoothPagedView AnimatorSet anim = animated ? new AnimatorSet() : null; // Stop any scrolling, move to the current page right away - setCurrentPage((mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage); + setCurrentPage(getNextPage()); final State oldState = mState; final boolean oldStateIsNormal = (oldState == State.NORMAL); @@ -3289,7 +3259,7 @@ public class Workspace extends SmoothPagedView * screen while a scroll is in progress. */ public CellLayout getCurrentDropLayout() { - return (CellLayout) getChildAt(mNextPage == INVALID_PAGE ? mCurrentPage : mNextPage); + return (CellLayout) getChildAt(getNextPage()); } /** @@ -3441,7 +3411,7 @@ public class Workspace extends SmoothPagedView if (!isSmall() && !mIsSwitchingState) { mInScrollArea = true; - final int page = (mNextPage != INVALID_PAGE ? mNextPage : mCurrentPage) + + final int page = getNextPage() + (direction == DragController.SCROLL_LEFT ? -1 : 1); // We always want to exit the current layout to ensure parity of enter / exit |