Merge "Eliminate redundant time parameter from gesture detection code" into jb-mr1-dev
commit
f92f9de7a9
|
@ -408,8 +408,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
mKeyDetector = keyDetector;
|
mKeyDetector = keyDetector;
|
||||||
mKeyboard = keyDetector.getKeyboard();
|
mKeyboard = keyDetector.getKeyboard();
|
||||||
mIsAlphabetKeyboard = mKeyboard.mId.isAlphabetKeyboard();
|
mIsAlphabetKeyboard = mKeyboard.mId.isAlphabetKeyboard();
|
||||||
mGestureStroke.setGestureSampleLength(
|
mGestureStroke.setGestureSampleLength(mKeyboard.mMostCommonKeyWidth);
|
||||||
mKeyboard.mMostCommonKeyWidth, mKeyboard.mMostCommonKeyHeight);
|
|
||||||
final Key newKey = mKeyDetector.detectHitKey(mKeyX, mKeyY);
|
final Key newKey = mKeyDetector.detectHitKey(mKeyX, mKeyY);
|
||||||
if (newKey != mCurrentKey) {
|
if (newKey != mCurrentKey) {
|
||||||
if (mDrawingProxy != null) {
|
if (mDrawingProxy != null) {
|
||||||
|
@ -713,7 +712,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
if (sShouldHandleGesture && mIsPossibleGesture) {
|
if (sShouldHandleGesture && mIsPossibleGesture) {
|
||||||
final GestureStroke stroke = mGestureStroke;
|
final GestureStroke stroke = mGestureStroke;
|
||||||
stroke.addPoint(x, y, gestureTime, isHistorical);
|
stroke.addPoint(x, y, gestureTime, isHistorical);
|
||||||
if (!mInGesture && stroke.isStartOfAGesture(gestureTime)) {
|
if (!mInGesture && stroke.isStartOfAGesture()) {
|
||||||
startBatchInput();
|
startBatchInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class GestureStroke {
|
||||||
// TODO: Move some of these to resource.
|
// TODO: Move some of these to resource.
|
||||||
private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 0.75f;
|
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_DURATION = 100; // msec
|
||||||
private static final float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT = 1.0f / 6.0f;
|
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
|
private static final float GESTURE_RECOG_SPEED_THRESHOLD = 0.4f; // dip/msec
|
||||||
private static final float GESTURE_RECOG_CURVATURE_THRESHOLD = (float)(Math.PI / 4.0f);
|
private static final float GESTURE_RECOG_CURVATURE_THRESHOLD = (float)(Math.PI / 4.0f);
|
||||||
|
|
||||||
|
@ -57,13 +57,15 @@ public class GestureStroke {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGestureSampleLength(final int keyWidth, final int keyHeight) {
|
public void setGestureSampleLength(final int keyWidth) {
|
||||||
// TODO: Find an appropriate base metric for these length. Maybe diagonal length of the key?
|
// TODO: Find an appropriate base metric for these length. Maybe diagonal length of the key?
|
||||||
mMinGestureLength = (int)(keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH);
|
mMinGestureLength = (int)(keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH);
|
||||||
mMinGestureSampleLength = (int)(keyHeight * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT);
|
mMinGestureSampleLength = (int)(keyWidth * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStartOfAGesture(final int downDuration) {
|
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_DURATION && mLength > mMinGestureLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue