am 84c1bbd7: Merge "Move PointerTracker.MIN_GESTURE_RECOGNITION_TIME to GestureStroke" into jb-mr1-dev

* commit '84c1bbd76d144c2d777952079b9e8d8fea98c9b2':
  Move PointerTracker.MIN_GESTURE_RECOGNITION_TIME to GestureStroke
This commit is contained in:
Tadashi G. Takaoka 2012-09-20 06:10:08 -07:00 committed by Android Git Automerger
commit faf62426fd
2 changed files with 11 additions and 6 deletions

View file

@ -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) {

View file

@ -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;
}