Remove unnecessary default KeyDetector from PointerTracker

Change-Id: Ib0fbb40a7040202d2a4b4ab49319d9e247a2a6ce
main
Tadashi G. Takaoka 2013-12-20 11:56:09 +09:00
parent dbb88e47c8
commit 921a32f0a9
3 changed files with 10 additions and 16 deletions

View File

@ -230,8 +230,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mKeyDetector = new KeyDetector( mKeyDetector = new KeyDetector(
keyHysteresisDistance, keyHysteresisDistanceForSlidingModifier); keyHysteresisDistance, keyHysteresisDistanceForSlidingModifier);
PointerTracker.init(mainKeyboardViewAttr, mKeyTimerHandler, this /* DrawingProxy */, PointerTracker.init(mainKeyboardViewAttr, mKeyTimerHandler, this /* DrawingProxy */);
mKeyDetector);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
final boolean forceNonDistinctMultitouch = prefs.getBoolean( final boolean forceNonDistinctMultitouch = prefs.getBoolean(
@ -240,7 +239,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT) .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT)
&& !forceNonDistinctMultitouch; && !forceNonDistinctMultitouch;
mNonDistinctMultitouchHelper = hasDistinctMultitouch ? null mNonDistinctMultitouchHelper = hasDistinctMultitouch ? null
: new NonDistinctMultitouchHelper(PointerTracker.getPointerTracker(0)); : new NonDistinctMultitouchHelper();
final int backgroundDimAlpha = mainKeyboardViewAttr.getInt( final int backgroundDimAlpha = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_backgroundDimAlpha, 0); R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
@ -431,7 +430,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
mKeyDetector.setKeyboard( mKeyDetector.setKeyboard(
keyboard, -getPaddingLeft(), -getPaddingTop() + getVerticalCorrection()); keyboard, -getPaddingLeft(), -getPaddingTop() + getVerticalCorrection());
PointerTracker.setKeyDetector(mKeyDetector); PointerTracker.setKeyDetector(mKeyDetector);
PointerTracker.setKeyboardActionListener(mKeyboardActionListener);
mMoreKeysKeyboardCache.clear(); mMoreKeysKeyboardCache.clear();
mSpaceKey = keyboard.getKey(Constants.CODE_SPACE); mSpaceKey = keyboard.getKey(Constants.CODE_SPACE);

View File

@ -155,10 +155,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
private static DrawingProxy sDrawingProxy; private static DrawingProxy sDrawingProxy;
private static TimerProxy sTimerProxy; private static TimerProxy sTimerProxy;
private static KeyDetector sDefaultKeyDetector;
private KeyDetector mKeyDetector;
private static KeyboardActionListener sListener = KeyboardActionListener.EMPTY_LISTENER; private static KeyboardActionListener sListener = KeyboardActionListener.EMPTY_LISTENER;
// The {@link KeyDetector} is set whenever the down event is processed. Also this is updated
// when new {@link Keyboard} is set by {@link #setKeyDetector(KeyDetector)}.
private KeyDetector mKeyDetector;
private Keyboard mKeyboard; private Keyboard mKeyboard;
private int mPhantomSuddenMoveThreshold; private int mPhantomSuddenMoveThreshold;
private final BogusMoveEventDetector mBogusMoveEventDetector = new BogusMoveEventDetector(); private final BogusMoveEventDetector mBogusMoveEventDetector = new BogusMoveEventDetector();
@ -344,7 +345,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
// TODO: Add PointerTrackerFactory singleton and move some class static methods into it. // TODO: Add PointerTrackerFactory singleton and move some class static methods into it.
public static void init(final TypedArray mainKeyboardViewAttr, final TimerProxy timerProxy, public static void init(final TypedArray mainKeyboardViewAttr, final TimerProxy timerProxy,
final DrawingProxy drawingProxy, final KeyDetector defaultKeyDetector) { final DrawingProxy drawingProxy) {
sParams = new PointerTrackerParams(mainKeyboardViewAttr); sParams = new PointerTrackerParams(mainKeyboardViewAttr);
sGestureStrokeParams = new GestureStrokeParams(mainKeyboardViewAttr); sGestureStrokeParams = new GestureStrokeParams(mainKeyboardViewAttr);
sGesturePreviewParams = new GestureStrokePreviewParams(mainKeyboardViewAttr); sGesturePreviewParams = new GestureStrokePreviewParams(mainKeyboardViewAttr);
@ -358,7 +359,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
sTimerProxy = timerProxy; sTimerProxy = timerProxy;
sDrawingProxy = drawingProxy; sDrawingProxy = drawingProxy;
sDefaultKeyDetector = defaultKeyDetector;
} }
private static void updateGestureHandlingMode() { private static void updateGestureHandlingMode() {
@ -434,7 +434,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
mPointerId = id; mPointerId = id;
mGestureStrokeWithPreviewPoints = new GestureStrokeWithPreviewPoints( mGestureStrokeWithPreviewPoints = new GestureStrokeWithPreviewPoints(
id, sGestureStrokeParams, sGesturePreviewParams); id, sGestureStrokeParams, sGesturePreviewParams);
setKeyDetectorInner(sDefaultKeyDetector);
} }
// Returns true if keyboard has been changed by this callback. // Returns true if keyboard has been changed by this callback.

View File

@ -27,16 +27,11 @@ import com.android.inputmethod.latin.utils.CoordinateUtils;
public final class NonDistinctMultitouchHelper { public final class NonDistinctMultitouchHelper {
private static final String TAG = NonDistinctMultitouchHelper.class.getSimpleName(); private static final String TAG = NonDistinctMultitouchHelper.class.getSimpleName();
// Use only main (id=0) pointer tracker. private static final int MAIN_POINTER_TRACKER_ID = 0;
private final PointerTracker mMainTracker;
private int mOldPointerCount = 1; private int mOldPointerCount = 1;
private Key mOldKey; private Key mOldKey;
private int[] mLastCoords = CoordinateUtils.newInstance(); private int[] mLastCoords = CoordinateUtils.newInstance();
public NonDistinctMultitouchHelper(final PointerTracker mainTracker) {
mMainTracker = mainTracker;
}
public void processMotionEvent(final MotionEvent me, final KeyDetector keyDetector) { public void processMotionEvent(final MotionEvent me, final KeyDetector keyDetector) {
final int pointerCount = me.getPointerCount(); final int pointerCount = me.getPointerCount();
final int oldPointerCount = mOldPointerCount; final int oldPointerCount = mOldPointerCount;
@ -47,7 +42,9 @@ public final class NonDistinctMultitouchHelper {
return; return;
} }
final PointerTracker mainTracker = mMainTracker; // Use only main pointer tracker.
final PointerTracker mainTracker = PointerTracker.getPointerTracker(
MAIN_POINTER_TRACKER_ID);
final int action = me.getActionMasked(); final int action = me.getActionMasked();
final int index = me.getActionIndex(); final int index = me.getActionIndex();
final long eventTime = me.getEventTime(); final long eventTime = me.getEventTime();