From 3e0839e5f830ab7e64223ebe186d97729eda3e22 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 3 Oct 2011 15:15:18 -0700 Subject: Fixing issue where dragging in the hotseat could trigger scrolling to side pages. (Bug: 5151006) Change-Id: I1b1b98ecc87180fa5994f46194f1b5668e618b91 --- src/com/android/launcher2/DragController.java | 14 ++++++++------ src/com/android/launcher2/DragScroller.java | 4 ++-- src/com/android/launcher2/Workspace.java | 12 +++++++++--- 3 files changed, 19 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java index ca7e55b64..107f8ef9d 100644 --- a/src/com/android/launcher2/DragController.java +++ b/src/com/android/launcher2/DragController.java @@ -484,16 +484,18 @@ public class DragController { if (!inDeleteRegion && x < mScrollZone) { if (mScrollState == SCROLL_OUTSIDE_ZONE && mDistanceSinceScroll > slop) { mScrollState = SCROLL_WAITING_IN_ZONE; - mScrollRunnable.setDirection(SCROLL_LEFT); - mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY); - mDragScroller.onEnterScrollArea(x, y, SCROLL_LEFT); + if (mDragScroller.onEnterScrollArea(x, y, SCROLL_LEFT)) { + mScrollRunnable.setDirection(SCROLL_LEFT); + mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY); + } } } else if (!inDeleteRegion && x > mScrollView.getWidth() - mScrollZone) { if (mScrollState == SCROLL_OUTSIDE_ZONE && mDistanceSinceScroll > slop) { mScrollState = SCROLL_WAITING_IN_ZONE; - mScrollRunnable.setDirection(SCROLL_RIGHT); - mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY); - mDragScroller.onEnterScrollArea(x, y, SCROLL_RIGHT); + if (mDragScroller.onEnterScrollArea(x, y, SCROLL_RIGHT)) { + mScrollRunnable.setDirection(SCROLL_RIGHT); + mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY); + } } } else { if (mScrollState == SCROLL_WAITING_IN_ZONE) { diff --git a/src/com/android/launcher2/DragScroller.java b/src/com/android/launcher2/DragScroller.java index 894b06b27..a3ee6c237 100644 --- a/src/com/android/launcher2/DragScroller.java +++ b/src/com/android/launcher2/DragScroller.java @@ -30,11 +30,11 @@ public interface DragScroller { * * @param direction The scroll direction */ - void onEnterScrollArea(int x, int y, int direction); + boolean onEnterScrollArea(int x, int y, int direction); /** * The touch point has left the scroll area. * NOTE: This may not be called, if a drop occurs inside the scroll area. */ - void onExitScrollArea(); + boolean onExitScrollArea(); } diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 873c03841..13a122345 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -3091,16 +3091,17 @@ public class Workspace extends SmoothPagedView } @Override - public void onEnterScrollArea(int x, int y, int direction) { + public boolean onEnterScrollArea(int x, int y, int direction) { // Ignore the scroll area if we are dragging over the hot seat if (mLauncher.getHotseat() != null) { Rect r = new Rect(); mLauncher.getHotseat().getHitRect(r); if (r.contains(x, y)) { - return; + return false; } } + boolean result = false; if (!isSmall() && !mIsSwitchingState) { mInScrollArea = true; @@ -3120,12 +3121,15 @@ public class Workspace extends SmoothPagedView // Workspace is responsible for drawing the edge glow on adjacent pages, // so we need to redraw the workspace when this may have changed. invalidate(); + result = true; } } + return result; } @Override - public void onExitScrollArea() { + public boolean onExitScrollArea() { + boolean result = false; if (mInScrollArea) { if (mDragTargetLayout != null) { // Unmark the overlapping layout and re-enter the current layout @@ -3136,9 +3140,11 @@ public class Workspace extends SmoothPagedView // Workspace is responsible for drawing the edge glow on adjacent pages, // so we need to redraw the workspace when this may have changed. invalidate(); + result = true; } mInScrollArea = false; } + return result; } private void onResetScrollArea() { -- cgit v1.2.3