am faf62426: am 84c1bbd7: Merge "Move PointerTracker.MIN_GESTURE_RECOGNITION_TIME to GestureStroke" into jb-mr1-dev
* commit 'faf62426fda3d17aab070da9a0f0d3f35f33908b': Move PointerTracker.MIN_GESTURE_RECOGNITION_TIME to GestureStrokemain
commit
99220e1d96
|
@ -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