summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/PagedView.java
diff options
context:
space:
mode:
authorPatrick Dubroy <dubroy@google.com>2011-01-19 18:47:27 -0800
committerPatrick Dubroy <dubroy@google.com>2011-01-19 20:52:20 -0800
commitd0ce1ec2e21ce3bb0ba3549a01d1d06b440a8e45 (patch)
tree80d38d4a819db600ea66b7946112ab1030009eed /src/com/android/launcher2/PagedView.java
parentf4ffdc63d3d5b400174624f5bb8c41c7ed17265b (diff)
downloadpackages_apps_trebuchet-d0ce1ec2e21ce3bb0ba3549a01d1d06b440a8e45.zip
packages_apps_trebuchet-d0ce1ec2e21ce3bb0ba3549a01d1d06b440a8e45.tar.gz
packages_apps_trebuchet-d0ce1ec2e21ce3bb0ba3549a01d1d06b440a8e45.tar.bz2
Fix 3237665: Home screen should scroll on tap, not touch down
Change-Id: I61f65beaf982eec54b86668d6da94aa5c52e9355
Diffstat (limited to 'src/com/android/launcher2/PagedView.java')
-rw-r--r--src/com/android/launcher2/PagedView.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 1965712..4a0f44e 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -696,6 +696,20 @@ public abstract class PagedView extends ViewGroup {
super.requestDisallowInterceptTouchEvent(disallowIntercept);
}
+ /**
+ * Return true if a tap at (x, y) should trigger a flip to the previous page.
+ */
+ protected boolean hitsPreviousPage(float x, float y) {
+ return (x < getRelativeChildOffset(mCurrentPage) - mPageSpacing);
+ }
+
+ /**
+ * Return true if a tap at (x, y) should trigger a flip to the next page.
+ */
+ protected boolean hitsNextPage(float x, float y) {
+ return (x > (getMeasuredWidth() - getRelativeChildOffset(mCurrentPage) + mPageSpacing));
+ }
+
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
/*
@@ -761,14 +775,11 @@ public abstract class PagedView extends ViewGroup {
// check if this can be the beginning of a tap on the side of the pages
// to scroll the current page
- if ((mTouchState != TOUCH_STATE_PREV_PAGE) && !handlePagingClicks() &&
- (mTouchState != TOUCH_STATE_NEXT_PAGE)) {
+ if (mTouchState != TOUCH_STATE_PREV_PAGE && mTouchState != TOUCH_STATE_NEXT_PAGE) {
if (getChildCount() > 0) {
- int width = getMeasuredWidth();
- int offset = getRelativeChildOffset(mCurrentPage);
- if (x < offset - mPageSpacing) {
+ if (hitsPreviousPage(x, y)) {
mTouchState = TOUCH_STATE_PREV_PAGE;
- } else if (x > (width - offset + mPageSpacing)) {
+ } else if (hitsNextPage(x, y)) {
mTouchState = TOUCH_STATE_NEXT_PAGE;
}
}
@@ -856,10 +867,6 @@ public abstract class PagedView extends ViewGroup {
}
}
- protected boolean handlePagingClicks() {
- return false;
- }
-
// This curve determines how the effect of scrolling over the limits of the page dimishes
// as the user pulls further and further from the bounds
private float overScrollInfluenceCurve(float f) {
@@ -966,7 +973,7 @@ public abstract class PagedView extends ViewGroup {
} else {
snapToDestination();
}
- } else if (mTouchState == TOUCH_STATE_PREV_PAGE && !handlePagingClicks()) {
+ } else if (mTouchState == TOUCH_STATE_PREV_PAGE) {
// at this point we have not moved beyond the touch slop
// (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
// we can just page
@@ -976,7 +983,7 @@ public abstract class PagedView extends ViewGroup {
} else {
snapToDestination();
}
- } else if (mTouchState == TOUCH_STATE_NEXT_PAGE && !handlePagingClicks()) {
+ } else if (mTouchState == TOUCH_STATE_NEXT_PAGE) {
// at this point we have not moved beyond the touch slop
// (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
// we can just page