Remove gesture detection hacking code
Change-Id: Idaec3753592ca0a5c5545eb5ab65254a3e32e662main
parent
507113a1bb
commit
708cc94a35
|
@ -29,7 +29,6 @@ import com.android.inputmethod.keyboard.internal.GestureStroke;
|
|||
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
||||
import com.android.inputmethod.latin.InputPointers;
|
||||
import com.android.inputmethod.latin.LatinImeLogger;
|
||||
import com.android.inputmethod.latin.Utils;
|
||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||
import com.android.inputmethod.research.ResearchLogger;
|
||||
|
||||
|
@ -130,10 +129,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
|||
private static final InputPointers sAggregratedPointers = new InputPointers(
|
||||
GestureStroke.DEFAULT_CAPACITY);
|
||||
private static PointerTrackerQueue sPointerTrackerQueue;
|
||||
// HACK: Change gesture detection criteria depending on this variable.
|
||||
// TODO: Find more comprehensive ways to detect a gesture start.
|
||||
// True when the previous user input was a gesture input, not a typing input.
|
||||
private static boolean sWasInGesture;
|
||||
|
||||
public final int mPointerId;
|
||||
|
||||
|
@ -586,7 +581,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
|||
mListener.onEndBatchInput(batchPoints);
|
||||
clearBatchInputRecognitionStateOfThisPointerTracker();
|
||||
clearBatchInputPointsOfAllPointerTrackers();
|
||||
sWasInGesture = true;
|
||||
}
|
||||
|
||||
private void abortBatchInput() {
|
||||
|
@ -719,7 +713,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
|||
if (sShouldHandleGesture && mIsPossibleGesture) {
|
||||
final GestureStroke stroke = mGestureStroke;
|
||||
stroke.addPoint(x, y, gestureTime, isHistorical);
|
||||
if (!mInGesture && stroke.isStartOfAGesture(gestureTime, sWasInGesture)) {
|
||||
if (!mInGesture && stroke.isStartOfAGesture(gestureTime)) {
|
||||
startBatchInput();
|
||||
}
|
||||
}
|
||||
|
@ -1002,7 +996,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
|||
int code = key.mCode;
|
||||
callListenerOnCodeInput(key, code, x, y);
|
||||
callListenerOnRelease(key, code, false);
|
||||
sWasInGesture = false;
|
||||
}
|
||||
|
||||
private void printTouchEvent(String title, int x, int y, long eventTime) {
|
||||
|
|
|
@ -37,14 +37,11 @@ public class GestureStroke {
|
|||
private int mLastPointY;
|
||||
|
||||
private int mMinGestureLength;
|
||||
private int mMinGestureLengthWhileInGesture;
|
||||
private int mMinGestureSampleLength;
|
||||
|
||||
// TODO: Move some of these to resource.
|
||||
private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 1.0f;
|
||||
private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH_WHILE_IN_GESTURE = 0.5f;
|
||||
private static final int MIN_GESTURE_DURATION = 150; // msec
|
||||
private static final int MIN_GESTURE_DURATION_WHILE_IN_GESTURE = 75; // msec
|
||||
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 float MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT = 1.0f / 6.0f;
|
||||
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);
|
||||
|
@ -63,18 +60,10 @@ public class GestureStroke {
|
|||
public void setGestureSampleLength(final int keyWidth, final int keyHeight) {
|
||||
// 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);
|
||||
mMinGestureLengthWhileInGesture = (int)(
|
||||
keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH_WHILE_IN_GESTURE);
|
||||
mMinGestureSampleLength = (int)(keyHeight * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT);
|
||||
}
|
||||
|
||||
public boolean isStartOfAGesture(final int downDuration, final boolean wasInGesture) {
|
||||
// The tolerance of the time duration and the stroke length to detect the start of a
|
||||
// gesture stroke should be eased when the previous input was a gesture input.
|
||||
if (wasInGesture) {
|
||||
return downDuration > MIN_GESTURE_DURATION_WHILE_IN_GESTURE
|
||||
&& mLength > mMinGestureLengthWhileInGesture;
|
||||
}
|
||||
public boolean isStartOfAGesture(final int downDuration) {
|
||||
return downDuration > MIN_GESTURE_DURATION && mLength > mMinGestureLength;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue