diff --git a/core/java/android/view/GestureDetector.java b/core/java/android/view/GestureDetector.java index 6bbfe0f160b5b..2351548df75a4 100644 --- a/core/java/android/view/GestureDetector.java +++ b/core/java/android/view/GestureDetector.java @@ -17,7 +17,6 @@ package android.view; import android.content.Context; -import android.os.Build; import android.os.Handler; import android.os.Message; @@ -202,6 +201,7 @@ public class GestureDetector { private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout(); private static final int TAP_TIMEOUT = ViewConfiguration.getTapTimeout(); private static final int DOUBLE_TAP_TIMEOUT = ViewConfiguration.getDoubleTapTimeout(); + private static final int DOUBLE_TAP_MIN_TIME = ViewConfiguration.getDoubleTapMinTime(); // constants for Message.what used by GestureHandler below private static final int SHOW_PRESS = 1; @@ -673,7 +673,8 @@ public class GestureDetector { return false; } - if (secondDown.getEventTime() - firstUp.getEventTime() > DOUBLE_TAP_TIMEOUT) { + final long deltaTime = secondDown.getEventTime() - firstUp.getEventTime(); + if (deltaTime > DOUBLE_TAP_TIMEOUT || deltaTime < DOUBLE_TAP_MIN_TIME) { return false; } diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index f8cb9c068aa77..c3f064fdfd4ae 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -96,6 +96,13 @@ public class ViewConfiguration { */ private static final int DOUBLE_TAP_TIMEOUT = 300; + /** + * Defines the minimum duration in milliseconds between the first tap's up event and + * the second tap's down event for an interaction to be considered a + * double-tap. + */ + private static final int DOUBLE_TAP_MIN_TIME = 40; + /** * Defines the maximum duration in milliseconds between a touch pad * touch and release for a given touch to be considered a tap (click) as @@ -435,6 +442,17 @@ public class ViewConfiguration { return DOUBLE_TAP_TIMEOUT; } + /** + * @return the minimum duration in milliseconds between the first tap's + * up event and the second tap's down event for an interaction to be considered a + * double-tap. + * + * @hide + */ + public static int getDoubleTapMinTime() { + return DOUBLE_TAP_MIN_TIME; + } + /** * @return the maximum duration in milliseconds between a touch pad * touch and release for a given touch to be considered a tap (click) as