am 708cc94a: Remove gesture detection hacking code
* commit '708cc94a354ad96294126a6ba954bf8be5bd5a06': Remove gesture detection hacking codemain
commit
6b5f5bb227
|
@ -29,7 +29,6 @@ import com.android.inputmethod.keyboard.internal.GestureStroke;
|
||||||
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
||||||
import com.android.inputmethod.latin.InputPointers;
|
import com.android.inputmethod.latin.InputPointers;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.Utils;
|
|
||||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||||
import com.android.inputmethod.research.ResearchLogger;
|
import com.android.inputmethod.research.ResearchLogger;
|
||||||
|
|
||||||
|
@ -130,10 +129,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
private static final InputPointers sAggregratedPointers = new InputPointers(
|
private static final InputPointers sAggregratedPointers = new InputPointers(
|
||||||
GestureStroke.DEFAULT_CAPACITY);
|
GestureStroke.DEFAULT_CAPACITY);
|
||||||
private static PointerTrackerQueue sPointerTrackerQueue;
|
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;
|
public final int mPointerId;
|
||||||
|
|
||||||
|
@ -586,7 +581,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
mListener.onEndBatchInput(batchPoints);
|
mListener.onEndBatchInput(batchPoints);
|
||||||
clearBatchInputRecognitionStateOfThisPointerTracker();
|
clearBatchInputRecognitionStateOfThisPointerTracker();
|
||||||
clearBatchInputPointsOfAllPointerTrackers();
|
clearBatchInputPointsOfAllPointerTrackers();
|
||||||
sWasInGesture = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void abortBatchInput() {
|
private void abortBatchInput() {
|
||||||
|
@ -719,7 +713,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, sWasInGesture)) {
|
if (!mInGesture && stroke.isStartOfAGesture(gestureTime)) {
|
||||||
startBatchInput();
|
startBatchInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1002,7 +996,6 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
int code = key.mCode;
|
int code = key.mCode;
|
||||||
callListenerOnCodeInput(key, code, x, y);
|
callListenerOnCodeInput(key, code, x, y);
|
||||||
callListenerOnRelease(key, code, false);
|
callListenerOnRelease(key, code, false);
|
||||||
sWasInGesture = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printTouchEvent(String title, int x, int y, long eventTime) {
|
private void printTouchEvent(String title, int x, int y, long eventTime) {
|
||||||
|
|
|
@ -37,14 +37,11 @@ public class GestureStroke {
|
||||||
private int mLastPointY;
|
private int mLastPointY;
|
||||||
|
|
||||||
private int mMinGestureLength;
|
private int mMinGestureLength;
|
||||||
private int mMinGestureLengthWhileInGesture;
|
|
||||||
private int mMinGestureSampleLength;
|
private int mMinGestureSampleLength;
|
||||||
|
|
||||||
// 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 = 1.0f;
|
private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH = 0.75f;
|
||||||
private static final float MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH_WHILE_IN_GESTURE = 0.5f;
|
private static final int MIN_GESTURE_DURATION = 100; // msec
|
||||||
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_SAMPLING_RATIO_TO_KEY_HEIGHT = 1.0f / 6.0f;
|
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_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);
|
||||||
|
@ -63,18 +60,10 @@ public class GestureStroke {
|
||||||
public void setGestureSampleLength(final int keyWidth, final int keyHeight) {
|
public void setGestureSampleLength(final int keyWidth, final int keyHeight) {
|
||||||
// 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);
|
||||||
mMinGestureLengthWhileInGesture = (int)(
|
|
||||||
keyWidth * MIN_GESTURE_LENGTH_RATIO_TO_KEY_WIDTH_WHILE_IN_GESTURE);
|
|
||||||
mMinGestureSampleLength = (int)(keyHeight * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT);
|
mMinGestureSampleLength = (int)(keyHeight * MIN_GESTURE_SAMPLING_RATIO_TO_KEY_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStartOfAGesture(final int downDuration, final boolean wasInGesture) {
|
public boolean isStartOfAGesture(final int downDuration) {
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
return downDuration > MIN_GESTURE_DURATION && mLength > mMinGestureLength;
|
return downDuration > MIN_GESTURE_DURATION && mLength > mMinGestureLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue