Loading java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +10 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,9 @@ public interface KeyboardActionListener { * * @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key, * the value will be zero. * @param isSinglePointer true if pressing has occurred while no other key is being pressed. */ public void onPressKey(int primaryCode); public void onPressKey(int primaryCode, boolean isSinglePointer); /** * Called when the user releases a key. This is sent after the {@link #onCodeInput} is called. Loading Loading @@ -87,6 +88,11 @@ public interface KeyboardActionListener { */ public void onCancelInput(); /** * Called when user finished sliding key input. */ public void onFinishSlidingInput(); /** * Send a non-"code input" custom request to the listener. * @return true if the request has been consumed, false otherwise. Loading @@ -97,7 +103,7 @@ public interface KeyboardActionListener { public static final Adapter EMPTY_LISTENER = new Adapter(); @Override public void onPressKey(int primaryCode) {} public void onPressKey(int primaryCode, boolean isSinglePointer) {} @Override public void onReleaseKey(int primaryCode, boolean withSliding) {} @Override Loading @@ -115,6 +121,8 @@ public interface KeyboardActionListener { @Override public void onCancelInput() {} @Override public void onFinishSlidingInput() {} @Override public boolean onCustomRequest(int requestCode) { return false; } Loading java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +5 −9 Original line number Diff line number Diff line Loading @@ -216,19 +216,19 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mState.onResetKeyboardStateToAlphabet(); } public void onPressKey(final int code) { public void onPressKey(final int code, final boolean isSinglePointer) { if (isVibrateAndSoundFeedbackRequired()) { mFeedbackManager.hapticAndAudioFeedback(code, mKeyboardView); } mState.onPressKey(code, isSinglePointer(), mLatinIME.getCurrentAutoCapsState()); mState.onPressKey(code, isSinglePointer, mLatinIME.getCurrentAutoCapsState()); } public void onReleaseKey(final int code, final boolean withSliding) { mState.onReleaseKey(code, withSliding); } public void onCancelInput() { mState.onCancelInput(isSinglePointer()); public void onFinishSlidingInput() { mState.onFinishSlidingInput(); } // Implements {@link KeyboardState.SwitchActions}. Loading Loading @@ -346,15 +346,11 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { return mKeyboardView != null && !mKeyboardView.isInSlidingKeyInput(); } private boolean isSinglePointer() { return mKeyboardView != null && mKeyboardView.getPointerCount() == 1; } /** * Updates state machine to figure out when to automatically switch back to the previous mode. */ public void onCodeInput(final int code) { mState.onCodeInput(code, isSinglePointer(), mLatinIME.getCurrentAutoCapsState()); mState.onCodeInput(code, mLatinIME.getCurrentAutoCapsState()); } public MainKeyboardView getMainKeyboardView() { Loading java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +0 −4 Original line number Diff line number Diff line Loading @@ -1100,10 +1100,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack return false; } public int getPointerCount() { return mOldPointerCount; } @Override public boolean dispatchTouchEvent(MotionEvent event) { if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) { Loading java/src/com/android/inputmethod/keyboard/PointerTracker.java +15 −4 Original line number Diff line number Diff line Loading @@ -459,7 +459,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { return false; } if (key.isEnabled()) { mListener.onPressKey(key.mCode); mListener.onPressKey(key.mCode, getActivePointerTrackerCount() == 1); final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged; mKeyboardLayoutHasBeenChanged = false; mTimerProxy.startTypingStateTimer(key); Loading Loading @@ -527,6 +527,13 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } } private void callListenerOnFinishSlidingInput() { if (DEBUG_LISTENER) { Log.d(TAG, String.format("[%d] onFinishSlidingInput", mPointerId)); } mListener.onFinishSlidingInput(); } private void callListenerOnCancelInput() { if (DEBUG_LISTENER) { Log.d(TAG, String.format("[%d] onCancelInput", mPointerId)); Loading Loading @@ -1036,7 +1043,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private void processSildeOutFromOldKey(final Key oldKey) { setReleasedKeyGraphics(oldKey); callListenerOnRelease(oldKey, oldKey.mCode, true); callListenerOnRelease(oldKey, oldKey.mCode, true /* withSliding */); startSlidingKeyInput(oldKey); mTimerProxy.cancelKeyTimers(); } Loading Loading @@ -1169,6 +1176,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private void onUpEventInternal(final int x, final int y, final long eventTime) { mTimerProxy.cancelKeyTimers(); final boolean isInSlidingKeyInput = mIsInSlidingKeyInput; final boolean isInSlidingKeyInputFromModifier = mIsInSlidingKeyInputFromModifier; resetSlidingKeyInput(); mIsDetectingGesture = false; final Key currentKey = mCurrentKey; Loading @@ -1189,7 +1197,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { if (sInGesture) { if (currentKey != null) { callListenerOnRelease(currentKey, currentKey.mCode, true); callListenerOnRelease(currentKey, currentKey.mCode, true /* withSliding */); } mayEndBatchInput(eventTime); return; Loading @@ -1203,6 +1211,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element { return; } detectAndSendKey(currentKey, mKeyX, mKeyY, eventTime); if (isInSlidingKeyInputFromModifier) { callListenerOnFinishSlidingInput(); } } public void onShowMoreKeysPanel(final int translatedX, final int translatedY, Loading Loading @@ -1328,7 +1339,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { final int code = key.mCode; callListenerOnCodeInput(key, code, x, y, eventTime); callListenerOnRelease(key, code, false); callListenerOnRelease(key, code, false /* withSliding */); } private void printTouchEvent(final String title, final int x, final int y, Loading java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +21 −24 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import com.android.inputmethod.latin.RecapitalizeStatus; * * The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()}, * {@link #onPressKey(int,boolean,int)}, {@link #onReleaseKey(int,boolean)}, * {@link #onCodeInput(int, boolean, int)}, {@link #onCancelInput(boolean)}, * {@link #onCodeInput(int,int)}, {@link #onFinishSlidingInput()}, {@link #onCancelInput()}, * {@link #onUpdateShiftState(int,int)}, {@link #onLongPressTimeout(int)}. * * The actions are {@link SwitchActions}'s methods. Loading Loading @@ -74,6 +74,7 @@ public final class KeyboardState { private static final int SWITCH_STATE_SYMBOL = 2; private static final int SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL = 3; private static final int SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE = 4; private static final int SWITCH_STATE_MOMENTARY_ALPHA_SHIFT = 5; private int mSwitchState = SWITCH_STATE_ALPHA; private boolean mIsAlphabetMode; Loading Loading @@ -525,6 +526,9 @@ public final class KeyboardState { } else if (mAlphabetShiftState.isShiftLockShifted() && withSliding) { // In shift locked state, shift has been pressed and slid out to other key. setShiftLocked(true); } else if (mAlphabetShiftState.isManualShifted() && withSliding) { // Shift has been pressed and slid out to other key. mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_SHIFT; } else if (isShiftLocked && !mAlphabetShiftState.isShiftLockShifted() && (mShiftKeyState.isPressing() || mShiftKeyState.isPressingOnShifted()) && !withSliding) { Loading Loading @@ -554,17 +558,21 @@ public final class KeyboardState { mShiftKeyState.onRelease(); } public void onCancelInput(final boolean isSinglePointer) { public void onFinishSlidingInput() { if (DEBUG_EVENT) { Log.d(TAG, "onCancelInput: single=" + isSinglePointer + " " + this); Log.d(TAG, "onFinishSlidingInput: " + this); } // Switch back to the previous keyboard mode if the user cancels sliding input. if (isSinglePointer) { if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) { switch (mSwitchState) { case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: toggleAlphabetAndSymbols(); } else if (mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE) { break; case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: toggleShiftInSymbols(); } break; case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: setAlphabetKeyboard(); break; } } Loading @@ -577,10 +585,9 @@ public final class KeyboardState { return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER; } public void onCodeInput(final int code, final boolean isSinglePointer, final int autoCaps) { public void onCodeInput(final int code, final int autoCaps) { if (DEBUG_EVENT) { Log.d(TAG, "onCodeInput: code=" + Constants.printableCode(code) + " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this); } Loading @@ -593,23 +600,12 @@ public final class KeyboardState { } else { mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; } } else if (isSinglePointer) { // Switch back to the previous keyboard mode if the user pressed the mode change key // and slid to other key, then released the finger. // If the user cancels the sliding input, switching back to the previous keyboard // mode is handled by {@link #onCancelInput}. toggleAlphabetAndSymbols(); } break; case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: if (code == Constants.CODE_SHIFT) { // Detected only the shift key has been pressed on symbol layout, and then released. mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; } else if (isSinglePointer) { // Switch back to the previous keyboard mode if the user pressed the shift key on // symbol mode and slid to other key, then released the finger. toggleShiftInSymbols(); mSwitchState = SWITCH_STATE_SYMBOL; } break; case SWITCH_STATE_SYMBOL_BEGIN: Loading Loading @@ -650,6 +646,7 @@ public final class KeyboardState { case SWITCH_STATE_SYMBOL: return "SYMBOL"; case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: return "MOMENTARY-ALPHA-SYMBOL"; case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: return "MOMENTARY-SYMBOL-MORE"; case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: return "MOMENTARY-ALPHA_SHIFT"; default: return null; } } Loading Loading
java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java +10 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,9 @@ public interface KeyboardActionListener { * * @param primaryCode the unicode of the key being pressed. If the touch is not on a valid key, * the value will be zero. * @param isSinglePointer true if pressing has occurred while no other key is being pressed. */ public void onPressKey(int primaryCode); public void onPressKey(int primaryCode, boolean isSinglePointer); /** * Called when the user releases a key. This is sent after the {@link #onCodeInput} is called. Loading Loading @@ -87,6 +88,11 @@ public interface KeyboardActionListener { */ public void onCancelInput(); /** * Called when user finished sliding key input. */ public void onFinishSlidingInput(); /** * Send a non-"code input" custom request to the listener. * @return true if the request has been consumed, false otherwise. Loading @@ -97,7 +103,7 @@ public interface KeyboardActionListener { public static final Adapter EMPTY_LISTENER = new Adapter(); @Override public void onPressKey(int primaryCode) {} public void onPressKey(int primaryCode, boolean isSinglePointer) {} @Override public void onReleaseKey(int primaryCode, boolean withSliding) {} @Override Loading @@ -115,6 +121,8 @@ public interface KeyboardActionListener { @Override public void onCancelInput() {} @Override public void onFinishSlidingInput() {} @Override public boolean onCustomRequest(int requestCode) { return false; } Loading
java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +5 −9 Original line number Diff line number Diff line Loading @@ -216,19 +216,19 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { mState.onResetKeyboardStateToAlphabet(); } public void onPressKey(final int code) { public void onPressKey(final int code, final boolean isSinglePointer) { if (isVibrateAndSoundFeedbackRequired()) { mFeedbackManager.hapticAndAudioFeedback(code, mKeyboardView); } mState.onPressKey(code, isSinglePointer(), mLatinIME.getCurrentAutoCapsState()); mState.onPressKey(code, isSinglePointer, mLatinIME.getCurrentAutoCapsState()); } public void onReleaseKey(final int code, final boolean withSliding) { mState.onReleaseKey(code, withSliding); } public void onCancelInput() { mState.onCancelInput(isSinglePointer()); public void onFinishSlidingInput() { mState.onFinishSlidingInput(); } // Implements {@link KeyboardState.SwitchActions}. Loading Loading @@ -346,15 +346,11 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { return mKeyboardView != null && !mKeyboardView.isInSlidingKeyInput(); } private boolean isSinglePointer() { return mKeyboardView != null && mKeyboardView.getPointerCount() == 1; } /** * Updates state machine to figure out when to automatically switch back to the previous mode. */ public void onCodeInput(final int code) { mState.onCodeInput(code, isSinglePointer(), mLatinIME.getCurrentAutoCapsState()); mState.onCodeInput(code, mLatinIME.getCurrentAutoCapsState()); } public MainKeyboardView getMainKeyboardView() { Loading
java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +0 −4 Original line number Diff line number Diff line Loading @@ -1100,10 +1100,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack return false; } public int getPointerCount() { return mOldPointerCount; } @Override public boolean dispatchTouchEvent(MotionEvent event) { if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) { Loading
java/src/com/android/inputmethod/keyboard/PointerTracker.java +15 −4 Original line number Diff line number Diff line Loading @@ -459,7 +459,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { return false; } if (key.isEnabled()) { mListener.onPressKey(key.mCode); mListener.onPressKey(key.mCode, getActivePointerTrackerCount() == 1); final boolean keyboardLayoutHasBeenChanged = mKeyboardLayoutHasBeenChanged; mKeyboardLayoutHasBeenChanged = false; mTimerProxy.startTypingStateTimer(key); Loading Loading @@ -527,6 +527,13 @@ public final class PointerTracker implements PointerTrackerQueue.Element { } } private void callListenerOnFinishSlidingInput() { if (DEBUG_LISTENER) { Log.d(TAG, String.format("[%d] onFinishSlidingInput", mPointerId)); } mListener.onFinishSlidingInput(); } private void callListenerOnCancelInput() { if (DEBUG_LISTENER) { Log.d(TAG, String.format("[%d] onCancelInput", mPointerId)); Loading Loading @@ -1036,7 +1043,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private void processSildeOutFromOldKey(final Key oldKey) { setReleasedKeyGraphics(oldKey); callListenerOnRelease(oldKey, oldKey.mCode, true); callListenerOnRelease(oldKey, oldKey.mCode, true /* withSliding */); startSlidingKeyInput(oldKey); mTimerProxy.cancelKeyTimers(); } Loading Loading @@ -1169,6 +1176,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { private void onUpEventInternal(final int x, final int y, final long eventTime) { mTimerProxy.cancelKeyTimers(); final boolean isInSlidingKeyInput = mIsInSlidingKeyInput; final boolean isInSlidingKeyInputFromModifier = mIsInSlidingKeyInputFromModifier; resetSlidingKeyInput(); mIsDetectingGesture = false; final Key currentKey = mCurrentKey; Loading @@ -1189,7 +1197,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { if (sInGesture) { if (currentKey != null) { callListenerOnRelease(currentKey, currentKey.mCode, true); callListenerOnRelease(currentKey, currentKey.mCode, true /* withSliding */); } mayEndBatchInput(eventTime); return; Loading @@ -1203,6 +1211,9 @@ public final class PointerTracker implements PointerTrackerQueue.Element { return; } detectAndSendKey(currentKey, mKeyX, mKeyY, eventTime); if (isInSlidingKeyInputFromModifier) { callListenerOnFinishSlidingInput(); } } public void onShowMoreKeysPanel(final int translatedX, final int translatedY, Loading Loading @@ -1328,7 +1339,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element { final int code = key.mCode; callListenerOnCodeInput(key, code, x, y, eventTime); callListenerOnRelease(key, code, false); callListenerOnRelease(key, code, false /* withSliding */); } private void printTouchEvent(final String title, final int x, final int y, Loading
java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +21 −24 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ import com.android.inputmethod.latin.RecapitalizeStatus; * * The input events are {@link #onLoadKeyboard()}, {@link #onSaveKeyboardState()}, * {@link #onPressKey(int,boolean,int)}, {@link #onReleaseKey(int,boolean)}, * {@link #onCodeInput(int, boolean, int)}, {@link #onCancelInput(boolean)}, * {@link #onCodeInput(int,int)}, {@link #onFinishSlidingInput()}, {@link #onCancelInput()}, * {@link #onUpdateShiftState(int,int)}, {@link #onLongPressTimeout(int)}. * * The actions are {@link SwitchActions}'s methods. Loading Loading @@ -74,6 +74,7 @@ public final class KeyboardState { private static final int SWITCH_STATE_SYMBOL = 2; private static final int SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL = 3; private static final int SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE = 4; private static final int SWITCH_STATE_MOMENTARY_ALPHA_SHIFT = 5; private int mSwitchState = SWITCH_STATE_ALPHA; private boolean mIsAlphabetMode; Loading Loading @@ -525,6 +526,9 @@ public final class KeyboardState { } else if (mAlphabetShiftState.isShiftLockShifted() && withSliding) { // In shift locked state, shift has been pressed and slid out to other key. setShiftLocked(true); } else if (mAlphabetShiftState.isManualShifted() && withSliding) { // Shift has been pressed and slid out to other key. mSwitchState = SWITCH_STATE_MOMENTARY_ALPHA_SHIFT; } else if (isShiftLocked && !mAlphabetShiftState.isShiftLockShifted() && (mShiftKeyState.isPressing() || mShiftKeyState.isPressingOnShifted()) && !withSliding) { Loading Loading @@ -554,17 +558,21 @@ public final class KeyboardState { mShiftKeyState.onRelease(); } public void onCancelInput(final boolean isSinglePointer) { public void onFinishSlidingInput() { if (DEBUG_EVENT) { Log.d(TAG, "onCancelInput: single=" + isSinglePointer + " " + this); Log.d(TAG, "onFinishSlidingInput: " + this); } // Switch back to the previous keyboard mode if the user cancels sliding input. if (isSinglePointer) { if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) { switch (mSwitchState) { case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: toggleAlphabetAndSymbols(); } else if (mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE) { break; case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: toggleShiftInSymbols(); } break; case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: setAlphabetKeyboard(); break; } } Loading @@ -577,10 +585,9 @@ public final class KeyboardState { return c == Constants.CODE_SPACE || c == Constants.CODE_ENTER; } public void onCodeInput(final int code, final boolean isSinglePointer, final int autoCaps) { public void onCodeInput(final int code, final int autoCaps) { if (DEBUG_EVENT) { Log.d(TAG, "onCodeInput: code=" + Constants.printableCode(code) + " single=" + isSinglePointer + " autoCaps=" + autoCaps + " " + this); } Loading @@ -593,23 +600,12 @@ public final class KeyboardState { } else { mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; } } else if (isSinglePointer) { // Switch back to the previous keyboard mode if the user pressed the mode change key // and slid to other key, then released the finger. // If the user cancels the sliding input, switching back to the previous keyboard // mode is handled by {@link #onCancelInput}. toggleAlphabetAndSymbols(); } break; case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: if (code == Constants.CODE_SHIFT) { // Detected only the shift key has been pressed on symbol layout, and then released. mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; } else if (isSinglePointer) { // Switch back to the previous keyboard mode if the user pressed the shift key on // symbol mode and slid to other key, then released the finger. toggleShiftInSymbols(); mSwitchState = SWITCH_STATE_SYMBOL; } break; case SWITCH_STATE_SYMBOL_BEGIN: Loading Loading @@ -650,6 +646,7 @@ public final class KeyboardState { case SWITCH_STATE_SYMBOL: return "SYMBOL"; case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: return "MOMENTARY-ALPHA-SYMBOL"; case SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE: return "MOMENTARY-SYMBOL-MORE"; case SWITCH_STATE_MOMENTARY_ALPHA_SHIFT: return "MOMENTARY-ALPHA_SHIFT"; default: return null; } } Loading