Move PointerTracker.MIN_GESTURE_RECOGNITION_TIME to GestureStroke
Change-Id: Ib50192ed8f611fd8288ff9b7a1e0a19249cc6348main
parent
430eed6dae
commit
f80f09c7ee
|
@ -47,8 +47,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
|||
private static boolean sGestureHandlingEnabledByInputField = false;
|
||||
private static boolean sGestureHandlingEnabledByUser = false;
|
||||
|
||||
private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec
|
||||
|
||||
public interface KeyEventHandler {
|
||||
/**
|
||||
* Get KeyDetector object that is used for this PointerTracker.
|
||||
|
@ -562,7 +560,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
|||
mGestureStrokeWithPreviewPoints.appendIncrementalBatchPoints(sAggregratedPointers);
|
||||
final int size = sAggregratedPointers.getPointerSize();
|
||||
if (size > sLastRecognitionPointSize
|
||||
&& eventTime > sLastRecognitionTime + MIN_GESTURE_RECOGNITION_TIME) {
|
||||
&& GestureStroke.hasRecognitionTimePast(eventTime, sLastRecognitionTime)) {
|
||||
sLastRecognitionPointSize = size;
|
||||
sLastRecognitionTime = eventTime;
|
||||
if (DEBUG_LISTENER) {
|
||||
|
|
|
@ -36,10 +36,16 @@ public class GestureStroke {
|
|||
|
||||
// TODO: Move some of these to resource.
|
||||
private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 0.75f;
|
||||
private static final int MIN_GESTURE_DURATION = 100; // msec
|
||||
private static final int MIN_GESTURE_START_DURATION = 100; // msec
|
||||
private static final int MIN_GESTURE_RECOGNITION_TIME = 100; // msec
|
||||
private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH = 1.0f / 6.0f;
|
||||
private static final float GESTURE_RECOG_SPEED_THRESHOLD = 0.4f; // dip/msec
|
||||
|
||||
public static final boolean hasRecognitionTimePast(
|
||||
final long currentTime, final long lastRecognitionTime) {
|
||||
return currentTime > lastRecognitionTime + MIN_GESTURE_RECOGNITION_TIME;
|
||||
}
|
||||
|
||||
public GestureStroke(final int pointerId) {
|
||||
mPointerId = pointerId;
|
||||
}
|
||||
|
@ -53,7 +59,7 @@ public class GestureStroke {
|
|||
public boolean isStartOfAGesture() {
|
||||
final int size = mEventTimes.getLength();
|
||||
final int downDuration = (size > 0) ? mEventTimes.get(size - 1) : 0;
|
||||
return downDuration > MIN_GESTURE_DURATION && mLength > mMinGestureLength;
|
||||
return downDuration > MIN_GESTURE_START_DURATION && mLength > mMinGestureLength;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
|
@ -97,7 +103,8 @@ public class GestureStroke {
|
|||
if (!isHistorical) {
|
||||
final int duration = (int)(time - mLastPointTime);
|
||||
if (mLastPointTime != 0 && duration > 0) {
|
||||
final float speed = getDistance(mLastPointX, mLastPointY, x, y) / duration;
|
||||
final float distance = getDistance(mLastPointX, mLastPointY, x, y);
|
||||
final float speed = distance / duration;
|
||||
if (speed < GESTURE_RECOG_SPEED_THRESHOLD) {
|
||||
mIncrementalRecognitionSize = size;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue