Merge "Add a minimum timeout for double-tap in GestureDetector" into klp-dev
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
|
||||||
@@ -202,6 +201,7 @@ public class GestureDetector {
|
|||||||
private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout();
|
private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout();
|
||||||
private static final int TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
|
private static final int TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
|
||||||
private static final int DOUBLE_TAP_TIMEOUT = ViewConfiguration.getDoubleTapTimeout();
|
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
|
// constants for Message.what used by GestureHandler below
|
||||||
private static final int SHOW_PRESS = 1;
|
private static final int SHOW_PRESS = 1;
|
||||||
@@ -673,7 +673,8 @@ public class GestureDetector {
|
|||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,13 @@ public class ViewConfiguration {
|
|||||||
*/
|
*/
|
||||||
private static final int DOUBLE_TAP_TIMEOUT = 300;
|
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
|
* Defines the maximum duration in milliseconds between a touch pad
|
||||||
* touch and release for a given touch to be considered a tap (click) as
|
* 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 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
|
* @return the maximum duration in milliseconds between a touch pad
|
||||||
* touch and release for a given touch to be considered a tap (click) as
|
* touch and release for a given touch to be considered a tap (click) as
|
||||||
|
|||||||
Reference in New Issue
Block a user