Loading java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +8 −14 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.view.inputmethod.EditorInfo; import com.android.inputmethod.compat.AccessibilityEventCompatUtils; import com.android.inputmethod.compat.MotionEventCompatUtils; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.LatinKeyboardView; import com.android.inputmethod.keyboard.PointerTracker; Loading @@ -42,7 +41,7 @@ public class AccessibleKeyboardViewProxy { private LatinKeyboardView mView; private AccessibleKeyboardActionListener mListener; private int mLastHoverKeyIndex = KeyDetector.NOT_A_KEY; private Key mLastHoverKey = null; public static void init(InputMethodService inputMethod, SharedPreferences prefs) { sInstance.initInternal(inputMethod, prefs); Loading Loading @@ -81,7 +80,7 @@ public class AccessibleKeyboardViewProxy { switch (event.getEventType()) { case AccessibilityEventCompatUtils.TYPE_VIEW_HOVER_ENTER: final Key key = tracker.getKey(mLastHoverKeyIndex); final Key key = mLastHoverKey; if (key == null) break; Loading Loading @@ -130,12 +129,12 @@ public class AccessibleKeyboardViewProxy { switch (event.getAction()) { case MotionEventCompatUtils.ACTION_HOVER_ENTER: case MotionEventCompatUtils.ACTION_HOVER_MOVE: final int keyIndex = tracker.getKeyIndexOn(x, y); final Key key = tracker.getKeyOn(x, y); if (keyIndex != mLastHoverKeyIndex) { fireKeyHoverEvent(tracker, mLastHoverKeyIndex, false); mLastHoverKeyIndex = keyIndex; fireKeyHoverEvent(tracker, mLastHoverKeyIndex, true); if (key != mLastHoverKey) { fireKeyHoverEvent(tracker, mLastHoverKey, false); mLastHoverKey = key; fireKeyHoverEvent(tracker, mLastHoverKey, true); } return true; Loading @@ -144,7 +143,7 @@ public class AccessibleKeyboardViewProxy { return false; } private void fireKeyHoverEvent(PointerTracker tracker, int keyIndex, boolean entering) { private void fireKeyHoverEvent(PointerTracker tracker, Key key, boolean entering) { if (mListener == null) { Log.e(TAG, "No accessible keyboard action listener set!"); return; Loading @@ -155,11 +154,6 @@ public class AccessibleKeyboardViewProxy { return; } if (keyIndex == KeyDetector.NOT_A_KEY) return; final Key key = tracker.getKey(keyIndex); if (key == null) return; Loading java/src/com/android/inputmethod/keyboard/Key.java +8 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,14 @@ public class Key { return false; } public boolean isShift() { return mCode == Keyboard.CODE_SHIFT; } public boolean isModifier() { return mCode == Keyboard.CODE_SHIFT || mCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL; } public boolean isRepeatable() { return (mActionFlags & ACTION_FLAGS_IS_REPEATABLE) != 0; } Loading java/src/com/android/inputmethod/keyboard/KeyDetector.java +19 −18 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ public class KeyDetector { private static final boolean DEBUG = false; public static final int NOT_A_CODE = -1; public static final int NOT_A_KEY = -1; private static final int NOT_A_KEY = -1; private final int mKeyHysteresisDistanceSquared; Loading Loading @@ -96,22 +96,22 @@ public class KeyDetector { } /** * Computes maximum size of the array that can contain all nearby key indices returned by * {@link #getKeyIndexAndNearbyCodes}. * Computes maximum size of the array that can contain all nearby key codes returned by * {@link #getKeyAndNearbyCodes}. * * @return Returns maximum size of the array that can contain all nearby key indices returned * by {@link #getKeyIndexAndNearbyCodes}. * @return Returns maximum size of the array that can contain all nearby key codes returned * by {@link #getKeyAndNearbyCodes}. */ protected int getMaxNearbyKeys() { return MAX_NEARBY_KEYS; } /** * Allocates array that can hold all key indices returned by {@link #getKeyIndexAndNearbyCodes} * Allocates array that can hold all key codes returned by {@link #getKeyAndNearbyCodes} * method. The maximum size of the array should be computed by {@link #getMaxNearbyKeys}. * * @return Allocates and returns an array that can hold all key indices returned by * {@link #getKeyIndexAndNearbyCodes} method. All elements in the returned array are * @return Allocates and returns an array that can hold all key codes returned by * {@link #getKeyAndNearbyCodes} method. All elements in the returned array are * initialized by {@link #NOT_A_CODE} value. */ public int[] newCodeArray() { Loading Loading @@ -180,31 +180,32 @@ public class KeyDetector { } /** * Finds all possible nearby key indices around a touch event point and returns the nearest key * index. The algorithm to determine the nearby keys depends on the threshold set by * Finds all possible nearby key codes around a touch event point and returns the nearest key. * The algorithm to determine the nearby keys depends on the threshold set by * {@link #setProximityThreshold(int)} and the mode set by * {@link #setProximityCorrectionEnabled(boolean)}. * * @param x The x-coordinate of a touch point * @param y The y-coordinate of a touch point * @param allCodes All nearby key code except functional key are returned in this array * @return The nearest key index * @param allCodes All nearby key codes except functional key are returned in this array * @return The nearest key */ public int getKeyIndexAndNearbyCodes(int x, int y, final int[] allCodes) { public Key getKeyAndNearbyCodes(int x, int y, final int[] allCodes) { final List<Key> keys = getKeyboard().mKeys; final int touchX = getTouchX(x); final int touchY = getTouchY(y); initializeNearbyKeys(); int primaryIndex = NOT_A_KEY; Key primaryKey = null; for (final int index : mKeyboard.getNearestKeys(touchX, touchY)) { final Key key = keys.get(index); final boolean isOnKey = key.isOnKey(touchX, touchY); final int distance = key.squaredDistanceToEdge(touchX, touchY); if (isOnKey || (mProximityCorrectOn && distance < mProximityThresholdSquare)) { final int insertedPosition = sortNearbyKeys(index, distance, isOnKey); if (insertedPosition == 0 && isOnKey) primaryIndex = index; if (insertedPosition == 0 && isOnKey) { primaryKey = key; } } } Loading @@ -213,11 +214,11 @@ public class KeyDetector { if (DEBUG) { Log.d(TAG, "x=" + x + " y=" + y + " primary=" + (primaryIndex == NOT_A_KEY ? "none" : keys.get(primaryIndex).mCode) + (primaryKey == null ? "none" : primaryKey.mCode) + " codes=" + Arrays.toString(allCodes)); } } return primaryIndex; return primaryKey; } } java/src/com/android/inputmethod/keyboard/KeyboardView.java +9 −10 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { final PointerTracker tracker = (PointerTracker) msg.obj; switch (msg.what) { case MSG_SHOW_KEY_PREVIEW: keyboardView.showKey(msg.arg1, tracker); keyboardView.showKey(tracker); break; case MSG_DISMISS_KEY_PREVIEW: tracker.getKeyPreviewText().setVisibility(View.INVISIBLE); Loading @@ -156,16 +156,15 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } } public void showKeyPreview(long delay, int keyIndex, PointerTracker tracker) { public void showKeyPreview(long delay, PointerTracker tracker) { removeMessages(MSG_SHOW_KEY_PREVIEW); final KeyboardView keyboardView = getOuterInstance(); if (keyboardView == null) return; if (tracker.getKeyPreviewText().getVisibility() == VISIBLE || delay == 0) { // Show right away, if it's already visible and finger is moving around keyboardView.showKey(keyIndex, tracker); keyboardView.showKey(tracker); } else { sendMessageDelayed( obtainMessage(MSG_SHOW_KEY_PREVIEW, keyIndex, 0, tracker), delay); sendMessageDelayed(obtainMessage(MSG_SHOW_KEY_PREVIEW, tracker), delay); } } Loading Loading @@ -830,9 +829,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } @Override public void showKeyPreview(int keyIndex, PointerTracker tracker) { public void showKeyPreview(PointerTracker tracker) { if (mShowKeyPreviewPopup) { mDrawingHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker); mDrawingHandler.showKeyPreview(mDelayBeforePreview, tracker); } } Loading @@ -858,7 +857,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { keyPreview, FrameLayoutCompatUtils.newLayoutParam(mPreviewPlacer, 0, 0)); } private void showKey(final int keyIndex, PointerTracker tracker) { private void showKey(PointerTracker tracker) { final TextView previewText = tracker.getKeyPreviewText(); // If the key preview has no parent view yet, add it to the ViewGroup which can place // key preview absolutely in SoftInputWindow. Loading @@ -867,8 +866,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } mDrawingHandler.cancelDismissKeyPreview(tracker); final Key key = tracker.getKey(keyIndex); // If keyIndex is invalid or IME is already closed, we must not show key preview. final Key key = tracker.getKey(); // If key is invalid or IME is already closed, we must not show key preview. // Trying to show key preview while root window is closed causes // WindowManager.BadTokenException. if (key == null) Loading java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +16 −15 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke private final boolean mHasDistinctMultitouch; private int mOldPointerCount = 1; private int mOldKeyIndex; private Key mOldKey; private final boolean mConfigShowMiniKeyboardAtTouchedPoint; protected KeyDetector mKeyDetector; Loading Loading @@ -103,19 +103,19 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final PointerTracker tracker = (PointerTracker) msg.obj; switch (msg.what) { case MSG_REPEAT_KEY: tracker.onRepeatKey(msg.arg1); startKeyRepeatTimer(keyboardView.mKeyRepeatInterval, msg.arg1, tracker); tracker.onRepeatKey(tracker.getKey()); startKeyRepeatTimer(keyboardView.mKeyRepeatInterval, tracker); break; case MSG_LONGPRESS_KEY: keyboardView.openMiniKeyboardIfRequired(msg.arg1, tracker); keyboardView.openMiniKeyboardIfRequired(tracker.getKey(), tracker); break; } } @Override public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker) { public void startKeyRepeatTimer(long delay, PointerTracker tracker) { mInKeyRepeat = true; sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, keyIndex, 0, tracker), delay); sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, tracker), delay); } public void cancelKeyRepeatTimer() { Loading @@ -128,9 +128,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke } @Override public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) { public void startLongPressTimer(long delay, PointerTracker tracker) { cancelLongPressTimer(); sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, keyIndex, 0, tracker), delay); sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, tracker), delay); } @Override Loading Loading @@ -181,8 +181,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final int pointerIndex = firstDown.getActionIndex(); final int id = firstDown.getPointerId(pointerIndex); final PointerTracker tracker = getPointerTracker(id); final Key key = tracker.getKeyOn((int)firstDown.getX(), (int)firstDown.getY()); // If the first down event is on shift key. if (tracker.isOnShiftKey((int) firstDown.getX(), (int) firstDown.getY())) { if (key != null && key.isShift()) { mProcessingShiftDoubleTapEvent = true; return true; } Loading @@ -199,8 +200,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final int pointerIndex = secondDown.getActionIndex(); final int id = secondDown.getPointerId(pointerIndex); final PointerTracker tracker = getPointerTracker(id); final Key key = tracker.getKeyOn((int)secondDown.getX(), (int)secondDown.getY()); // If the second down event is also on shift key. if (tracker.isOnShiftKey((int) secondDown.getX(), (int) secondDown.getY())) { if (key != null && key.isShift()) { // Detected a double tap on shift key. If we are in the ignoring double tap // mode, it means we have already turned off caps lock in // {@link KeyboardSwitcher#onReleaseShift} . Loading Loading @@ -326,7 +328,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke super.cancelAllMessages(); } private boolean openMiniKeyboardIfRequired(int keyIndex, PointerTracker tracker) { private boolean openMiniKeyboardIfRequired(Key parentKey, PointerTracker tracker) { // Check if we have a popup layout specified first. if (mMoreKeysLayout == 0) { return false; Loading @@ -335,7 +337,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke // Check if we are already displaying popup panel. if (mMoreKeysPanel != null) return false; final Key parentKey = tracker.getKey(keyIndex); if (parentKey == null) return false; return onLongPress(parentKey, tracker); Loading Loading @@ -546,8 +547,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke // Multi-touch to single touch transition. // Send a down event for the latest pointer if the key is different from the // previous key. final int newKeyIndex = tracker.getKeyIndexOn(x, y); if (mOldKeyIndex != newKeyIndex) { final Key newKey = tracker.getKeyOn(x, y); if (mOldKey != newKey) { tracker.onDownEvent(x, y, eventTime, this); if (action == MotionEvent.ACTION_UP) tracker.onUpEvent(x, y, eventTime); Loading @@ -557,7 +558,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke // Send an up event for the last pointer. final int lastX = tracker.getLastX(); final int lastY = tracker.getLastY(); mOldKeyIndex = tracker.getKeyIndexOn(lastX, lastY); mOldKey = tracker.getKeyOn(lastX, lastY); tracker.onUpEvent(lastX, lastY, eventTime); } else if (pointerCount == 1 && oldPointerCount == 1) { tracker.processMotionEvent(action, x, y, eventTime, this); Loading Loading
java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +8 −14 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.view.inputmethod.EditorInfo; import com.android.inputmethod.compat.AccessibilityEventCompatUtils; import com.android.inputmethod.compat.MotionEventCompatUtils; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.LatinKeyboardView; import com.android.inputmethod.keyboard.PointerTracker; Loading @@ -42,7 +41,7 @@ public class AccessibleKeyboardViewProxy { private LatinKeyboardView mView; private AccessibleKeyboardActionListener mListener; private int mLastHoverKeyIndex = KeyDetector.NOT_A_KEY; private Key mLastHoverKey = null; public static void init(InputMethodService inputMethod, SharedPreferences prefs) { sInstance.initInternal(inputMethod, prefs); Loading Loading @@ -81,7 +80,7 @@ public class AccessibleKeyboardViewProxy { switch (event.getEventType()) { case AccessibilityEventCompatUtils.TYPE_VIEW_HOVER_ENTER: final Key key = tracker.getKey(mLastHoverKeyIndex); final Key key = mLastHoverKey; if (key == null) break; Loading Loading @@ -130,12 +129,12 @@ public class AccessibleKeyboardViewProxy { switch (event.getAction()) { case MotionEventCompatUtils.ACTION_HOVER_ENTER: case MotionEventCompatUtils.ACTION_HOVER_MOVE: final int keyIndex = tracker.getKeyIndexOn(x, y); final Key key = tracker.getKeyOn(x, y); if (keyIndex != mLastHoverKeyIndex) { fireKeyHoverEvent(tracker, mLastHoverKeyIndex, false); mLastHoverKeyIndex = keyIndex; fireKeyHoverEvent(tracker, mLastHoverKeyIndex, true); if (key != mLastHoverKey) { fireKeyHoverEvent(tracker, mLastHoverKey, false); mLastHoverKey = key; fireKeyHoverEvent(tracker, mLastHoverKey, true); } return true; Loading @@ -144,7 +143,7 @@ public class AccessibleKeyboardViewProxy { return false; } private void fireKeyHoverEvent(PointerTracker tracker, int keyIndex, boolean entering) { private void fireKeyHoverEvent(PointerTracker tracker, Key key, boolean entering) { if (mListener == null) { Log.e(TAG, "No accessible keyboard action listener set!"); return; Loading @@ -155,11 +154,6 @@ public class AccessibleKeyboardViewProxy { return; } if (keyIndex == KeyDetector.NOT_A_KEY) return; final Key key = tracker.getKey(keyIndex); if (key == null) return; Loading
java/src/com/android/inputmethod/keyboard/Key.java +8 −0 Original line number Diff line number Diff line Loading @@ -318,6 +318,14 @@ public class Key { return false; } public boolean isShift() { return mCode == Keyboard.CODE_SHIFT; } public boolean isModifier() { return mCode == Keyboard.CODE_SHIFT || mCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL; } public boolean isRepeatable() { return (mActionFlags & ACTION_FLAGS_IS_REPEATABLE) != 0; } Loading
java/src/com/android/inputmethod/keyboard/KeyDetector.java +19 −18 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ public class KeyDetector { private static final boolean DEBUG = false; public static final int NOT_A_CODE = -1; public static final int NOT_A_KEY = -1; private static final int NOT_A_KEY = -1; private final int mKeyHysteresisDistanceSquared; Loading Loading @@ -96,22 +96,22 @@ public class KeyDetector { } /** * Computes maximum size of the array that can contain all nearby key indices returned by * {@link #getKeyIndexAndNearbyCodes}. * Computes maximum size of the array that can contain all nearby key codes returned by * {@link #getKeyAndNearbyCodes}. * * @return Returns maximum size of the array that can contain all nearby key indices returned * by {@link #getKeyIndexAndNearbyCodes}. * @return Returns maximum size of the array that can contain all nearby key codes returned * by {@link #getKeyAndNearbyCodes}. */ protected int getMaxNearbyKeys() { return MAX_NEARBY_KEYS; } /** * Allocates array that can hold all key indices returned by {@link #getKeyIndexAndNearbyCodes} * Allocates array that can hold all key codes returned by {@link #getKeyAndNearbyCodes} * method. The maximum size of the array should be computed by {@link #getMaxNearbyKeys}. * * @return Allocates and returns an array that can hold all key indices returned by * {@link #getKeyIndexAndNearbyCodes} method. All elements in the returned array are * @return Allocates and returns an array that can hold all key codes returned by * {@link #getKeyAndNearbyCodes} method. All elements in the returned array are * initialized by {@link #NOT_A_CODE} value. */ public int[] newCodeArray() { Loading Loading @@ -180,31 +180,32 @@ public class KeyDetector { } /** * Finds all possible nearby key indices around a touch event point and returns the nearest key * index. The algorithm to determine the nearby keys depends on the threshold set by * Finds all possible nearby key codes around a touch event point and returns the nearest key. * The algorithm to determine the nearby keys depends on the threshold set by * {@link #setProximityThreshold(int)} and the mode set by * {@link #setProximityCorrectionEnabled(boolean)}. * * @param x The x-coordinate of a touch point * @param y The y-coordinate of a touch point * @param allCodes All nearby key code except functional key are returned in this array * @return The nearest key index * @param allCodes All nearby key codes except functional key are returned in this array * @return The nearest key */ public int getKeyIndexAndNearbyCodes(int x, int y, final int[] allCodes) { public Key getKeyAndNearbyCodes(int x, int y, final int[] allCodes) { final List<Key> keys = getKeyboard().mKeys; final int touchX = getTouchX(x); final int touchY = getTouchY(y); initializeNearbyKeys(); int primaryIndex = NOT_A_KEY; Key primaryKey = null; for (final int index : mKeyboard.getNearestKeys(touchX, touchY)) { final Key key = keys.get(index); final boolean isOnKey = key.isOnKey(touchX, touchY); final int distance = key.squaredDistanceToEdge(touchX, touchY); if (isOnKey || (mProximityCorrectOn && distance < mProximityThresholdSquare)) { final int insertedPosition = sortNearbyKeys(index, distance, isOnKey); if (insertedPosition == 0 && isOnKey) primaryIndex = index; if (insertedPosition == 0 && isOnKey) { primaryKey = key; } } } Loading @@ -213,11 +214,11 @@ public class KeyDetector { if (DEBUG) { Log.d(TAG, "x=" + x + " y=" + y + " primary=" + (primaryIndex == NOT_A_KEY ? "none" : keys.get(primaryIndex).mCode) + (primaryKey == null ? "none" : primaryKey.mCode) + " codes=" + Arrays.toString(allCodes)); } } return primaryIndex; return primaryKey; } }
java/src/com/android/inputmethod/keyboard/KeyboardView.java +9 −10 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { final PointerTracker tracker = (PointerTracker) msg.obj; switch (msg.what) { case MSG_SHOW_KEY_PREVIEW: keyboardView.showKey(msg.arg1, tracker); keyboardView.showKey(tracker); break; case MSG_DISMISS_KEY_PREVIEW: tracker.getKeyPreviewText().setVisibility(View.INVISIBLE); Loading @@ -156,16 +156,15 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } } public void showKeyPreview(long delay, int keyIndex, PointerTracker tracker) { public void showKeyPreview(long delay, PointerTracker tracker) { removeMessages(MSG_SHOW_KEY_PREVIEW); final KeyboardView keyboardView = getOuterInstance(); if (keyboardView == null) return; if (tracker.getKeyPreviewText().getVisibility() == VISIBLE || delay == 0) { // Show right away, if it's already visible and finger is moving around keyboardView.showKey(keyIndex, tracker); keyboardView.showKey(tracker); } else { sendMessageDelayed( obtainMessage(MSG_SHOW_KEY_PREVIEW, keyIndex, 0, tracker), delay); sendMessageDelayed(obtainMessage(MSG_SHOW_KEY_PREVIEW, tracker), delay); } } Loading Loading @@ -830,9 +829,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } @Override public void showKeyPreview(int keyIndex, PointerTracker tracker) { public void showKeyPreview(PointerTracker tracker) { if (mShowKeyPreviewPopup) { mDrawingHandler.showKeyPreview(mDelayBeforePreview, keyIndex, tracker); mDrawingHandler.showKeyPreview(mDelayBeforePreview, tracker); } } Loading @@ -858,7 +857,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { keyPreview, FrameLayoutCompatUtils.newLayoutParam(mPreviewPlacer, 0, 0)); } private void showKey(final int keyIndex, PointerTracker tracker) { private void showKey(PointerTracker tracker) { final TextView previewText = tracker.getKeyPreviewText(); // If the key preview has no parent view yet, add it to the ViewGroup which can place // key preview absolutely in SoftInputWindow. Loading @@ -867,8 +866,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { } mDrawingHandler.cancelDismissKeyPreview(tracker); final Key key = tracker.getKey(keyIndex); // If keyIndex is invalid or IME is already closed, we must not show key preview. final Key key = tracker.getKey(); // If key is invalid or IME is already closed, we must not show key preview. // Trying to show key preview while root window is closed causes // WindowManager.BadTokenException. if (key == null) Loading
java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +16 −15 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke private final boolean mHasDistinctMultitouch; private int mOldPointerCount = 1; private int mOldKeyIndex; private Key mOldKey; private final boolean mConfigShowMiniKeyboardAtTouchedPoint; protected KeyDetector mKeyDetector; Loading Loading @@ -103,19 +103,19 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final PointerTracker tracker = (PointerTracker) msg.obj; switch (msg.what) { case MSG_REPEAT_KEY: tracker.onRepeatKey(msg.arg1); startKeyRepeatTimer(keyboardView.mKeyRepeatInterval, msg.arg1, tracker); tracker.onRepeatKey(tracker.getKey()); startKeyRepeatTimer(keyboardView.mKeyRepeatInterval, tracker); break; case MSG_LONGPRESS_KEY: keyboardView.openMiniKeyboardIfRequired(msg.arg1, tracker); keyboardView.openMiniKeyboardIfRequired(tracker.getKey(), tracker); break; } } @Override public void startKeyRepeatTimer(long delay, int keyIndex, PointerTracker tracker) { public void startKeyRepeatTimer(long delay, PointerTracker tracker) { mInKeyRepeat = true; sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, keyIndex, 0, tracker), delay); sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, tracker), delay); } public void cancelKeyRepeatTimer() { Loading @@ -128,9 +128,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke } @Override public void startLongPressTimer(long delay, int keyIndex, PointerTracker tracker) { public void startLongPressTimer(long delay, PointerTracker tracker) { cancelLongPressTimer(); sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, keyIndex, 0, tracker), delay); sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, tracker), delay); } @Override Loading Loading @@ -181,8 +181,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final int pointerIndex = firstDown.getActionIndex(); final int id = firstDown.getPointerId(pointerIndex); final PointerTracker tracker = getPointerTracker(id); final Key key = tracker.getKeyOn((int)firstDown.getX(), (int)firstDown.getY()); // If the first down event is on shift key. if (tracker.isOnShiftKey((int) firstDown.getX(), (int) firstDown.getY())) { if (key != null && key.isShift()) { mProcessingShiftDoubleTapEvent = true; return true; } Loading @@ -199,8 +200,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke final int pointerIndex = secondDown.getActionIndex(); final int id = secondDown.getPointerId(pointerIndex); final PointerTracker tracker = getPointerTracker(id); final Key key = tracker.getKeyOn((int)secondDown.getX(), (int)secondDown.getY()); // If the second down event is also on shift key. if (tracker.isOnShiftKey((int) secondDown.getX(), (int) secondDown.getY())) { if (key != null && key.isShift()) { // Detected a double tap on shift key. If we are in the ignoring double tap // mode, it means we have already turned off caps lock in // {@link KeyboardSwitcher#onReleaseShift} . Loading Loading @@ -326,7 +328,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke super.cancelAllMessages(); } private boolean openMiniKeyboardIfRequired(int keyIndex, PointerTracker tracker) { private boolean openMiniKeyboardIfRequired(Key parentKey, PointerTracker tracker) { // Check if we have a popup layout specified first. if (mMoreKeysLayout == 0) { return false; Loading @@ -335,7 +337,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke // Check if we are already displaying popup panel. if (mMoreKeysPanel != null) return false; final Key parentKey = tracker.getKey(keyIndex); if (parentKey == null) return false; return onLongPress(parentKey, tracker); Loading Loading @@ -546,8 +547,8 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke // Multi-touch to single touch transition. // Send a down event for the latest pointer if the key is different from the // previous key. final int newKeyIndex = tracker.getKeyIndexOn(x, y); if (mOldKeyIndex != newKeyIndex) { final Key newKey = tracker.getKeyOn(x, y); if (mOldKey != newKey) { tracker.onDownEvent(x, y, eventTime, this); if (action == MotionEvent.ACTION_UP) tracker.onUpEvent(x, y, eventTime); Loading @@ -557,7 +558,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke // Send an up event for the last pointer. final int lastX = tracker.getLastX(); final int lastY = tracker.getLastY(); mOldKeyIndex = tracker.getKeyIndexOn(lastX, lastY); mOldKey = tracker.getKeyOn(lastX, lastY); tracker.onUpEvent(lastX, lastY, eventTime); } else if (pointerCount == 1 && oldPointerCount == 1) { tracker.processMotionEvent(action, x, y, eventTime, this); Loading