diff options
Diffstat (limited to 'java/src/com/android/inputmethod')
5 files changed, 200 insertions, 67 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index b41631e83..20d7847ff 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -82,6 +82,17 @@ import java.util.WeakHashMap; * @attr ref R.styleable#MainKeyboardView_longPressShiftKeyTimeout * @attr ref R.styleable#MainKeyboardView_ignoreAltCodeKeyTimeout * @attr ref R.styleable#MainKeyboardView_showMoreKeysKeyboardAtTouchPoint + * @attr ref R.styleable#MainKeyboardView_gestureStaticTimeThresholdAfterFastTyping + * @attr ref R.styleable#MainKeyboardView_gestureDetectFastMoveSpeedThreshold + * @attr ref R.styleable#MainKeyboardView_gestureDynamicThresholdDecayDuration + * @attr ref R.styleable#MainKeyboardView_gestureDynamicTimeThresholdFrom + * @attr ref R.styleable#MainKeyboardView_gestureDynamicTimeThresholdTo + * @attr ref R.styleable#MainKeyboardView_gestureDynamicDistanceThresholdFrom + * @attr ref R.styleable#MainKeyboardView_gestureDynamicDistanceThresholdTo + * @attr ref R.styleable#MainKeyboardView_gestureSamplingMinimumDistance + * @attr ref R.styleable#MainKeyboardView_gestureRecognitionMinimumTime + * @attr ref R.styleable#MainKeyboardView_gestureRecognitionSpeedThreshold + * @attr ref R.styleable#MainKeyboardView_suppressKeyPreviewAfterBatchInputDuration */ public final class MainKeyboardView extends KeyboardView implements PointerTracker.KeyEventHandler, SuddenJumpingTouchEventHandler.ProcessMotionEvent { diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index ad7d0a39f..7aeddc279 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -23,6 +23,7 @@ import android.view.MotionEvent; import com.android.inputmethod.accessibility.AccessibilityUtils; import com.android.inputmethod.keyboard.internal.GestureStroke; +import com.android.inputmethod.keyboard.internal.GestureStroke.GestureStrokeParams; import com.android.inputmethod.keyboard.internal.GestureStrokeWithPreviewPoints; import com.android.inputmethod.keyboard.internal.PointerTrackerQueue; import com.android.inputmethod.latin.CollectionUtils; @@ -47,9 +48,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private static boolean sGestureHandlingEnabledByInputField = false; private static boolean sGestureHandlingEnabledByUser = false; - // TODO: Move this to resource. - private static final int SUPPRESS_KEY_PREVIEW_AFTER_LAST_BATCH_INPUT_DURATION = 1000; // msec - public interface KeyEventHandler { /** * Get KeyDetector object that is used for this PointerTracker. @@ -125,6 +123,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { public final int mTouchNoiseThresholdTime; public final float mTouchNoiseThresholdDistance; public final int mTouchNoiseThresholdDistanceSquared; + public final int mSuppressKeyPreviewAfterBatchInputDuration; public static final PointerTrackerParams DEFAULT = new PointerTrackerParams(); @@ -133,9 +132,10 @@ public final class PointerTracker implements PointerTrackerQueue.Element { mTouchNoiseThresholdTime = 0; mTouchNoiseThresholdDistance = 0.0f; mTouchNoiseThresholdDistanceSquared = 0; + mSuppressKeyPreviewAfterBatchInputDuration = 0; } - public PointerTrackerParams(TypedArray mainKeyboardViewAttr) { + public PointerTrackerParams(final TypedArray mainKeyboardViewAttr) { mSlidingKeyInputEnabled = mainKeyboardViewAttr.getBoolean( R.styleable.MainKeyboardView_slidingKeyInputEnable, false); mTouchNoiseThresholdTime = mainKeyboardViewAttr.getInt( @@ -145,11 +145,14 @@ public final class PointerTracker implements PointerTrackerQueue.Element { mTouchNoiseThresholdDistance = touchNouseThresholdDistance; mTouchNoiseThresholdDistanceSquared = (int)(touchNouseThresholdDistance * touchNouseThresholdDistance); + mSuppressKeyPreviewAfterBatchInputDuration = mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_suppressKeyPreviewAfterBatchInputDuration, 0); } } // Parameters for pointer handling. private static PointerTrackerParams sParams; + private static GestureStrokeParams sGestureStrokeParams; private static boolean sNeedsPhantomSuddenMoveEventHack; private static final ArrayList<PointerTracker> sTrackers = CollectionUtils.newArrayList(); @@ -168,13 +171,80 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private boolean mIsDetectingGesture = false; // per PointerTracker. private static boolean sInGesture = false; private static long sGestureFirstDownTime; - private static long sLastBatchInputTime; - private static long sLastLetterTypingUpTime; + private static TimeRecorder sTimeRecorder; private static final InputPointers sAggregratedPointers = new InputPointers( GestureStroke.DEFAULT_CAPACITY); private static int sLastRecognitionPointSize = 0; // synchronized using sAggregratedPointers private static long sLastRecognitionTime = 0; // synchronized using sAggregratedPointers + static final class TimeRecorder { + private final int mSuppressKeyPreviewAfterBatchInputDuration; + private final int mStaticTimeThresholdAfterFastTyping; // msec + private long mLastTypingTime; + private long mLastLetterTypingTime; + private long mLastBatchInputTime; + + public TimeRecorder(final PointerTrackerParams pointerTrackerParams, + final GestureStrokeParams gestureStrokeParams) { + mSuppressKeyPreviewAfterBatchInputDuration = + pointerTrackerParams.mSuppressKeyPreviewAfterBatchInputDuration; + mStaticTimeThresholdAfterFastTyping = + gestureStrokeParams.mStaticTimeThresholdAfterFastTyping; + } + + private void recordTyping(final long eventTime) { + mLastTypingTime = eventTime; + } + + private void recordLetterTyping(final long eventTime) { + mLastLetterTypingTime = eventTime; + // Reset gesture typing time + mLastBatchInputTime = 0; + } + + private void recordGestureTyping(final long eventTime) { + mLastBatchInputTime = eventTime; + // Reset typing time. + mLastTypingTime = 0; + } + + private boolean isInTyping() { + return mLastTypingTime != 0; + } + + private boolean isInBatchInput() { + return mLastBatchInputTime != 0; + } + + public void onCodeInput(final int code, final long eventTime) { + if (Keyboard.isLetterCode(code) && code != Keyboard.CODE_SPACE) { + if (isInTyping() + && eventTime - mLastTypingTime < mStaticTimeThresholdAfterFastTyping) { + recordLetterTyping(eventTime); + } + } else { + if (eventTime - mLastLetterTypingTime < mStaticTimeThresholdAfterFastTyping) { + // This non-letter typing should be treated as a part of fast typing. + recordLetterTyping(eventTime); + } + } + recordTyping(eventTime); + } + + public void onEndBatchInput(final long eventTime) { + recordGestureTyping(eventTime); + } + + public long getLastLetterTypingTime() { + return mLastLetterTypingTime; + } + + public boolean needsToSuppressKeyPreviewPopup(final long eventTime) { + return !isInTyping() && isInBatchInput() + && eventTime - mLastBatchInputTime < mSuppressKeyPreviewAfterBatchInputDuration; + } + } + // The position and time at which first down event occurred. private long mDownTime; private long mUpTime; @@ -222,10 +292,14 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack; sParams = PointerTrackerParams.DEFAULT; + sGestureStrokeParams = GestureStrokeParams.DEFAULT; + sTimeRecorder = new TimeRecorder(sParams, sGestureStrokeParams); } public static void setParameters(final TypedArray mainKeyboardViewAttr) { sParams = new PointerTrackerParams(mainKeyboardViewAttr); + sGestureStrokeParams = new GestureStrokeParams(mainKeyboardViewAttr); + sTimeRecorder = new TimeRecorder(sParams, sGestureStrokeParams); } private static void updateGestureHandlingMode() { @@ -296,7 +370,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element { throw new NullPointerException(); } mPointerId = id; - mGestureStrokeWithPreviewPoints = new GestureStrokeWithPreviewPoints(id); + mGestureStrokeWithPreviewPoints = new GestureStrokeWithPreviewPoints( + id, sGestureStrokeParams); setKeyDetectorInner(handler.getKeyDetector()); mListener = handler.getKeyboardActionListener(); mDrawingProxy = handler.getDrawingProxy(); @@ -331,7 +406,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { // Note that we need primaryCode argument because the keyboard may in shifted state and the // primaryCode is different from {@link Key#mCode}. private void callListenerOnCodeInput(final Key key, final int primaryCode, final int x, - final int y) { + final int y, final long eventTime) { final boolean ignoreModifierKey = mIgnoreModifierKey && key.isModifier(); final boolean altersCode = key.altCodeWhileTyping() && mTimerProxy.isTypingState(); final int code = altersCode ? key.getAltCode() : primaryCode; @@ -351,7 +426,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } // Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state. if (key.isEnabled() || altersCode) { - sLastBatchInputTime = 0; // reset time + sTimeRecorder.onCodeInput(code, eventTime); if (code == Keyboard.CODE_OUTPUT_TEXT) { mListener.onTextInput(key.getOutputText()); } else if (code != Keyboard.CODE_UNSPECIFIED) { @@ -466,10 +541,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private static boolean needsToSuppressKeyPreviewPopup(final long eventTime) { if (!sShouldHandleGesture) return false; - if (sLastBatchInputTime == 0) return false; - final long elapsedTimeAfterTheLastBatchInput = eventTime - sLastBatchInputTime; - return elapsedTimeAfterTheLastBatchInput - < SUPPRESS_KEY_PREVIEW_AFTER_LAST_BATCH_INPUT_DURATION; + return sTimeRecorder.needsToSuppressKeyPreviewPopup(eventTime); } private void setPressedKeyGraphics(final Key key, final long eventTime) { @@ -587,10 +659,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private void mayUpdateBatchInput(final long eventTime, final Key key) { if (key != null) { synchronized (sAggregratedPointers) { - mGestureStrokeWithPreviewPoints.appendIncrementalBatchPoints(sAggregratedPointers); + final GestureStroke stroke = mGestureStrokeWithPreviewPoints; + stroke.appendIncrementalBatchPoints(sAggregratedPointers); final int size = sAggregratedPointers.getPointerSize(); if (size > sLastRecognitionPointSize - && GestureStroke.hasRecognitionTimePast(eventTime, sLastRecognitionTime)) { + && stroke.hasRecognitionTimePast(eventTime, sLastRecognitionTime)) { sLastRecognitionPointSize = size; sLastRecognitionTime = eventTime; if (DEBUG_LISTENER) { @@ -614,7 +687,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { mPointerId, sAggregratedPointers.getPointerSize())); } sInGesture = false; - sLastBatchInputTime = eventTime; + sTimeRecorder.onEndBatchInput(eventTime); mListener.onEndBatchInput(sAggregratedPointers); } } @@ -692,7 +765,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { sGestureFirstDownTime = eventTime; } mGestureStrokeWithPreviewPoints.onDownEvent(x, y, eventTime, sGestureFirstDownTime, - sLastLetterTypingUpTime); + sTimeRecorder.getLastLetterTypingTime()); } } @@ -933,11 +1006,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { return; } if (currentKey != null && !currentKey.isRepeatable()) { - detectAndSendKey(currentKey, mKeyX, mKeyY); - final int code = currentKey.mCode; - if (Keyboard.isLetterCode(code) && code != Keyboard.CODE_SPACE) { - sLastLetterTypingUpTime = eventTime; - } + detectAndSendKey(currentKey, mKeyX, mKeyY, eventTime); } } @@ -988,7 +1057,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { public void onRegisterKey(final Key key) { if (key != null) { - detectAndSendKey(key, key.mX, key.mY); + detectAndSendKey(key, key.mX, key.mY, SystemClock.uptimeMillis()); mTimerProxy.startTypingStateTimer(key); } } @@ -1014,14 +1083,14 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } } - private void detectAndSendKey(final Key key, final int x, final int y) { + private void detectAndSendKey(final Key key, final int x, final int y, final long eventTime) { if (key == null) { callListenerOnCancelInput(); return; } final int code = key.mCode; - callListenerOnCodeInput(key, code, x, y); + callListenerOnCodeInput(key, code, x, y, eventTime); callListenerOnRelease(key, code, false); } diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java index c0e92df32..9b1a20159 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java @@ -14,10 +14,13 @@ package com.android.inputmethod.keyboard.internal; +import android.content.res.TypedArray; import android.util.Log; import com.android.inputmethod.latin.InputPointers; +import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.ResizableIntArray; +import com.android.inputmethod.latin.ResourceUtils; public class GestureStroke { private static final String TAG = GestureStroke.class.getSimpleName(); @@ -31,6 +34,8 @@ public class GestureStroke { private final ResizableIntArray mXCoordinates = new ResizableIntArray(DEFAULT_CAPACITY); private final ResizableIntArray mYCoordinates = new ResizableIntArray(DEFAULT_CAPACITY); + private final GestureStrokeParams mParams; + private int mKeyWidth; // pixel // Static threshold for starting gesture detection private int mDetectFastMoveSpeedThreshold; // pixel /sec @@ -51,53 +56,100 @@ public class GestureStroke { private int mIncrementalRecognitionSize; private int mLastIncrementalBatchSize; - // TODO: Move some of these to resource. - - // Static threshold for gesture after fast typing - public static final int GESTURE_STATIC_TIME_THRESHOLD_AFTER_FAST_TYPING = 350; // msec - - // Static threshold for starting gesture detection - private static final float DETECT_FAST_MOVE_SPEED_THRESHOLD = 1.5f; // keyWidth / sec + public static final class GestureStrokeParams { + // Static threshold for gesture after fast typing + public final int mStaticTimeThresholdAfterFastTyping; // msec + // Static threshold for starting gesture detection + public final float mDetectFastMoveSpeedThreshold; // keyWidth/sec + // Dynamic threshold for gesture after fast typing + public final int mDynamicThresholdDecayDuration; // msec + // Time based threshold values + public final int mDynamicTimeThresholdFrom; // msec + public final int mDynamicTimeThresholdTo; // msec + // Distance based threshold values + public final float mDynamicDistanceThresholdFrom; // keyWidth + public final float mDynamicDistanceThresholdTo; // keyWidth + // Parameters for gesture sampling + public final float mSamplingMinimumDistance; // keyWidth + // Parameters for gesture recognition + public final int mRecognitionMinimumTime; // msec + public final float mRecognitionSpeedThreshold; // keyWidth/sec - // Dynamic threshold for gesture after fast typing - private static final int GESTURE_DYNAMIC_THRESHOLD_DECAY_DURATION = 450; // msec - // Time based threshold values - private static final int GESTURE_DYNAMIC_TIME_THRESHOLD_FROM = 300; // msec - private static final int GESTURE_DYNAMIC_TIME_THRESHOLD_TO = 20; // msec - // Distance based threshold values - private static final float GESTURE_DYNAMIC_DISTANCE_THRESHOLD_FROM = 6.0f; // keyWidth - private static final float GESTURE_DYNAMIC_DISTANCE_THRESHOLD_TO = 0.35f; // keyWidth + // Default GestureStroke parameters for test. + public static final GestureStrokeParams FOR_TEST = new GestureStrokeParams(); + public static final GestureStrokeParams DEFAULT = FOR_TEST; - // Parameters for gesture sampling - private static final float GESTURE_SAMPLING_MINIMUM_DISTANCE = 1.0f / 6.0f; // keyWidth + private GestureStrokeParams() { + // These parameter values are default and intended for testing. + mStaticTimeThresholdAfterFastTyping = 350; // msec + mDetectFastMoveSpeedThreshold = 1.5f; // keyWidth / sec + mDynamicThresholdDecayDuration = 450; // msec + mDynamicTimeThresholdFrom = 300; // msec + mDynamicTimeThresholdTo = 20; // msec + mDynamicDistanceThresholdFrom = 6.0f; // keyWidth + mDynamicDistanceThresholdTo = 0.35f; // keyWidth + // The following parameters' change will affect the result of regression test. + mSamplingMinimumDistance = 1.0f / 6.0f; // keyWidth + mRecognitionMinimumTime = 100; // msec + mRecognitionSpeedThreshold = 5.5f; // keyWidth / sec + } - // Parameters for gesture recognition - private static final int GESTURE_RECOGNITION_MINIMUM_TIME = 100; // msec - private static final float GESTURE_RECOGNITION_SPEED_THRESHOLD = 5.5f; // keyWidth / sec + public GestureStrokeParams(final TypedArray mainKeyboardViewAttr) { + mStaticTimeThresholdAfterFastTyping = mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_gestureStaticTimeThresholdAfterFastTyping, + DEFAULT.mStaticTimeThresholdAfterFastTyping); + mDetectFastMoveSpeedThreshold = ResourceUtils.getFraction(mainKeyboardViewAttr, + R.styleable.MainKeyboardView_gestureDetectFastMoveSpeedThreshold, + DEFAULT.mDetectFastMoveSpeedThreshold); + mDynamicThresholdDecayDuration = mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_gestureDynamicThresholdDecayDuration, + DEFAULT.mDynamicThresholdDecayDuration); + mDynamicTimeThresholdFrom = mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_gestureDynamicTimeThresholdFrom, + DEFAULT.mDynamicTimeThresholdFrom); + mDynamicTimeThresholdTo = mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_gestureDynamicTimeThresholdTo, + DEFAULT.mDynamicTimeThresholdTo); + mDynamicDistanceThresholdFrom = ResourceUtils.getFraction(mainKeyboardViewAttr, + R.styleable.MainKeyboardView_gestureDynamicDistanceThresholdFrom, + DEFAULT.mDynamicDistanceThresholdFrom); + mDynamicDistanceThresholdTo = ResourceUtils.getFraction(mainKeyboardViewAttr, + R.styleable.MainKeyboardView_gestureDynamicDistanceThresholdTo, + DEFAULT.mDynamicDistanceThresholdTo); + mSamplingMinimumDistance = ResourceUtils.getFraction(mainKeyboardViewAttr, + R.styleable.MainKeyboardView_gestureSamplingMinimumDistance, + DEFAULT.mSamplingMinimumDistance); + mRecognitionMinimumTime = mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_gestureRecognitionMinimumTime, + DEFAULT.mRecognitionMinimumTime); + mRecognitionSpeedThreshold = ResourceUtils.getFraction(mainKeyboardViewAttr, + R.styleable.MainKeyboardView_gestureRecognitionSpeedThreshold, + DEFAULT.mRecognitionSpeedThreshold); + } + } private static final int MSEC_PER_SEC = 1000; - public GestureStroke(final int pointerId) { + public GestureStroke(final int pointerId, final GestureStrokeParams params) { mPointerId = pointerId; + mParams = params; } public void setKeyboardGeometry(final int keyWidth) { mKeyWidth = keyWidth; // TODO: Find an appropriate base metric for these length. Maybe diagonal length of the key? - mDetectFastMoveSpeedThreshold = (int)(keyWidth * DETECT_FAST_MOVE_SPEED_THRESHOLD); + mDetectFastMoveSpeedThreshold = (int)(keyWidth * mParams.mDetectFastMoveSpeedThreshold); mGestureDynamicDistanceThresholdFrom = - (int)(keyWidth * GESTURE_DYNAMIC_DISTANCE_THRESHOLD_FROM); - mGestureDynamicDistanceThresholdTo = - (int)(keyWidth * GESTURE_DYNAMIC_DISTANCE_THRESHOLD_TO); - mGestureSamplingMinimumDistance = (int)(keyWidth * GESTURE_SAMPLING_MINIMUM_DISTANCE); - mGestureRecognitionSpeedThreshold = - (int)(keyWidth * GESTURE_RECOGNITION_SPEED_THRESHOLD); + (int)(keyWidth * mParams.mDynamicDistanceThresholdFrom); + mGestureDynamicDistanceThresholdTo = (int)(keyWidth * mParams.mDynamicDistanceThresholdTo); + mGestureSamplingMinimumDistance = (int)(keyWidth * mParams.mSamplingMinimumDistance); + mGestureRecognitionSpeedThreshold = (int)(keyWidth * mParams.mRecognitionSpeedThreshold); if (DEBUG) { Log.d(TAG, String.format( "[%d] setKeyboardGeometry: keyWidth=%3d tT=%3d >> %3d tD=%3d >> %3d", mPointerId, keyWidth, - GESTURE_DYNAMIC_TIME_THRESHOLD_FROM, - GESTURE_DYNAMIC_TIME_THRESHOLD_TO, + mParams.mDynamicTimeThresholdFrom, + mParams.mDynamicTimeThresholdTo, mGestureDynamicDistanceThresholdFrom, mGestureDynamicDistanceThresholdTo)); } @@ -107,7 +159,7 @@ public class GestureStroke { final long gestureFirstDownTime, final long lastTypingTime) { reset(); final long elapsedTimeAfterTyping = downTime - lastTypingTime; - if (elapsedTimeAfterTyping < GESTURE_STATIC_TIME_THRESHOLD_AFTER_FAST_TYPING) { + if (elapsedTimeAfterTyping < mParams.mStaticTimeThresholdAfterFastTyping) { mAfterFastTyping = true; } if (DEBUG) { @@ -119,23 +171,23 @@ public class GestureStroke { } private int getGestureDynamicDistanceThreshold(final int deltaTime) { - if (!mAfterFastTyping || deltaTime >= GESTURE_DYNAMIC_THRESHOLD_DECAY_DURATION) { + if (!mAfterFastTyping || deltaTime >= mParams.mDynamicThresholdDecayDuration) { return mGestureDynamicDistanceThresholdTo; } final int decayedThreshold = (mGestureDynamicDistanceThresholdFrom - mGestureDynamicDistanceThresholdTo) - * deltaTime / GESTURE_DYNAMIC_THRESHOLD_DECAY_DURATION; + * deltaTime / mParams.mDynamicThresholdDecayDuration; return mGestureDynamicDistanceThresholdFrom - decayedThreshold; } private int getGestureDynamicTimeThreshold(final int deltaTime) { - if (!mAfterFastTyping || deltaTime >= GESTURE_DYNAMIC_THRESHOLD_DECAY_DURATION) { - return GESTURE_DYNAMIC_TIME_THRESHOLD_TO; + if (!mAfterFastTyping || deltaTime >= mParams.mDynamicThresholdDecayDuration) { + return mParams.mDynamicTimeThresholdTo; } final int decayedThreshold = - (GESTURE_DYNAMIC_TIME_THRESHOLD_FROM - GESTURE_DYNAMIC_TIME_THRESHOLD_TO) - * deltaTime / GESTURE_DYNAMIC_THRESHOLD_DECAY_DURATION; - return GESTURE_DYNAMIC_TIME_THRESHOLD_FROM - decayedThreshold; + (mParams.mDynamicTimeThresholdFrom - mParams.mDynamicTimeThresholdTo) + * deltaTime / mParams.mDynamicThresholdDecayDuration; + return mParams.mDynamicTimeThresholdFrom - decayedThreshold; } public boolean isStartOfAGesture() { @@ -249,9 +301,9 @@ public class GestureStroke { } } - public static final boolean hasRecognitionTimePast( + public final boolean hasRecognitionTimePast( final long currentTime, final long lastRecognitionTime) { - return currentTime > lastRecognitionTime + GESTURE_RECOGNITION_MINIMUM_TIME; + return currentTime > lastRecognitionTime + mParams.mRecognitionMinimumTime; } public void appendAllBatchPoints(final InputPointers out) { diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java index 05e0a2ec3..8192c9076 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java @@ -33,8 +33,8 @@ public final class GestureStrokeWithPreviewPoints extends GestureStroke { // TODO: Move this to resource. private static final float MIN_PREVIEW_SAMPLE_LENGTH_RATIO_TO_KEY_WIDTH = 0.1f; - public GestureStrokeWithPreviewPoints(final int pointerId) { - super(pointerId); + public GestureStrokeWithPreviewPoints(final int pointerId, final GestureStrokeParams params) { + super(pointerId, params); } @Override diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java index 0b115945b..46b363c10 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java @@ -200,6 +200,7 @@ public final class BinaryDictionaryFileDumper { outputStream.flush(); outputStream.close(); final File finalFile = new File(finalFileName); + finalFile.delete(); if (!outputFile.renameTo(finalFile)) { throw new IOException("Can't move the file to its final name"); } |