diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java | 5 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java | 48 |
2 files changed, 24 insertions, 29 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 22ab3e4e5..4967a5e80 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -137,8 +137,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, mKeyboardSet = builder.build(); final KeyboardId mainKeyboardId = mKeyboardSet.getMainKeyboardId(); try { - mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols), - hasDistinctMultitouch()); + mState.onLoadKeyboard(mResources.getString(R.string.layout_switch_back_symbols)); } catch (RuntimeException e) { Log.w(TAG, "loading keyboard failed: " + mainKeyboardId, e); LatinImeLogger.logOnException(mainKeyboardId.toString(), e); @@ -316,7 +315,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, } /** - * Updates state machine to figure out when to automatically snap back to the previous mode. + * Updates state machine to figure out when to automatically switch back to the previous mode. */ public void onCodeInput(int code) { mState.onCodeInput(code, isSinglePointer(), mInputMethodService.getCurrentAutoCapsState()); diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index c43b9852b..3e7089619 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -26,7 +26,7 @@ import com.android.inputmethod.keyboard.Keyboard; * * This class contains all keyboard state transition logic. * - * The input events are {@link #onLoadKeyboard(String, boolean)}, {@link #onSaveKeyboardState()}, + * The input events are {@link #onLoadKeyboard(String)}, {@link #onSaveKeyboardState()}, * {@link #onPressKey(int)}, {@link #onReleaseKey(int, boolean)}, * {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)}, * {@link #onUpdateShiftState(boolean)}. @@ -74,7 +74,6 @@ public class KeyboardState { private int mSwitchState = SWITCH_STATE_ALPHA; private String mLayoutSwitchBackSymbols; - private boolean mHasDistinctMultitouch; private final SwitchActions mSwitchActions; @@ -95,12 +94,11 @@ public class KeyboardState { mSwitchActions = switchActions; } - public void onLoadKeyboard(String layoutSwitchBackSymbols, boolean hasDistinctMultitouch) { + public void onLoadKeyboard(String layoutSwitchBackSymbols) { if (DEBUG_EVENT) { Log.d(TAG, "onLoadKeyboard"); } mLayoutSwitchBackSymbols = layoutSwitchBackSymbols; - mHasDistinctMultitouch = hasDistinctMultitouch; mKeyboardShiftState.setShifted(false); mKeyboardShiftState.setShiftLocked(false); mShiftKeyState.onRelease(); @@ -164,18 +162,16 @@ public class KeyboardState { if (DEBUG_ACTION) { Log.d(TAG, "setShifted: shiftMode=" + shiftModeToString(shiftMode)); } - if (shiftMode == SwitchActions.AUTOMATIC_SHIFT) { + switch (shiftMode) { + case SwitchActions.AUTOMATIC_SHIFT: mKeyboardShiftState.setAutomaticTemporaryUpperCase(); - } else { - final boolean shifted = (shiftMode == SwitchActions.MANUAL_SHIFT); - // On non-distinct multi touch panel device, we should also turn off the shift locked - // state when shift key is pressed to go to normal mode. - // On the other hand, on distinct multi touch panel device, turning off the shift - // locked state with shift key pressing is handled by onReleaseShift(). - if (!mHasDistinctMultitouch && !shifted && mKeyboardShiftState.isShiftLocked()) { - mSwitchActions.setShiftLocked(false); - } - mKeyboardShiftState.setShifted(shifted); + break; + case SwitchActions.MANUAL_SHIFT: + mKeyboardShiftState.setShifted(true); + break; + case SwitchActions.UNSHIFT: + mKeyboardShiftState.setShifted(false); + break; } mSwitchActions.setShifted(shiftMode); } @@ -273,7 +269,7 @@ public class KeyboardState { } private void onReleaseSymbol() { - // Snap back to the previous keyboard mode if the user chords the mode change key and + // Switch back to the previous keyboard mode if the user chords the mode change key and // another key, then releases the mode change key. if (mSwitchState == SWITCH_STATE_CHORDING_ALPHA) { toggleAlphabetAndSymbols(); @@ -359,8 +355,8 @@ public class KeyboardState { setShifted(SwitchActions.UNSHIFT); } } else { - // In symbol mode, snap back to the previous keyboard mode if the user chords the shift - // key and another key, then releases the shift key. + // In symbol mode, switch back to the previous keyboard mode if the user chords the + // shift key and another key, then releases the shift key. if (mSwitchState == SWITCH_STATE_CHORDING_SYMBOL) { toggleShiftInSymbols(); } @@ -372,7 +368,7 @@ public class KeyboardState { if (DEBUG_EVENT) { Log.d(TAG, "onCancelInput: single=" + isSinglePointer + " " + this); } - // Snap back to the previous keyboard mode if the user cancels sliding input. + // Switch back to the previous keyboard mode if the user cancels sliding input. if (isSinglePointer) { if (mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL) { toggleAlphabetAndSymbols(); @@ -431,13 +427,13 @@ public class KeyboardState { mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; } } else if (isSinglePointer) { - // Snap back to the previous keyboard mode if the user pressed the mode change key + // 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, snapping back to the previous keyboard + // If the user cancels the sliding input, switching back to the previous keyboard // mode is handled by {@link #onCancelInput}. toggleAlphabetAndSymbols(); } else { - // Chording input is being started. The keyboard mode will be snapped back to the + // Chording input is being started. The keyboard mode will be switched back to the // previous mode in {@link onReleaseSymbol} when the mode change key is released. mSwitchState = SWITCH_STATE_CHORDING_ALPHA; } @@ -447,12 +443,12 @@ public class KeyboardState { // Detected only the shift key has been pressed on symbol layout, and then released. mSwitchState = SWITCH_STATE_SYMBOL_BEGIN; } else if (isSinglePointer) { - // Snap back to the previous keyboard mode if the user pressed the shift key on + // 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; } else { - // Chording input is being started. The keyboard mode will be snapped back to the + // Chording input is being started. The keyboard mode will be switched back to the // previous mode in {@link onReleaseShift} when the shift key is released. mSwitchState = SWITCH_STATE_CHORDING_SYMBOL; } @@ -462,14 +458,14 @@ public class KeyboardState { || code == Keyboard.CODE_OUTPUT_TEXT)) { mSwitchState = SWITCH_STATE_SYMBOL; } - // Snap back to alpha keyboard mode immediately if user types a quote character. + // Switch back to alpha keyboard mode immediately if user types a quote character. if (isLayoutSwitchBackCharacter(code)) { setAlphabetKeyboard(); } break; case SWITCH_STATE_SYMBOL: case SWITCH_STATE_CHORDING_SYMBOL: - // Snap back to alpha keyboard mode if user types one or more non-space/enter + // Switch back to alpha keyboard mode if user types one or more non-space/enter // characters followed by a space/enter or a quote character. if (isSpaceCharacter(code) || isLayoutSwitchBackCharacter(code)) { setAlphabetKeyboard(); |