am 770b0087: Remove KeyEventHandler
* commit '770b00874b7b26bb6057e4d12ed7c4042f467294': Remove KeyEventHandlermain
commit
8b49f4921c
|
@ -24,7 +24,6 @@ import android.animation.ObjectAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
@ -49,8 +48,6 @@ import android.widget.TextView;
|
||||||
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
||||||
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
|
import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
|
||||||
import com.android.inputmethod.annotations.ExternallyReferenced;
|
import com.android.inputmethod.annotations.ExternallyReferenced;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
|
|
||||||
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
|
||||||
import com.android.inputmethod.keyboard.internal.DrawingHandler;
|
import com.android.inputmethod.keyboard.internal.DrawingHandler;
|
||||||
import com.android.inputmethod.keyboard.internal.GestureFloatingPreviewText;
|
import com.android.inputmethod.keyboard.internal.GestureFloatingPreviewText;
|
||||||
import com.android.inputmethod.keyboard.internal.GestureTrailsPreview;
|
import com.android.inputmethod.keyboard.internal.GestureTrailsPreview;
|
||||||
|
@ -120,9 +117,8 @@ import java.util.WeakHashMap;
|
||||||
* @attr ref R.styleable#MainKeyboardView_gestureRecognitionSpeedThreshold
|
* @attr ref R.styleable#MainKeyboardView_gestureRecognitionSpeedThreshold
|
||||||
* @attr ref R.styleable#MainKeyboardView_suppressKeyPreviewAfterBatchInputDuration
|
* @attr ref R.styleable#MainKeyboardView_suppressKeyPreviewAfterBatchInputDuration
|
||||||
*/
|
*/
|
||||||
public final class MainKeyboardView extends KeyboardView implements PointerTracker.KeyEventHandler,
|
public final class MainKeyboardView extends KeyboardView implements PointerTracker.DrawingProxy,
|
||||||
PointerTracker.DrawingProxy, MoreKeysPanel.Controller, DrawingHandler.Callbacks,
|
MoreKeysPanel.Controller, DrawingHandler.Callbacks, TimerHandler.Callbacks {
|
||||||
TimerHandler.Callbacks {
|
|
||||||
private static final String TAG = MainKeyboardView.class.getSimpleName();
|
private static final String TAG = MainKeyboardView.class.getSimpleName();
|
||||||
|
|
||||||
/** Listener for {@link KeyboardActionListener}. */
|
/** Listener for {@link KeyboardActionListener}. */
|
||||||
|
@ -214,8 +210,27 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
public MainKeyboardView(final Context context, final AttributeSet attrs, final int defStyle) {
|
public MainKeyboardView(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
|
|
||||||
final Resources res = getResources();
|
mPreviewPlacerView = new PreviewPlacerView(context, attrs);
|
||||||
PointerTracker.init(res);
|
|
||||||
|
final TypedArray mainKeyboardViewAttr = context.obtainStyledAttributes(
|
||||||
|
attrs, R.styleable.MainKeyboardView, defStyle, R.style.MainKeyboardView);
|
||||||
|
final int ignoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
|
||||||
|
final int gestureRecognitionUpdateTime = mainKeyboardViewAttr.getInt(
|
||||||
|
R.styleable.MainKeyboardView_gestureRecognitionUpdateTime, 0);
|
||||||
|
mKeyTimerHandler = new TimerHandler(
|
||||||
|
this, ignoreAltCodeKeyTimeout, gestureRecognitionUpdateTime);
|
||||||
|
|
||||||
|
final float keyHysteresisDistance = mainKeyboardViewAttr.getDimension(
|
||||||
|
R.styleable.MainKeyboardView_keyHysteresisDistance, 0.0f);
|
||||||
|
final float keyHysteresisDistanceForSlidingModifier = mainKeyboardViewAttr.getDimension(
|
||||||
|
R.styleable.MainKeyboardView_keyHysteresisDistanceForSlidingModifier, 0.0f);
|
||||||
|
mKeyDetector = new KeyDetector(
|
||||||
|
keyHysteresisDistance, keyHysteresisDistanceForSlidingModifier);
|
||||||
|
|
||||||
|
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(
|
||||||
DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH, false);
|
DebugSettings.PREF_FORCE_NON_DISTINCT_MULTITOUCH, false);
|
||||||
|
@ -223,12 +238,8 @@ 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();
|
: new NonDistinctMultitouchHelper(PointerTracker.getPointerTracker(0));
|
||||||
|
|
||||||
mPreviewPlacerView = new PreviewPlacerView(context, attrs);
|
|
||||||
|
|
||||||
final TypedArray mainKeyboardViewAttr = context.obtainStyledAttributes(
|
|
||||||
attrs, R.styleable.MainKeyboardView, defStyle, R.style.MainKeyboardView);
|
|
||||||
final int backgroundDimAlpha = mainKeyboardViewAttr.getInt(
|
final int backgroundDimAlpha = mainKeyboardViewAttr.getInt(
|
||||||
R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
|
R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
|
||||||
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
|
mBackgroundDimAlphaPaint.setColor(Color.BLACK);
|
||||||
|
@ -253,18 +264,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
final int altCodeKeyWhileTypingFadeinAnimatorResId = mainKeyboardViewAttr.getResourceId(
|
final int altCodeKeyWhileTypingFadeinAnimatorResId = mainKeyboardViewAttr.getResourceId(
|
||||||
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
|
R.styleable.MainKeyboardView_altCodeKeyWhileTypingFadeinAnimator, 0);
|
||||||
|
|
||||||
final float keyHysteresisDistance = mainKeyboardViewAttr.getDimension(
|
|
||||||
R.styleable.MainKeyboardView_keyHysteresisDistance, 0.0f);
|
|
||||||
final float keyHysteresisDistanceForSlidingModifier = mainKeyboardViewAttr.getDimension(
|
|
||||||
R.styleable.MainKeyboardView_keyHysteresisDistanceForSlidingModifier, 0.0f);
|
|
||||||
mKeyDetector = new KeyDetector(
|
|
||||||
keyHysteresisDistance, keyHysteresisDistanceForSlidingModifier);
|
|
||||||
final int ignoreAltCodeKeyTimeout = mainKeyboardViewAttr.getInt(
|
|
||||||
R.styleable.MainKeyboardView_ignoreAltCodeKeyTimeout, 0);
|
|
||||||
final int gestureRecognitionUpdateTime = mainKeyboardViewAttr.getInt(
|
|
||||||
R.styleable.MainKeyboardView_gestureRecognitionUpdateTime, 0);
|
|
||||||
mKeyTimerHandler = new TimerHandler(
|
|
||||||
this, ignoreAltCodeKeyTimeout, gestureRecognitionUpdateTime);
|
|
||||||
mKeyPreviewOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
|
mKeyPreviewOffset = mainKeyboardViewAttr.getDimensionPixelOffset(
|
||||||
R.styleable.MainKeyboardView_keyPreviewOffset, 0);
|
R.styleable.MainKeyboardView_keyPreviewOffset, 0);
|
||||||
mKeyPreviewHeight = mainKeyboardViewAttr.getDimensionPixelSize(
|
mKeyPreviewHeight = mainKeyboardViewAttr.getDimensionPixelSize(
|
||||||
|
@ -287,7 +286,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
mGestureFloatingPreviewTextLingerTimeout = mainKeyboardViewAttr.getInt(
|
mGestureFloatingPreviewTextLingerTimeout = mainKeyboardViewAttr.getInt(
|
||||||
R.styleable.MainKeyboardView_gestureFloatingPreviewTextLingerTimeout, 0);
|
R.styleable.MainKeyboardView_gestureFloatingPreviewTextLingerTimeout, 0);
|
||||||
PointerTracker.setParameters(mainKeyboardViewAttr);
|
|
||||||
|
|
||||||
mGestureFloatingPreviewText = new GestureFloatingPreviewText(
|
mGestureFloatingPreviewText = new GestureFloatingPreviewText(
|
||||||
mPreviewPlacerView, mainKeyboardViewAttr);
|
mPreviewPlacerView, mainKeyboardViewAttr);
|
||||||
|
@ -313,7 +311,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER;
|
mKeyboardActionListener = KeyboardActionListener.EMPTY_LISTENER;
|
||||||
|
|
||||||
mLanguageOnSpacebarHorizontalMargin = (int)res.getDimension(
|
mLanguageOnSpacebarHorizontalMargin = (int)getResources().getDimension(
|
||||||
R.dimen.config_language_on_spacebar_horizontal_margin);
|
R.dimen.config_language_on_spacebar_horizontal_margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,28 +400,16 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
PointerTracker.setKeyboardActionListener(listener);
|
PointerTracker.setKeyboardActionListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// TODO: We should reconsider which coordinate system should be used to represent keyboard
|
||||||
* Returns the {@link KeyboardActionListener} object.
|
// event.
|
||||||
* @return the listener attached to this keyboard
|
public int getKeyX(final int x) {
|
||||||
*/
|
return Constants.isValidCoordinate(x) ? mKeyDetector.getTouchX(x) : x;
|
||||||
@Override
|
|
||||||
public KeyboardActionListener getKeyboardActionListener() {
|
|
||||||
return mKeyboardActionListener;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// TODO: We should reconsider which coordinate system should be used to represent keyboard
|
||||||
public KeyDetector getKeyDetector() {
|
// event.
|
||||||
return mKeyDetector;
|
public int getKeyY(final int y) {
|
||||||
}
|
return Constants.isValidCoordinate(y) ? mKeyDetector.getTouchY(y) : y;
|
||||||
|
|
||||||
@Override
|
|
||||||
public DrawingProxy getDrawingProxy() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TimerProxy getTimerProxy() {
|
|
||||||
return mKeyTimerHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -441,6 +427,7 @@ 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);
|
||||||
|
@ -999,7 +986,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
mKeyTimerHandler.cancelKeyRepeatTimer();
|
mKeyTimerHandler.cancelKeyRepeatTimer();
|
||||||
}
|
}
|
||||||
// Non distinct multitouch screen support
|
// Non distinct multitouch screen support
|
||||||
mNonDistinctMultitouchHelper.processMotionEvent(me, this);
|
mNonDistinctMultitouchHelper.processMotionEvent(me, mKeyDetector);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return processMotionEvent(me);
|
return processMotionEvent(me);
|
||||||
|
@ -1016,8 +1003,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
|
|
||||||
final int index = me.getActionIndex();
|
final int index = me.getActionIndex();
|
||||||
final int id = me.getPointerId(index);
|
final int id = me.getPointerId(index);
|
||||||
final PointerTracker tracker = PointerTracker.getPointerTracker(id, this);
|
final PointerTracker tracker = PointerTracker.getPointerTracker(id);
|
||||||
tracker.processMotionEvent(me, this);
|
tracker.processMotionEvent(me, mKeyDetector);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,7 +1033,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchHoverEvent(final MotionEvent event) {
|
public boolean dispatchHoverEvent(final MotionEvent event) {
|
||||||
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
|
||||||
final PointerTracker tracker = PointerTracker.getPointerTracker(0, this);
|
final PointerTracker tracker = PointerTracker.getPointerTracker(0);
|
||||||
return AccessibleKeyboardViewProxy.getInstance().dispatchHoverEvent(event, tracker);
|
return AccessibleKeyboardViewProxy.getInstance().dispatchHoverEvent(event, tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,33 +55,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
private static boolean sGestureHandlingEnabledByInputField = false;
|
private static boolean sGestureHandlingEnabledByInputField = false;
|
||||||
private static boolean sGestureHandlingEnabledByUser = false;
|
private static boolean sGestureHandlingEnabledByUser = false;
|
||||||
|
|
||||||
public interface KeyEventHandler {
|
|
||||||
/**
|
|
||||||
* Get KeyDetector object that is used for this PointerTracker.
|
|
||||||
* @return the KeyDetector object that is used for this PointerTracker
|
|
||||||
*/
|
|
||||||
public KeyDetector getKeyDetector();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get KeyboardActionListener object that is used to register key code and so on.
|
|
||||||
* @return the KeyboardActionListner for this PointerTracke
|
|
||||||
*/
|
|
||||||
public KeyboardActionListener getKeyboardActionListener();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get DrawingProxy object that is used for this PointerTracker.
|
|
||||||
* @return the DrawingProxy object that is used for this PointerTracker
|
|
||||||
*/
|
|
||||||
public DrawingProxy getDrawingProxy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get TimerProxy object that handles key repeat and long press timer event for this
|
|
||||||
* PointerTracker.
|
|
||||||
* @return the TimerProxy object that handles key repeat and long press timer event.
|
|
||||||
*/
|
|
||||||
public TimerProxy getTimerProxy();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface DrawingProxy {
|
public interface DrawingProxy {
|
||||||
public void invalidateKey(Key key);
|
public void invalidateKey(Key key);
|
||||||
public void showKeyPreview(Key key);
|
public void showKeyPreview(Key key);
|
||||||
|
@ -142,18 +115,6 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
public final int mKeyRepeatInterval;
|
public final int mKeyRepeatInterval;
|
||||||
public final int mLongPressShiftLockTimeout;
|
public final int mLongPressShiftLockTimeout;
|
||||||
|
|
||||||
public static final PointerTrackerParams DEFAULT = new PointerTrackerParams();
|
|
||||||
|
|
||||||
private PointerTrackerParams() {
|
|
||||||
mKeySelectionByDraggingFinger = false;
|
|
||||||
mTouchNoiseThresholdTime = 0;
|
|
||||||
mTouchNoiseThresholdDistance = 0;
|
|
||||||
mSuppressKeyPreviewAfterBatchInputDuration = 0;
|
|
||||||
mKeyRepeatStartTimeout = 0;
|
|
||||||
mKeyRepeatInterval = 0;
|
|
||||||
mLongPressShiftLockTimeout = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PointerTrackerParams(final TypedArray mainKeyboardViewAttr) {
|
public PointerTrackerParams(final TypedArray mainKeyboardViewAttr) {
|
||||||
mKeySelectionByDraggingFinger = mainKeyboardViewAttr.getBoolean(
|
mKeySelectionByDraggingFinger = mainKeyboardViewAttr.getBoolean(
|
||||||
R.styleable.MainKeyboardView_keySelectionByDraggingFinger, false);
|
R.styleable.MainKeyboardView_keySelectionByDraggingFinger, false);
|
||||||
|
@ -189,10 +150,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
|
|
||||||
public final int mPointerId;
|
public final int mPointerId;
|
||||||
|
|
||||||
private DrawingProxy mDrawingProxy;
|
private static DrawingProxy sDrawingProxy;
|
||||||
private TimerProxy mTimerProxy;
|
private static TimerProxy sTimerProxy;
|
||||||
|
private static KeyDetector sDefaultKeyDetector;
|
||||||
private KeyDetector mKeyDetector;
|
private KeyDetector mKeyDetector;
|
||||||
private KeyboardActionListener mListener = KeyboardActionListener.EMPTY_LISTENER;
|
private static KeyboardActionListener sListener = KeyboardActionListener.EMPTY_LISTENER;
|
||||||
|
|
||||||
private Keyboard mKeyboard;
|
private Keyboard mKeyboard;
|
||||||
private int mPhantomSuddenMoveThreshold;
|
private int mPhantomSuddenMoveThreshold;
|
||||||
|
@ -377,22 +339,26 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
return needsTheHack;
|
return needsTheHack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(final Resources res) {
|
// TODO: Add PointerTrackerFactory singleton and move some class static methods into it.
|
||||||
sNeedsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
|
public static void init(final TypedArray mainKeyboardViewAttr, final TimerProxy timerProxy,
|
||||||
ResourceUtils.getDeviceOverrideValue(
|
final DrawingProxy drawingProxy, final KeyDetector defaultKeyDetector) {
|
||||||
res, R.array.phantom_sudden_move_event_device_list));
|
|
||||||
sNeedsProximateBogusDownMoveUpEventHack = needsProximateBogusDownMoveUpEventHack(res);
|
|
||||||
sParams = PointerTrackerParams.DEFAULT;
|
|
||||||
sGestureStrokeParams = GestureStrokeParams.DEFAULT;
|
|
||||||
sGesturePreviewParams = GestureStrokePreviewParams.DEFAULT;
|
|
||||||
sTimeRecorder = new TimeRecorder(sParams, sGestureStrokeParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setParameters(final TypedArray mainKeyboardViewAttr) {
|
|
||||||
sParams = new PointerTrackerParams(mainKeyboardViewAttr);
|
sParams = new PointerTrackerParams(mainKeyboardViewAttr);
|
||||||
sGestureStrokeParams = new GestureStrokeParams(mainKeyboardViewAttr);
|
sGestureStrokeParams = new GestureStrokeParams(mainKeyboardViewAttr);
|
||||||
sGesturePreviewParams = new GestureStrokePreviewParams(mainKeyboardViewAttr);
|
sGesturePreviewParams = new GestureStrokePreviewParams(mainKeyboardViewAttr);
|
||||||
sTimeRecorder = new TimeRecorder(sParams, sGestureStrokeParams);
|
sTimeRecorder = new TimeRecorder(sParams, sGestureStrokeParams);
|
||||||
|
|
||||||
|
final Resources res = mainKeyboardViewAttr.getResources();
|
||||||
|
sNeedsPhantomSuddenMoveEventHack = Boolean.parseBoolean(
|
||||||
|
ResourceUtils.getDeviceOverrideValue(
|
||||||
|
res, R.array.phantom_sudden_move_event_device_list));
|
||||||
|
sNeedsProximateBogusDownMoveUpEventHack = needsProximateBogusDownMoveUpEventHack(res);
|
||||||
|
sGestureStrokeParams = GestureStrokeParams.DEFAULT;
|
||||||
|
sGesturePreviewParams = GestureStrokePreviewParams.DEFAULT;
|
||||||
|
sTimeRecorder = new TimeRecorder(sParams, sGestureStrokeParams);
|
||||||
|
|
||||||
|
sTimerProxy = timerProxy;
|
||||||
|
sDrawingProxy = drawingProxy;
|
||||||
|
sDefaultKeyDetector = defaultKeyDetector;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateGestureHandlingMode() {
|
private static void updateGestureHandlingMode() {
|
||||||
|
@ -413,12 +379,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
updateGestureHandlingMode();
|
updateGestureHandlingMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PointerTracker getPointerTracker(final int id, final KeyEventHandler handler) {
|
public static PointerTracker getPointerTracker(final int id) {
|
||||||
final ArrayList<PointerTracker> trackers = sTrackers;
|
final ArrayList<PointerTracker> trackers = sTrackers;
|
||||||
|
|
||||||
// Create pointer trackers until we can get 'id+1'-th tracker, if needed.
|
// Create pointer trackers until we can get 'id+1'-th tracker, if needed.
|
||||||
for (int i = trackers.size(); i <= id; i++) {
|
for (int i = trackers.size(); i <= id; i++) {
|
||||||
final PointerTracker tracker = new PointerTracker(i, handler);
|
final PointerTracker tracker = new PointerTracker(i);
|
||||||
trackers.add(tracker);
|
trackers.add(tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,11 +400,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setKeyboardActionListener(final KeyboardActionListener listener) {
|
public static void setKeyboardActionListener(final KeyboardActionListener listener) {
|
||||||
final int trackersSize = sTrackers.size();
|
sListener = listener;
|
||||||
for (int i = 0; i < trackersSize; ++i) {
|
|
||||||
final PointerTracker tracker = sTrackers.get(i);
|
|
||||||
tracker.mListener = listener;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setKeyDetector(final KeyDetector keyDetector) {
|
public static void setKeyDetector(final KeyDetector keyDetector) {
|
||||||
|
@ -468,21 +430,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PointerTracker(final int id, final KeyEventHandler handler) {
|
private PointerTracker(final int id) {
|
||||||
if (handler == null) {
|
|
||||||
throw new NullPointerException();
|
|
||||||
}
|
|
||||||
mPointerId = id;
|
mPointerId = id;
|
||||||
mGestureStrokeWithPreviewPoints = new GestureStrokeWithPreviewPoints(
|
mGestureStrokeWithPreviewPoints = new GestureStrokeWithPreviewPoints(
|
||||||
id, sGestureStrokeParams, sGesturePreviewParams);
|
id, sGestureStrokeParams, sGesturePreviewParams);
|
||||||
setKeyEventHandler(handler);
|
setKeyDetectorInner(sDefaultKeyDetector);
|
||||||
}
|
|
||||||
|
|
||||||
private void setKeyEventHandler(final KeyEventHandler handler) {
|
|
||||||
setKeyDetectorInner(handler.getKeyDetector());
|
|
||||||
mListener = handler.getKeyboardActionListener();
|
|
||||||
mDrawingProxy = handler.getDrawingProxy();
|
|
||||||
mTimerProxy = handler.getTimerProxy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if keyboard has been changed by this callback.
|
// Returns true if keyboard has been changed by this callback.
|
||||||
|
@ -507,10 +459,10 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (key.isEnabled()) {
|
if (key.isEnabled()) {
|
||||||
mListener.onPressKey(key.getCode(), repeatCount, getActivePointerTrackerCount() == 1);
|
sListener.onPressKey(key.getCode(), repeatCount, getActivePointerTrackerCount() == 1);
|
||||||
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
|
final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged;
|
||||||
mKeyboardLayoutHasBeenChanged = false;
|
mKeyboardLayoutHasBeenChanged = false;
|
||||||
mTimerProxy.startTypingStateTimer(key);
|
sTimerProxy.startTypingStateTimer(key);
|
||||||
return keyboardLayoutHasBeenChanged;
|
return keyboardLayoutHasBeenChanged;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -521,7 +473,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
private void callListenerOnCodeInput(final Key key, final int primaryCode, final int x,
|
private void callListenerOnCodeInput(final Key key, final int primaryCode, final int x,
|
||||||
final int y, final long eventTime) {
|
final int y, final long eventTime) {
|
||||||
final boolean ignoreModifierKey = mIsInDraggingFinger && key.isModifier();
|
final boolean ignoreModifierKey = mIsInDraggingFinger && key.isModifier();
|
||||||
final boolean altersCode = key.altCodeWhileTyping() && mTimerProxy.isTypingState();
|
final boolean altersCode = key.altCodeWhileTyping() && sTimerProxy.isTypingState();
|
||||||
final int code = altersCode ? key.getAltCode() : primaryCode;
|
final int code = altersCode ? key.getAltCode() : primaryCode;
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
final String output = code == Constants.CODE_OUTPUT_TEXT
|
final String output = code == Constants.CODE_OUTPUT_TEXT
|
||||||
|
@ -541,9 +493,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
if (key.isEnabled() || altersCode) {
|
if (key.isEnabled() || altersCode) {
|
||||||
sTimeRecorder.onCodeInput(code, eventTime);
|
sTimeRecorder.onCodeInput(code, eventTime);
|
||||||
if (code == Constants.CODE_OUTPUT_TEXT) {
|
if (code == Constants.CODE_OUTPUT_TEXT) {
|
||||||
mListener.onTextInput(key.getOutputText());
|
sListener.onTextInput(key.getOutputText());
|
||||||
} else if (code != Constants.CODE_UNSPECIFIED) {
|
} else if (code != Constants.CODE_UNSPECIFIED) {
|
||||||
mListener.onCodeInput(code, x, y);
|
sListener.onCodeInput(code, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -571,7 +523,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (key.isEnabled()) {
|
if (key.isEnabled()) {
|
||||||
mListener.onReleaseKey(primaryCode, withSliding);
|
sListener.onReleaseKey(primaryCode, withSliding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +531,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, String.format("[%d] onFinishSlidingInput", mPointerId));
|
Log.d(TAG, String.format("[%d] onFinishSlidingInput", mPointerId));
|
||||||
}
|
}
|
||||||
mListener.onFinishSlidingInput();
|
sListener.onFinishSlidingInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callListenerOnCancelInput() {
|
private void callListenerOnCancelInput() {
|
||||||
|
@ -589,7 +541,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
|
||||||
ResearchLogger.pointerTracker_callListenerOnCancelInput();
|
ResearchLogger.pointerTracker_callListenerOnCancelInput();
|
||||||
}
|
}
|
||||||
mListener.onCancelInput();
|
sListener.onCancelInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setKeyDetectorInner(final KeyDetector keyDetector) {
|
private void setKeyDetectorInner(final KeyDetector keyDetector) {
|
||||||
|
@ -606,7 +558,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
mGestureStrokeWithPreviewPoints.setKeyboardGeometry(keyWidth, mKeyboard.mOccupiedHeight);
|
mGestureStrokeWithPreviewPoints.setKeyboardGeometry(keyWidth, mKeyboard.mOccupiedHeight);
|
||||||
final Key newKey = mKeyDetector.detectHitKey(mKeyX, mKeyY);
|
final Key newKey = mKeyDetector.detectHitKey(mKeyX, mKeyY);
|
||||||
if (newKey != mCurrentKey) {
|
if (newKey != mCurrentKey) {
|
||||||
if (mDrawingProxy != null) {
|
if (sDrawingProxy != null) {
|
||||||
setReleasedKeyGraphics(mCurrentKey);
|
setReleasedKeyGraphics(mCurrentKey);
|
||||||
}
|
}
|
||||||
// Keep {@link #mCurrentKey} that comes from previous keyboard.
|
// Keep {@link #mCurrentKey} that comes from previous keyboard.
|
||||||
|
@ -634,7 +586,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setReleasedKeyGraphics(final Key key) {
|
private void setReleasedKeyGraphics(final Key key) {
|
||||||
mDrawingProxy.dismissKeyPreview(key);
|
sDrawingProxy.dismissKeyPreview(key);
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -675,14 +627,14 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state.
|
// Even if the key is disabled, it should respond if it is in the altCodeWhileTyping state.
|
||||||
final boolean altersCode = key.altCodeWhileTyping() && mTimerProxy.isTypingState();
|
final boolean altersCode = key.altCodeWhileTyping() && sTimerProxy.isTypingState();
|
||||||
final boolean needsToUpdateGraphics = key.isEnabled() || altersCode;
|
final boolean needsToUpdateGraphics = key.isEnabled() || altersCode;
|
||||||
if (!needsToUpdateGraphics) {
|
if (!needsToUpdateGraphics) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!key.noKeyPreview() && !sInGesture && !needsToSuppressKeyPreviewPopup(eventTime)) {
|
if (!key.noKeyPreview() && !sInGesture && !needsToSuppressKeyPreviewPopup(eventTime)) {
|
||||||
mDrawingProxy.showKeyPreview(key);
|
sDrawingProxy.showKeyPreview(key);
|
||||||
}
|
}
|
||||||
updatePressKeyGraphics(key);
|
updatePressKeyGraphics(key);
|
||||||
|
|
||||||
|
@ -694,7 +646,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.altCodeWhileTyping() && mTimerProxy.isTypingState()) {
|
if (key.altCodeWhileTyping() && sTimerProxy.isTypingState()) {
|
||||||
final int altCode = key.getAltCode();
|
final int altCode = key.getAltCode();
|
||||||
final Key altKey = mKeyboard.getKey(altCode);
|
final Key altKey = mKeyboard.getKey(altCode);
|
||||||
if (altKey != null) {
|
if (altKey != null) {
|
||||||
|
@ -708,14 +660,14 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateReleaseKeyGraphics(final Key key) {
|
private static void updateReleaseKeyGraphics(final Key key) {
|
||||||
key.onReleased();
|
key.onReleased();
|
||||||
mDrawingProxy.invalidateKey(key);
|
sDrawingProxy.invalidateKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePressKeyGraphics(final Key key) {
|
private static void updatePressKeyGraphics(final Key key) {
|
||||||
key.onPressed();
|
key.onPressed();
|
||||||
mDrawingProxy.invalidateKey(key);
|
sDrawingProxy.invalidateKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GestureStrokeWithPreviewPoints getGestureStrokeWithPreviewPoints() {
|
public GestureStrokeWithPreviewPoints getGestureStrokeWithPreviewPoints() {
|
||||||
|
@ -786,12 +738,12 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
sAggregratedPointers.reset();
|
sAggregratedPointers.reset();
|
||||||
sLastRecognitionPointSize = 0;
|
sLastRecognitionPointSize = 0;
|
||||||
sLastRecognitionTime = 0;
|
sLastRecognitionTime = 0;
|
||||||
mListener.onStartBatchInput();
|
sListener.onStartBatchInput();
|
||||||
dismissAllMoreKeysPanels();
|
dismissAllMoreKeysPanels();
|
||||||
}
|
}
|
||||||
mTimerProxy.cancelLongPressTimer();
|
sTimerProxy.cancelLongPressTimer();
|
||||||
// A gesture floating preview text will be shown at the oldest pointer/finger on the screen.
|
// A gesture floating preview text will be shown at the oldest pointer/finger on the screen.
|
||||||
mDrawingProxy.showGestureTrail(
|
sDrawingProxy.showGestureTrail(
|
||||||
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,7 +761,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// A gesture floating preview text will be shown at the oldest pointer/finger on the screen.
|
// A gesture floating preview text will be shown at the oldest pointer/finger on the screen.
|
||||||
mDrawingProxy.showGestureTrail(
|
sDrawingProxy.showGestureTrail(
|
||||||
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,8 +776,8 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
Log.d(TAG, String.format("[%d] onUpdateBatchInput: batchPoints=%d", mPointerId,
|
Log.d(TAG, String.format("[%d] onUpdateBatchInput: batchPoints=%d", mPointerId,
|
||||||
size));
|
size));
|
||||||
}
|
}
|
||||||
mTimerProxy.startUpdateBatchInputTimer(this);
|
sTimerProxy.startUpdateBatchInputTimer(this);
|
||||||
mListener.onUpdateBatchInput(sAggregratedPointers);
|
sListener.onUpdateBatchInput(sAggregratedPointers);
|
||||||
// The listener may change the size of the pointers (when auto-committing
|
// The listener may change the size of the pointers (when auto-committing
|
||||||
// for example), so we need to get the size from the pointers again.
|
// for example), so we need to get the size from the pointers again.
|
||||||
sLastRecognitionPointSize = sAggregratedPointers.getPointerSize();
|
sLastRecognitionPointSize = sAggregratedPointers.getPointerSize();
|
||||||
|
@ -840,13 +792,13 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
if (getActivePointerTrackerCount() == 1) {
|
if (getActivePointerTrackerCount() == 1) {
|
||||||
sInGesture = false;
|
sInGesture = false;
|
||||||
sTimeRecorder.onEndBatchInput(eventTime);
|
sTimeRecorder.onEndBatchInput(eventTime);
|
||||||
mTimerProxy.cancelAllUpdateBatchInputTimers();
|
sTimerProxy.cancelAllUpdateBatchInputTimers();
|
||||||
if (!mIsTrackingForActionDisabled) {
|
if (!mIsTrackingForActionDisabled) {
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, String.format("[%d] onEndBatchInput : batchPoints=%d",
|
Log.d(TAG, String.format("[%d] onEndBatchInput : batchPoints=%d",
|
||||||
mPointerId, sAggregratedPointers.getPointerSize()));
|
mPointerId, sAggregratedPointers.getPointerSize()));
|
||||||
}
|
}
|
||||||
mListener.onEndBatchInput(sAggregratedPointers);
|
sListener.onEndBatchInput(sAggregratedPointers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -854,7 +806,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// A gesture floating preview text will be shown at the oldest pointer/finger on the screen.
|
// A gesture floating preview text will be shown at the oldest pointer/finger on the screen.
|
||||||
mDrawingProxy.showGestureTrail(
|
sDrawingProxy.showGestureTrail(
|
||||||
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
this, isOldestTrackerInQueue() /* showsFloatingPreviewText */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,17 +820,17 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
if (DEBUG_LISTENER) {
|
if (DEBUG_LISTENER) {
|
||||||
Log.d(TAG, String.format("[%d] onCancelBatchInput", mPointerId));
|
Log.d(TAG, String.format("[%d] onCancelBatchInput", mPointerId));
|
||||||
}
|
}
|
||||||
mListener.onCancelBatchInput();
|
sListener.onCancelBatchInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processMotionEvent(final MotionEvent me, final KeyEventHandler handler) {
|
public void processMotionEvent(final MotionEvent me, final KeyDetector keyDetector) {
|
||||||
final int action = me.getActionMasked();
|
final int action = me.getActionMasked();
|
||||||
final long eventTime = me.getEventTime();
|
final long eventTime = me.getEventTime();
|
||||||
if (action == MotionEvent.ACTION_MOVE) {
|
if (action == MotionEvent.ACTION_MOVE) {
|
||||||
final int pointerCount = me.getPointerCount();
|
final int pointerCount = me.getPointerCount();
|
||||||
for (int index = 0; index < pointerCount; index++) {
|
for (int index = 0; index < pointerCount; index++) {
|
||||||
final int id = me.getPointerId(index);
|
final int id = me.getPointerId(index);
|
||||||
final PointerTracker tracker = getPointerTracker(id, handler);
|
final PointerTracker tracker = getPointerTracker(id);
|
||||||
final int x = (int)me.getX(index);
|
final int x = (int)me.getX(index);
|
||||||
final int y = (int)me.getY(index);
|
final int y = (int)me.getY(index);
|
||||||
tracker.onMoveEvent(x, y, eventTime, me);
|
tracker.onMoveEvent(x, y, eventTime, me);
|
||||||
|
@ -891,7 +843,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
case MotionEvent.ACTION_POINTER_DOWN:
|
case MotionEvent.ACTION_POINTER_DOWN:
|
||||||
onDownEvent(x, y, eventTime, handler);
|
onDownEvent(x, y, eventTime, keyDetector);
|
||||||
break;
|
break;
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
case MotionEvent.ACTION_POINTER_UP:
|
case MotionEvent.ACTION_POINTER_UP:
|
||||||
|
@ -904,11 +856,11 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDownEvent(final int x, final int y, final long eventTime,
|
private void onDownEvent(final int x, final int y, final long eventTime,
|
||||||
final KeyEventHandler handler) {
|
final KeyDetector keyDetector) {
|
||||||
if (DEBUG_EVENT) {
|
if (DEBUG_EVENT) {
|
||||||
printTouchEvent("onDownEvent:", x, y, eventTime);
|
printTouchEvent("onDownEvent:", x, y, eventTime);
|
||||||
}
|
}
|
||||||
setKeyEventHandler(handler);
|
setKeyDetectorInner(keyDetector);
|
||||||
// Naive up-to-down noise filter.
|
// Naive up-to-down noise filter.
|
||||||
final long deltaT = eventTime - mUpTime;
|
final long deltaT = eventTime - mUpTime;
|
||||||
if (deltaT < sParams.mTouchNoiseThresholdTime) {
|
if (deltaT < sParams.mTouchNoiseThresholdTime) {
|
||||||
|
@ -998,7 +950,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
private void resetKeySelectionByDraggingFinger() {
|
private void resetKeySelectionByDraggingFinger() {
|
||||||
mIsInDraggingFinger = false;
|
mIsInDraggingFinger = false;
|
||||||
mIsInSlidingKeyInput = false;
|
mIsInSlidingKeyInput = false;
|
||||||
mDrawingProxy.dismissSlidingKeyInputPreview();
|
sDrawingProxy.dismissSlidingKeyInputPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onGestureMoveEvent(final int x, final int y, final long eventTime,
|
private void onGestureMoveEvent(final int x, final int y, final long eventTime,
|
||||||
|
@ -1009,7 +961,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
final boolean onValidArea = mGestureStrokeWithPreviewPoints.addPointOnKeyboard(
|
final boolean onValidArea = mGestureStrokeWithPreviewPoints.addPointOnKeyboard(
|
||||||
x, y, gestureTime, isMajorEvent);
|
x, y, gestureTime, isMajorEvent);
|
||||||
if (mGestureStrokeWithPreviewPoints.getLength() > beforeLength) {
|
if (mGestureStrokeWithPreviewPoints.getLength() > beforeLength) {
|
||||||
mTimerProxy.startUpdateBatchInputTimer(this);
|
sTimerProxy.startUpdateBatchInputTimer(this);
|
||||||
}
|
}
|
||||||
// If the move event goes out from valid batch input area, cancel batch input.
|
// If the move event goes out from valid batch input area, cancel batch input.
|
||||||
if (!onValidArea) {
|
if (!onValidArea) {
|
||||||
|
@ -1055,7 +1007,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
mMoreKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId, eventTime);
|
mMoreKeysPanel.onMoveEvent(translatedX, translatedY, mPointerId, eventTime);
|
||||||
onMoveKey(x, y);
|
onMoveKey(x, y);
|
||||||
if (mIsInSlidingKeyInput) {
|
if (mIsInSlidingKeyInput) {
|
||||||
mDrawingProxy.showSlidingKeyInputPreview(this);
|
sDrawingProxy.showSlidingKeyInputPreview(this);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1120,7 +1072,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
setReleasedKeyGraphics(oldKey);
|
setReleasedKeyGraphics(oldKey);
|
||||||
callListenerOnRelease(oldKey, oldKey.getCode(), true /* withSliding */);
|
callListenerOnRelease(oldKey, oldKey.getCode(), true /* withSliding */);
|
||||||
startKeySelectionByDraggingFinger(oldKey);
|
startKeySelectionByDraggingFinger(oldKey);
|
||||||
mTimerProxy.cancelKeyTimers();
|
sTimerProxy.cancelKeyTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dragFingerFromOldKeyToNewKey(final Key key, final int x, final int y,
|
private void dragFingerFromOldKeyToNewKey(final Key key, final int x, final int y,
|
||||||
|
@ -1212,7 +1164,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mIsInSlidingKeyInput) {
|
if (mIsInSlidingKeyInput) {
|
||||||
mDrawingProxy.showSlidingKeyInputPreview(this);
|
sDrawingProxy.showSlidingKeyInputPreview(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1221,7 +1173,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
printTouchEvent("onUpEvent :", x, y, eventTime);
|
printTouchEvent("onUpEvent :", x, y, eventTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
mTimerProxy.cancelUpdateBatchInputTimer(this);
|
sTimerProxy.cancelUpdateBatchInputTimer(this);
|
||||||
if (!sInGesture) {
|
if (!sInGesture) {
|
||||||
if (mCurrentKey != null && mCurrentKey.isModifier()) {
|
if (mCurrentKey != null && mCurrentKey.isModifier()) {
|
||||||
// Before processing an up event of modifier key, all pointers already being
|
// Before processing an up event of modifier key, all pointers already being
|
||||||
|
@ -1251,7 +1203,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUpEventInternal(final int x, final int y, final long eventTime) {
|
private void onUpEventInternal(final int x, final int y, final long eventTime) {
|
||||||
mTimerProxy.cancelKeyTimers();
|
sTimerProxy.cancelKeyTimers();
|
||||||
final boolean isInDraggingFinger = mIsInDraggingFinger;
|
final boolean isInDraggingFinger = mIsInDraggingFinger;
|
||||||
final boolean isInSlidingKeyInput = mIsInSlidingKeyInput;
|
final boolean isInSlidingKeyInput = mIsInSlidingKeyInput;
|
||||||
resetKeySelectionByDraggingFinger();
|
resetKeySelectionByDraggingFinger();
|
||||||
|
@ -1330,7 +1282,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCancelEventInternal() {
|
private void onCancelEventInternal() {
|
||||||
mTimerProxy.cancelKeyTimers();
|
sTimerProxy.cancelKeyTimers();
|
||||||
setReleasedKeyGraphics(mCurrentKey);
|
setReleasedKeyGraphics(mCurrentKey);
|
||||||
resetKeySelectionByDraggingFinger();
|
resetKeySelectionByDraggingFinger();
|
||||||
if (isShowingMoreKeysPanel()) {
|
if (isShowingMoreKeysPanel()) {
|
||||||
|
@ -1393,7 +1345,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
if (mIsInDraggingFinger && key.getMoreKeys() == null) return;
|
if (mIsInDraggingFinger && key.getMoreKeys() == null) return;
|
||||||
|
|
||||||
final int delay = getLongPressTimeout(key.getCode());
|
final int delay = getLongPressTimeout(key.getCode());
|
||||||
mTimerProxy.startLongPressTimer(this, delay);
|
sTimerProxy.startLongPressTimer(this, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getLongPressTimeout(final int code) {
|
private int getLongPressTimeout(final int code) {
|
||||||
|
@ -1446,7 +1398,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element {
|
||||||
private void startKeyRepeatTimer(final int repeatCount) {
|
private void startKeyRepeatTimer(final int repeatCount) {
|
||||||
final int delay =
|
final int delay =
|
||||||
(repeatCount == 1) ? sParams.mKeyRepeatStartTimeout : sParams.mKeyRepeatInterval;
|
(repeatCount == 1) ? sParams.mKeyRepeatStartTimeout : sParams.mKeyRepeatInterval;
|
||||||
mTimerProxy.startKeyRepeatTimer(this, repeatCount, delay);
|
sTimerProxy.startKeyRepeatTimer(this, repeatCount, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printTouchEvent(final String title, final int x, final int y,
|
private void printTouchEvent(final String title, final int x, final int y,
|
||||||
|
|
|
@ -20,18 +20,24 @@ import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
|
import com.android.inputmethod.keyboard.KeyDetector;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker;
|
import com.android.inputmethod.keyboard.PointerTracker;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker.KeyEventHandler;
|
|
||||||
import com.android.inputmethod.latin.utils.CoordinateUtils;
|
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 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 void processMotionEvent(final MotionEvent me, final KeyEventHandler keyEventHandler) {
|
public NonDistinctMultitouchHelper(final PointerTracker mainTracker) {
|
||||||
|
mMainTracker = mainTracker;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
mOldPointerCount = pointerCount;
|
mOldPointerCount = pointerCount;
|
||||||
|
@ -41,8 +47,7 @@ public final class NonDistinctMultitouchHelper {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use only main (id=0) pointer tracker.
|
final PointerTracker mainTracker = mMainTracker;
|
||||||
final PointerTracker mainTracker = PointerTracker.getPointerTracker(0, keyEventHandler);
|
|
||||||
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();
|
||||||
|
@ -51,12 +56,12 @@ public final class NonDistinctMultitouchHelper {
|
||||||
// In single-touch.
|
// In single-touch.
|
||||||
if (oldPointerCount == 1 && pointerCount == 1) {
|
if (oldPointerCount == 1 && pointerCount == 1) {
|
||||||
if (me.getPointerId(index) == mainTracker.mPointerId) {
|
if (me.getPointerId(index) == mainTracker.mPointerId) {
|
||||||
mainTracker.processMotionEvent(me, keyEventHandler);
|
mainTracker.processMotionEvent(me, keyDetector);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Inject a copied event.
|
// Inject a copied event.
|
||||||
injectMotionEvent(action, me.getX(index), me.getY(index), downTime, eventTime,
|
injectMotionEvent(action, me.getX(index), me.getY(index), downTime, eventTime,
|
||||||
mainTracker, keyEventHandler);
|
mainTracker, keyDetector);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +75,7 @@ public final class NonDistinctMultitouchHelper {
|
||||||
mOldKey = mainTracker.getKeyOn(x, y);
|
mOldKey = mainTracker.getKeyOn(x, y);
|
||||||
// Inject an artifact up event for the old key.
|
// Inject an artifact up event for the old key.
|
||||||
injectMotionEvent(MotionEvent.ACTION_UP, x, y, downTime, eventTime,
|
injectMotionEvent(MotionEvent.ACTION_UP, x, y, downTime, eventTime,
|
||||||
mainTracker, keyEventHandler);
|
mainTracker, keyDetector);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,11 +90,11 @@ public final class NonDistinctMultitouchHelper {
|
||||||
// Inject an artifact down event for the new key.
|
// Inject an artifact down event for the new key.
|
||||||
// An artifact up event for the new key will usually be injected as a single-touch.
|
// An artifact up event for the new key will usually be injected as a single-touch.
|
||||||
injectMotionEvent(MotionEvent.ACTION_DOWN, x, y, downTime, eventTime,
|
injectMotionEvent(MotionEvent.ACTION_DOWN, x, y, downTime, eventTime,
|
||||||
mainTracker, keyEventHandler);
|
mainTracker, keyDetector);
|
||||||
if (action == MotionEvent.ACTION_UP) {
|
if (action == MotionEvent.ACTION_UP) {
|
||||||
// Inject an artifact up event for the new key also.
|
// Inject an artifact up event for the new key also.
|
||||||
injectMotionEvent(MotionEvent.ACTION_UP, x, y, downTime, eventTime,
|
injectMotionEvent(MotionEvent.ACTION_UP, x, y, downTime, eventTime,
|
||||||
mainTracker, keyEventHandler);
|
mainTracker, keyDetector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -101,11 +106,11 @@ public final class NonDistinctMultitouchHelper {
|
||||||
|
|
||||||
private static void injectMotionEvent(final int action, final float x, final float y,
|
private static void injectMotionEvent(final int action, final float x, final float y,
|
||||||
final long downTime, final long eventTime, final PointerTracker tracker,
|
final long downTime, final long eventTime, final PointerTracker tracker,
|
||||||
final KeyEventHandler handler) {
|
final KeyDetector keyDetector) {
|
||||||
final MotionEvent me = MotionEvent.obtain(
|
final MotionEvent me = MotionEvent.obtain(
|
||||||
downTime, eventTime, action, x, y, 0 /* metaState */);
|
downTime, eventTime, action, x, y, 0 /* metaState */);
|
||||||
try {
|
try {
|
||||||
tracker.processMotionEvent(me, handler);
|
tracker.processMotionEvent(me, keyDetector);
|
||||||
} finally {
|
} finally {
|
||||||
me.recycle();
|
me.recycle();
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ import com.android.inputmethod.compat.InputMethodServiceCompatUtils;
|
||||||
import com.android.inputmethod.compat.SuggestionSpanUtils;
|
import com.android.inputmethod.compat.SuggestionSpanUtils;
|
||||||
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
|
import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
|
||||||
import com.android.inputmethod.event.EventInterpreter;
|
import com.android.inputmethod.event.EventInterpreter;
|
||||||
import com.android.inputmethod.keyboard.KeyDetector;
|
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
|
@ -2284,16 +2283,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
resetComposingState(false /* alsoResetLastComposedWord */);
|
resetComposingState(false /* alsoResetLastComposedWord */);
|
||||||
}
|
}
|
||||||
if (isComposingWord) {
|
if (isComposingWord) {
|
||||||
final int keyX, keyY;
|
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
|
||||||
if (Constants.isValidCoordinate(x) && Constants.isValidCoordinate(y)) {
|
// TODO: We should reconsider which coordinate system should be used to represent
|
||||||
final KeyDetector keyDetector =
|
// keyboard event.
|
||||||
mKeyboardSwitcher.getMainKeyboardView().getKeyDetector();
|
final int keyX = mainKeyboardView.getKeyX(x);
|
||||||
keyX = keyDetector.getTouchX(x);
|
final int keyY = mainKeyboardView.getKeyY(y);
|
||||||
keyY = keyDetector.getTouchY(y);
|
|
||||||
} else {
|
|
||||||
keyX = x;
|
|
||||||
keyY = y;
|
|
||||||
}
|
|
||||||
mWordComposer.add(primaryCode, keyX, keyY);
|
mWordComposer.add(primaryCode, keyX, keyY);
|
||||||
// If it's the first letter, make note of auto-caps state
|
// If it's the first letter, make note of auto-caps state
|
||||||
if (mWordComposer.size() == 1) {
|
if (mWordComposer.size() == 1) {
|
||||||
|
|
Loading…
Reference in New Issue