Merge "Remeve the reference of MainKeyboardView from PointerTracker" into jb-mr1-dev
commit
922a85734d
|
@ -110,7 +110,6 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
|
||||||
new WeakHashMap<Key, MoreKeysPanel>();
|
new WeakHashMap<Key, MoreKeysPanel>();
|
||||||
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
|
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
|
||||||
|
|
||||||
private final PointerTrackerParams mPointerTrackerParams;
|
|
||||||
private final SuddenJumpingTouchEventHandler mTouchScreenRegulator;
|
private final SuddenJumpingTouchEventHandler mTouchScreenRegulator;
|
||||||
|
|
||||||
protected KeyDetector mKeyDetector;
|
protected KeyDetector mKeyDetector;
|
||||||
|
@ -127,11 +126,26 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
|
||||||
private static final int MSG_LONGPRESS_KEY = 2;
|
private static final int MSG_LONGPRESS_KEY = 2;
|
||||||
private static final int MSG_DOUBLE_TAP = 3;
|
private static final int MSG_DOUBLE_TAP = 3;
|
||||||
|
|
||||||
private final KeyTimerParams mParams;
|
private final int mKeyRepeatStartTimeout;
|
||||||
|
private final int mKeyRepeatInterval;
|
||||||
|
private final int mLongPressKeyTimeout;
|
||||||
|
private final int mLongPressShiftKeyTimeout;
|
||||||
|
private final int mIgnoreAltCodeKeyTimeout;
|
||||||
|
|
||||||
public KeyTimerHandler(MainKeyboardView outerInstance, KeyTimerParams params) {
|
public KeyTimerHandler(final MainKeyboardView outerInstance,
|
||||||
|
final TypedArray mainKeyboardViewAttr) {
|
||||||
super(outerInstance);
|
super(outerInstance);
|
||||||
mParams = params;
|
|
||||||
|
mKeyRepeatStartTimeout = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_keyRepeatStartTimeout, 0);
|
||||||
|
mKeyRepeatInterval = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_keyRepeatInterval, 0);
|
||||||
|
mLongPressKeyTimeout = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_longPressKeyTimeout, 0);
|
||||||
|
mLongPressShiftKeyTimeout = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_longPressShiftKeyTimeout, 0);
|
||||||
|
mIgnoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,7 +160,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
|
||||||
final Key currentKey = tracker.getKey();
|
final Key currentKey = tracker.getKey();
|
||||||
if (currentKey != null && currentKey.mCode == msg.arg1) {
|
if (currentKey != null && currentKey.mCode == msg.arg1) {
|
||||||
tracker.onRegisterKey(currentKey);
|
tracker.onRegisterKey(currentKey);
|
||||||
startKeyRepeatTimer(tracker, mParams.mKeyRepeatInterval);
|
startKeyRepeatTimer(tracker, mKeyRepeatInterval);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MSG_LONGPRESS_KEY:
|
case MSG_LONGPRESS_KEY:
|
||||||
|
@ -167,7 +181,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startKeyRepeatTimer(PointerTracker tracker) {
|
public void startKeyRepeatTimer(PointerTracker tracker) {
|
||||||
startKeyRepeatTimer(tracker, mParams.mKeyRepeatStartTimeout);
|
startKeyRepeatTimer(tracker, mKeyRepeatStartTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelKeyRepeatTimer() {
|
public void cancelKeyRepeatTimer() {
|
||||||
|
@ -185,7 +199,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
|
||||||
final int delay;
|
final int delay;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case Keyboard.CODE_SHIFT:
|
case Keyboard.CODE_SHIFT:
|
||||||
delay = mParams.mLongPressShiftKeyTimeout;
|
delay = mLongPressShiftKeyTimeout;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
delay = 0;
|
delay = 0;
|
||||||
|
@ -206,15 +220,15 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
|
||||||
final int delay;
|
final int delay;
|
||||||
switch (key.mCode) {
|
switch (key.mCode) {
|
||||||
case Keyboard.CODE_SHIFT:
|
case Keyboard.CODE_SHIFT:
|
||||||
delay = mParams.mLongPressShiftKeyTimeout;
|
delay = mLongPressShiftKeyTimeout;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) {
|
if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) {
|
||||||
// We use longer timeout for sliding finger input started from the symbols
|
// We use longer timeout for sliding finger input started from the symbols
|
||||||
// mode key.
|
// mode key.
|
||||||
delay = mParams.mLongPressKeyTimeout * 3;
|
delay = mLongPressKeyTimeout * 3;
|
||||||
} else {
|
} else {
|
||||||
delay = mParams.mLongPressKeyTimeout;
|
delay = mLongPressKeyTimeout;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +282,7 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessageDelayed(
|
sendMessageDelayed(
|
||||||
obtainMessage(MSG_TYPING_STATE_EXPIRED), mParams.mIgnoreAltCodeKeyTimeout);
|
obtainMessage(MSG_TYPING_STATE_EXPIRED), mIgnoreAltCodeKeyTimeout);
|
||||||
if (isTyping) {
|
if (isTyping) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -307,50 +321,6 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PointerTrackerParams {
|
|
||||||
public final boolean mSlidingKeyInputEnabled;
|
|
||||||
public final int mTouchNoiseThresholdTime;
|
|
||||||
public final float mTouchNoiseThresholdDistance;
|
|
||||||
|
|
||||||
public static final PointerTrackerParams DEFAULT = new PointerTrackerParams();
|
|
||||||
|
|
||||||
private PointerTrackerParams() {
|
|
||||||
mSlidingKeyInputEnabled = false;
|
|
||||||
mTouchNoiseThresholdTime =0;
|
|
||||||
mTouchNoiseThresholdDistance = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PointerTrackerParams(TypedArray mainKeyboardViewAttr) {
|
|
||||||
mSlidingKeyInputEnabled = mainKeyboardViewAttr.getBoolean(
|
|
||||||
R.styleable.MainKeyboardView_slidingKeyInputEnable, false);
|
|
||||||
mTouchNoiseThresholdTime = mainKeyboardViewAttr.getInt(
|
|
||||||
R.styleable.MainKeyboardView_touchNoiseThresholdTime, 0);
|
|
||||||
mTouchNoiseThresholdDistance = mainKeyboardViewAttr.getDimension(
|
|
||||||
R.styleable.MainKeyboardView_touchNoiseThresholdDistance, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class KeyTimerParams {
|
|
||||||
public final int mKeyRepeatStartTimeout;
|
|
||||||
public final int mKeyRepeatInterval;
|
|
||||||
public final int mLongPressKeyTimeout;
|
|
||||||
public final int mLongPressShiftKeyTimeout;
|
|
||||||
public final int mIgnoreAltCodeKeyTimeout;
|
|
||||||
|
|
||||||
public KeyTimerParams(TypedArray mainKeyboardViewAttr) {
|
|
||||||
mKeyRepeatStartTimeout = mainKeyboardViewAttr.getInt(
|
|
||||||
R.styleable.MainKeyboardView_keyRepeatStartTimeout, 0);
|
|
||||||
mKeyRepeatInterval = mainKeyboardViewAttr.getInt(
|
|
||||||
R.styleable.MainKeyboardView_keyRepeatInterval, 0);
|
|
||||||
mLongPressKeyTimeout = mainKeyboardViewAttr.getInt(
|
|
||||||
R.styleable.MainKeyboardView_longPressKeyTimeout, 0);
|
|
||||||
mLongPressShiftKeyTimeout = mainKeyboardViewAttr.getInt(
|
|
||||||
R.styleable.MainKeyboardView_longPressShiftKeyTimeout, 0);
|
|
||||||
mIgnoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
|
|
||||||
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MainKeyboardView(Context context, AttributeSet attrs) {
|
public MainKeyboardView(Context context, AttributeSet attrs) {
|
||||||
this(context, attrs, R.attr.mainKeyboardViewStyle);
|
this(context, attrs, R.attr.mainKeyboardViewStyle);
|
||||||
}
|
}
|
||||||
|
@ -389,19 +359,15 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key
|
||||||
final int altCodeKeyWhileTypingFadeinAnimatorResId = a.getResourceId(
|
final int altCodeKeyWhileTypingFadeinAnimatorResId = a.getResourceId(
|
||||||
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
|
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
|
||||||
|
|
||||||
final KeyTimerParams keyTimerParams = new KeyTimerParams(a);
|
|
||||||
mPointerTrackerParams = new PointerTrackerParams(a);
|
|
||||||
|
|
||||||
final float keyHysteresisDistance = a.getDimension(
|
final float keyHysteresisDistance = a.getDimension(
|
||||||
R.styleable.MainKeyboardView_keyHysteresisDistance, 0);
|
R.styleable.MainKeyboardView_keyHysteresisDistance, 0);
|
||||||
mKeyDetector = new KeyDetector(keyHysteresisDistance);
|
mKeyDetector = new KeyDetector(keyHysteresisDistance);
|
||||||
mKeyTimerHandler = new KeyTimerHandler(this, keyTimerParams);
|
mKeyTimerHandler = new KeyTimerHandler(this, a);
|
||||||
mConfigShowMoreKeysKeyboardAtTouchedPoint = a.getBoolean(
|
mConfigShowMoreKeysKeyboardAtTouchedPoint = a.getBoolean(
|
||||||
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
|
R.styleable.MainKeyboardView_showMoreKeysKeyboardAtTouchedPoint, false);
|
||||||
|
PointerTracker.setParameters(a);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
PointerTracker.setParameters(mPointerTrackerParams);
|
|
||||||
|
|
||||||
mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator(
|
mLanguageOnSpacebarFadeoutAnimator = loadObjectAnimator(
|
||||||
languageOnSpacebarFadeoutAnimatorResId, this);
|
languageOnSpacebarFadeoutAnimatorResId, this);
|
||||||
mAltCodeKeyWhileTypingFadeoutAnimator = loadObjectAnimator(
|
mAltCodeKeyWhileTypingFadeoutAnimator = loadObjectAnimator(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
@ -28,6 +29,7 @@ import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
|
||||||
import com.android.inputmethod.latin.CollectionUtils;
|
import com.android.inputmethod.latin.CollectionUtils;
|
||||||
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.R;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -118,9 +120,36 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class PointerTrackerParams {
|
||||||
|
public final boolean mSlidingKeyInputEnabled;
|
||||||
|
public final int mTouchNoiseThresholdTime;
|
||||||
|
public final float mTouchNoiseThresholdDistance;
|
||||||
|
public final int mTouchNoiseThresholdDistanceSquared;
|
||||||
|
|
||||||
|
public static final PointerTrackerParams DEFAULT = new PointerTrackerParams();
|
||||||
|
|
||||||
|
private PointerTrackerParams() {
|
||||||
|
mSlidingKeyInputEnabled = false;
|
||||||
|
mTouchNoiseThresholdTime = 0;
|
||||||
|
mTouchNoiseThresholdDistance = 0.0f;
|
||||||
|
mTouchNoiseThresholdDistanceSquared = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointerTrackerParams(TypedArray mainKeyboardViewAttr) {
|
||||||
|
mSlidingKeyInputEnabled = mainKeyboardViewAttr.getBoolean(
|
||||||
|
R.styleable.MainKeyboardView_slidingKeyInputEnable, false);
|
||||||
|
mTouchNoiseThresholdTime = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_touchNoiseThresholdTime, 0);
|
||||||
|
final float touchNouseThresholdDistance = mainKeyboardViewAttr.getDimension(
|
||||||
|
R.styleable.MainKeyboardView_touchNoiseThresholdDistance, 0);
|
||||||
|
mTouchNoiseThresholdDistance = touchNouseThresholdDistance;
|
||||||
|
mTouchNoiseThresholdDistanceSquared =
|
||||||
|
(int)(touchNouseThresholdDistance * touchNouseThresholdDistance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parameters for pointer handling.
|
// Parameters for pointer handling.
|
||||||
private static MainKeyboardView.PointerTrackerParams sParams;
|
private static PointerTrackerParams sParams;
|
||||||
private static int sTouchNoiseThresholdDistanceSquared;
|
|
||||||
private static boolean sNeedsPhantomSuddenMoveEventHack;
|
private static boolean sNeedsPhantomSuddenMoveEventHack;
|
||||||
|
|
||||||
private static final ArrayList<PointerTracker> sTrackers = CollectionUtils.newArrayList();
|
private static final ArrayList<PointerTracker> sTrackers = CollectionUtils.newArrayList();
|
||||||
|
@ -192,14 +221,11 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
sPointerTrackerQueue = null;
|
sPointerTrackerQueue = null;
|
||||||
}
|
}
|
||||||
sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack;
|
sNeedsPhantomSuddenMoveEventHack = needsPhantomSuddenMoveEventHack;
|
||||||
|
sParams = PointerTrackerParams.DEFAULT;
|
||||||
setParameters(MainKeyboardView.PointerTrackerParams.DEFAULT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setParameters(final MainKeyboardView.PointerTrackerParams params) {
|
public static void setParameters(final TypedArray mainKeyboardViewAttr) {
|
||||||
sParams = params;
|
sParams = new PointerTrackerParams(mainKeyboardViewAttr);
|
||||||
sTouchNoiseThresholdDistanceSquared = (int)(
|
|
||||||
params.mTouchNoiseThresholdDistance * params.mTouchNoiseThresholdDistance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateGestureHandlingMode() {
|
private static void updateGestureHandlingMode() {
|
||||||
|
@ -635,7 +661,7 @@ public class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
final int dx = x - mLastX;
|
final int dx = x - mLastX;
|
||||||
final int dy = y - mLastY;
|
final int dy = y - mLastY;
|
||||||
final int distanceSquared = (dx * dx + dy * dy);
|
final int distanceSquared = (dx * dx + dy * dy);
|
||||||
if (distanceSquared < sTouchNoiseThresholdDistanceSquared) {
|
if (distanceSquared < sParams.mTouchNoiseThresholdDistanceSquared) {
|
||||||
if (DEBUG_MODE)
|
if (DEBUG_MODE)
|
||||||
Log.w(TAG, "onDownEvent: ignore potential noise: time=" + deltaT
|
Log.w(TAG, "onDownEvent: ignore potential noise: time=" + deltaT
|
||||||
+ " distance=" + distanceSquared);
|
+ " distance=" + distanceSquared);
|
||||||
|
|
Loading…
Reference in New Issue