am dc2ce725: Merge "Make GestureStrokeParams as a top level class"
* commit 'dc2ce725556a1905bf1ff1a11b3dc9feb42bc31a': Make GestureStrokeParams as a top level classmain
commit
085250d391
|
@ -25,7 +25,7 @@ import android.view.MotionEvent;
|
|||
import com.android.inputmethod.keyboard.internal.BogusMoveEventDetector;
|
||||
import com.android.inputmethod.keyboard.internal.GestureEnabler;
|
||||
import com.android.inputmethod.keyboard.internal.GestureStroke;
|
||||
import com.android.inputmethod.keyboard.internal.GestureStroke.GestureStrokeParams;
|
||||
import com.android.inputmethod.keyboard.internal.GestureStrokeParams;
|
||||
import com.android.inputmethod.keyboard.internal.GestureStrokeWithPreviewPoints;
|
||||
import com.android.inputmethod.keyboard.internal.GestureStrokeWithPreviewPoints.GestureStrokePreviewParams;
|
||||
import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
||||
|
|
|
@ -16,13 +16,10 @@
|
|||
|
||||
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.utils.ResizableIntArray;
|
||||
import com.android.inputmethod.latin.utils.ResourceUtils;
|
||||
|
||||
public class GestureStroke {
|
||||
private static final String TAG = GestureStroke.class.getSimpleName();
|
||||
|
@ -64,77 +61,6 @@ public class GestureStroke {
|
|||
private int mIncrementalRecognitionSize;
|
||||
private int mLastIncrementalBatchSize;
|
||||
|
||||
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
|
||||
|
||||
// Default GestureStroke parameters.
|
||||
public static final GestureStrokeParams DEFAULT = new GestureStrokeParams();
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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, final GestureStrokeParams params) {
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.keyboard.internal;
|
||||
|
||||
import android.content.res.TypedArray;
|
||||
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.utils.ResourceUtils;
|
||||
|
||||
public 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
|
||||
|
||||
// Default GestureStroke parameters.
|
||||
public static final GestureStrokeParams DEFAULT = new GestureStrokeParams();
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue