From e5343ae752f63129ef4a235daaabffba75d5ad9b Mon Sep 17 00:00:00 2001 From: Radford Juang Date: Fri, 16 Jan 2015 14:46:52 -0800 Subject: [PATCH] Fix issue where holding down shutter button sometimes does not trigger burst. This can occur when the user intends to do a long-press but finger budges slightly (e.g., 1 pixel) triggering an ACTION_MOVE event. This fix disables ACTION_MOVE events from being sent to gesture detector, allowing the long tap event to occur when slight finger movement occurs. Change-Id: Id13a7121f0a899291f031509983050d472566c80 --- src/com/android/camera/ShutterButton.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/android/camera/ShutterButton.java b/src/com/android/camera/ShutterButton.java index e80bfcb57..956b863d7 100755 --- a/src/com/android/camera/ShutterButton.java +++ b/src/com/android/camera/ShutterButton.java @@ -105,7 +105,16 @@ public class ShutterButton extends ImageView { @Override public boolean dispatchTouchEvent(MotionEvent m) { if (mTouchEnabled) { - mGestureDetector.onTouchEvent(m); + // Don't send ACTION_MOVE messages to gesture detector unless event motion is out of + // shutter button view. A small motion resets the long tap status. A long tap should + // be interpreted as the duration the finger is held down on the shutter button, + // regardless of any small motions. If motion moves out of shutter button view, the + // gesture detector needs to be notified to reset the long tap status. + if (m.getActionMasked() != MotionEvent.ACTION_MOVE + || m.getX() < 0 || m.getY() < 0 + || m.getX() >= getWidth() || m.getY() >= getHeight()) { + mGestureDetector.onTouchEvent(m); + } if (m.getActionMasked() == MotionEvent.ACTION_UP) { mTouchCoordinate = new TouchCoordinate(m.getX(), m.getY(), this.getMeasuredWidth(), this.getMeasuredHeight()); -- 2.11.0