diff options
author | Winson Chung <winsonc@google.com> | 2012-04-27 13:48:05 -0700 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2012-04-27 13:48:51 -0700 |
commit | 360e63fd3e77247002b86da2a77bd8dfe8c8a807 (patch) | |
tree | 381bfd47ff8348fed4ff3747d6ae25bbb7c8cccd /src/com/android/launcher2/DragLayer.java | |
parent | 840ebf6277c8eea38b6a4f03cd8bb4e09bd69c7d (diff) | |
download | Launcher2-360e63fd3e77247002b86da2a77bd8dfe8c8a807.tar.gz |
Moving side-page indicators to DragLayer to ensure it draws above hotseat gradient. (Bug 5117499)
Change-Id: Id0ab644f6631f4fd6be042b6be36ba8fe58eaae4
Diffstat (limited to 'src/com/android/launcher2/DragLayer.java')
-rw-r--r-- | src/com/android/launcher2/DragLayer.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java index 69ed0536..379e5997 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); + } + } + } } |