Loading core/java/android/view/GestureDetector.java +10 −3 Original line number Diff line number Diff line Loading @@ -502,6 +502,8 @@ public class GestureDetector { final boolean pointerUp = (action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP; final int skipIndex = pointerUp ? ev.getActionIndex() : -1; final boolean isGeneratedGesture = (ev.getFlags() & MotionEvent.FLAG_IS_GENERATED_GESTURE) != 0; // Determine focal point float sumX = 0, sumY = 0; Loading Loading @@ -604,7 +606,8 @@ public class GestureDetector { final int deltaX = (int) (focusX - mDownFocusX); final int deltaY = (int) (focusY - mDownFocusY); int distance = (deltaX * deltaX) + (deltaY * deltaY); if (distance > mTouchSlopSquare) { int slopSquare = isGeneratedGesture ? 0 : mTouchSlopSquare; if (distance > slopSquare) { handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); mLastFocusX = focusX; mLastFocusY = focusY; Loading @@ -613,7 +616,8 @@ public class GestureDetector { mHandler.removeMessages(SHOW_PRESS); mHandler.removeMessages(LONG_PRESS); } if (distance > mDoubleTapTouchSlopSquare) { int doubleTapSlopSquare = isGeneratedGesture ? 0 : mDoubleTapTouchSlopSquare; if (distance > doubleTapSlopSquare) { mAlwaysInBiggerTapRegion = false; } } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) { Loading Loading @@ -761,7 +765,10 @@ public class GestureDetector { int deltaX = (int) firstDown.getX() - (int) secondDown.getX(); int deltaY = (int) firstDown.getY() - (int) secondDown.getY(); return (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare); final boolean isGeneratedGesture = (firstDown.getFlags() & MotionEvent.FLAG_IS_GENERATED_GESTURE) != 0; int slopSquare = isGeneratedGesture ? 0 : mDoubleTapSlopSquare; return (deltaX * deltaX + deltaY * deltaY < slopSquare); } private void dispatchLongPress() { Loading core/java/android/view/MotionEvent.java +62 −54 Original line number Diff line number Diff line Loading @@ -443,6 +443,14 @@ public final class MotionEvent extends InputEvent implements Parcelable { */ public static final int FLAG_HOVER_EXIT_PENDING = 0x4; /** * This flag indicates that the event has been generated by a gesture generator. It * provides a hint to the GestureDector to not apply any touch slop. * * @hide */ public static final int FLAG_IS_GENERATED_GESTURE = 0x8; /** * Private flag that indicates when the system has detected that this motion event * may be inconsistent with respect to the sequence of previously delivered motion events, Loading Loading
core/java/android/view/GestureDetector.java +10 −3 Original line number Diff line number Diff line Loading @@ -502,6 +502,8 @@ public class GestureDetector { final boolean pointerUp = (action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP; final int skipIndex = pointerUp ? ev.getActionIndex() : -1; final boolean isGeneratedGesture = (ev.getFlags() & MotionEvent.FLAG_IS_GENERATED_GESTURE) != 0; // Determine focal point float sumX = 0, sumY = 0; Loading Loading @@ -604,7 +606,8 @@ public class GestureDetector { final int deltaX = (int) (focusX - mDownFocusX); final int deltaY = (int) (focusY - mDownFocusY); int distance = (deltaX * deltaX) + (deltaY * deltaY); if (distance > mTouchSlopSquare) { int slopSquare = isGeneratedGesture ? 0 : mTouchSlopSquare; if (distance > slopSquare) { handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); mLastFocusX = focusX; mLastFocusY = focusY; Loading @@ -613,7 +616,8 @@ public class GestureDetector { mHandler.removeMessages(SHOW_PRESS); mHandler.removeMessages(LONG_PRESS); } if (distance > mDoubleTapTouchSlopSquare) { int doubleTapSlopSquare = isGeneratedGesture ? 0 : mDoubleTapTouchSlopSquare; if (distance > doubleTapSlopSquare) { mAlwaysInBiggerTapRegion = false; } } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) { Loading Loading @@ -761,7 +765,10 @@ public class GestureDetector { int deltaX = (int) firstDown.getX() - (int) secondDown.getX(); int deltaY = (int) firstDown.getY() - (int) secondDown.getY(); return (deltaX * deltaX + deltaY * deltaY < mDoubleTapSlopSquare); final boolean isGeneratedGesture = (firstDown.getFlags() & MotionEvent.FLAG_IS_GENERATED_GESTURE) != 0; int slopSquare = isGeneratedGesture ? 0 : mDoubleTapSlopSquare; return (deltaX * deltaX + deltaY * deltaY < slopSquare); } private void dispatchLongPress() { Loading
core/java/android/view/MotionEvent.java +62 −54 Original line number Diff line number Diff line Loading @@ -443,6 +443,14 @@ public final class MotionEvent extends InputEvent implements Parcelable { */ public static final int FLAG_HOVER_EXIT_PENDING = 0x4; /** * This flag indicates that the event has been generated by a gesture generator. It * provides a hint to the GestureDector to not apply any touch slop. * * @hide */ public static final int FLAG_IS_GENERATED_GESTURE = 0x8; /** * Private flag that indicates when the system has detected that this motion event * may be inconsistent with respect to the sequence of previously delivered motion events, Loading