diff options
author | joedow <joedow@chromium.org> | 2015-12-08 14:01:02 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-08 22:02:29 +0000 |
commit | 2de28656801634fdb66b1d591596a6534404895d (patch) | |
tree | 41132cd2c2e0a28f9a53a13463f5cbe1af40cca7 /remoting/android/java/src | |
parent | 5ebd1587dad4f5ce3e670d4c26254b8a66badd7d (diff) | |
download | chromium_src-2de28656801634fdb66b1d591596a6534404895d.zip chromium_src-2de28656801634fdb66b1d591596a6534404895d.tar.gz chromium_src-2de28656801634fdb66b1d591596a6534404895d.tar.bz2 |
Updated the TapGestureDetector to provide coordinates for tap events.
This change allows listeners to receive the coordinates of the initial
fingerdown for tap and longpress events and use them for input injection.
Note: The new parameters are not currently used in the TouchInputHandler
class but will be hooked up in a future CL.
BUG=454549
Review URL: https://codereview.chromium.org/1509983002
Cr-Commit-Position: refs/heads/master@{#363810}
Diffstat (limited to 'remoting/android/java/src')
-rw-r--r-- | remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java | 25 | ||||
-rw-r--r-- | remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java | 4 |
2 files changed, 21 insertions, 8 deletions
diff --git a/remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java b/remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java index 14cf558..45dab79 100644 --- a/remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java +++ b/remoting/android/java/src/org/chromium/chromoting/TapGestureDetector.java @@ -25,16 +25,20 @@ public class TapGestureDetector { * Notified when a tap event occurs. * * @param pointerCount The number of fingers that were tapped. + * @param x The x coordinate of the initial finger tapped. + * @param y The y coordinate of the initial finger tapped. * @return True if the event is consumed. */ - boolean onTap(int pointerCount); + boolean onTap(int pointerCount, float x, float y); /** * Notified when a long-touch event occurs. * * @param pointerCount The number of fingers held down. + * @param x The x coordinate of the initial finger tapped. + * @param y The y coordinate of the initial finger tapped. */ - void onLongPress(int pointerCount); + void onLongPress(int pointerCount, float x, float y); } /** The listener to which notifications are sent. */ @@ -46,6 +50,9 @@ public class TapGestureDetector { /** The maximum number of fingers seen in the gesture. */ private int mPointerCount = 0; + /** The coordinates of the first finger down seen in the gesture. */ + private PointF mInitialPoint; + /** * Stores the location of each down MotionEvent (by pointer ID), for detecting motion of any * pointer beyond the TouchSlop region. @@ -74,7 +81,8 @@ public class TapGestureDetector { public void handleMessage(Message message) { TapGestureDetector detector = mDetector.get(); if (detector != null) { - detector.mListener.onLongPress(detector.mPointerCount); + detector.mListener.onLongPress( + detector.mPointerCount, detector.mInitialPoint.x, detector.mInitialPoint.y); detector.mTapCancelled = true; } } @@ -117,8 +125,9 @@ public class TapGestureDetector { case MotionEvent.ACTION_UP: cancelLongTouchNotification(); if (!mTapCancelled) { - handled = mListener.onTap(mPointerCount); + handled = mListener.onTap(mPointerCount, mInitialPoint.x, mInitialPoint.y); } + mInitialPoint = null; break; case MotionEvent.ACTION_POINTER_UP: @@ -143,8 +152,12 @@ public class TapGestureDetector { pointerIndex = event.getActionIndex(); } int pointerId = event.getPointerId(pointerIndex); - mInitialPositions.put(pointerId, - new PointF(event.getX(pointerIndex), event.getY(pointerIndex))); + PointF eventPosition = new PointF(event.getX(pointerIndex), event.getY(pointerIndex)); + mInitialPositions.put(pointerId, eventPosition); + + if (mInitialPoint == null) { + mInitialPoint = eventPosition; + } } /** Removes the ACTION_UP or ACTION_POINTER_UP event from the stored list. */ diff --git a/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java b/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java index d7520f7..71c3be0 100644 --- a/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java +++ b/remoting/android/java/src/org/chromium/chromoting/TouchInputHandler.java @@ -356,7 +356,7 @@ public class TouchInputHandler implements TouchInputHandlerInterface { /** Called when the user taps the screen with one or more fingers. */ @Override - public boolean onTap(int pointerCount) { + public boolean onTap(int pointerCount, float x, float y) { int button = mouseButtonFromPointerCount(pointerCount); if (button == BUTTON_UNDEFINED) { return false; @@ -370,7 +370,7 @@ public class TouchInputHandler implements TouchInputHandlerInterface { /** Called when a long-press is triggered for one or more fingers. */ @Override - public void onLongPress(int pointerCount) { + public void onLongPress(int pointerCount, float x, float y) { mHeldButton = mouseButtonFromPointerCount(pointerCount); if (mHeldButton != BUTTON_UNDEFINED) { mInputStrategy.injectRemoteButtonEvent(mHeldButton, true); |