diff options
author | 2011-12-26 23:40:09 +0900 | |
---|---|---|
committer | 2012-01-10 15:13:05 +0900 | |
commit | ee4be6e3c6eed719683fd3019d48365ba76790e2 (patch) | |
tree | 674c5753ad538d65d27d454bc3efc3b61a58333c /java/src | |
parent | 8edd3067181a425ce1383bb950184f9742af7557 (diff) | |
download | latinime-ee4be6e3c6eed719683fd3019d48365ba76790e2.tar.gz latinime-ee4be6e3c6eed719683fd3019d48365ba76790e2.tar.xz latinime-ee4be6e3c6eed719683fd3019d48365ba76790e2.zip |
Call KeyboardState.onUpdateShiftState from onCodeInput if code is a normal letter
This will be helpful to write unit test code.
Change-Id: Ib61cc46ac547084e0dc9ecd3a50814fecf08ace2
Diffstat (limited to 'java/src')
4 files changed, 26 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 3540577ca..fad12cc1f 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -67,7 +67,9 @@ import java.util.Set; public class Keyboard { private static final String TAG = Keyboard.class.getSimpleName(); - /** Some common keys code. These should be aligned with values/keycodes.xml */ + /** Some common keys code. Must be positive. + * These should be aligned with values/keycodes.xml + */ public static final int CODE_ENTER = '\n'; public static final int CODE_TAB = '\t'; public static final int CODE_SPACE = ' '; @@ -85,7 +87,9 @@ public class Keyboard { public static final int CODE_DIGIT0 = '0'; public static final int CODE_PLUS = '+'; - /** Special keys code. These should be aligned with values/keycodes.xml */ + /** Special keys code. Must be non-positive. + * These should be aligned with values/keycodes.xml + */ public static final int CODE_DUMMY = 0; public static final int CODE_SHIFT = -1; public static final int CODE_SWITCH_ALPHA_SYMBOL = -2; @@ -248,6 +252,10 @@ public class Keyboard { return label; } + public static boolean isLetterCode(int code) { + return code > CODE_DUMMY; + } + public static class Params { public KeyboardId mId; public int mThemeId; diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index fa073b671..e5097152b 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -332,7 +332,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, * Updates state machine to figure out when to automatically snap back to the previous mode. */ public void onCodeInput(int code) { - mState.onCodeInput(code, isSinglePointer()); + mState.onCodeInput(code, isSinglePointer(), mInputMethodService.getCurrentAutoCapsState()); } public LatinKeyboardView getKeyboardView() { diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index 623cab303..c0adf970a 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -29,9 +29,10 @@ import com.android.inputmethod.keyboard.Keyboard; * * The input events are {@link #onLoadKeyboard(String, boolean)}, {@link #onSaveKeyboardState()}, * {@link #onPressShift(boolean)}, {@link #onReleaseShift(boolean)}, {@link #onPressSymbol()}, - * {@link #onReleaseSymbol()}, {@link #onOtherKeyPressed()}, {@link #onCodeInput(int, boolean)}, - * {@link #onCancelInput(boolean)}, {@link #onUpdateShiftState(boolean)}, {@link #onToggleShift()}, - * {@link #onToggleCapsLock()}, and {@link #onToggleAlphabetAndSymbols()}. + * {@link #onReleaseSymbol()}, {@link #onOtherKeyPressed()}, + * {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)}, + * {@link #onUpdateShiftState(boolean)}, {@link #onToggleShift()}, {@link #onToggleCapsLock()}, + * and {@link #onToggleAlphabetAndSymbols()}. * * The actions are {@link SwitchActions}'s methods. */ @@ -267,6 +268,10 @@ public class KeyboardState { if (DEBUG_STATE) { Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + " " + this); } + onUpdateShiftStateInternal(autoCaps); + } + + private void onUpdateShiftStateInternal(boolean autoCaps) { if (mIsAlphabetMode) { if (!mKeyboardShiftState.isShiftLocked() && !mShiftKeyState.isIgnoring()) { if (mShiftKeyState.isReleasing() && autoCaps) { @@ -381,10 +386,10 @@ public class KeyboardState { return false; } - public void onCodeInput(int code, boolean isSinglePointer) { + public void onCodeInput(int code, boolean isSinglePointer, boolean autoCaps) { if (DEBUG_STATE) { Log.d(TAG, "onCodeInput: code=" + code + " isSinglePointer=" + isSinglePointer - + " " + this); + + " autoCaps=" + autoCaps + " " + this); } switch (mSwitchState) { case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: @@ -446,6 +451,11 @@ public class KeyboardState { } break; } + + // If the code is a letter, update keyboard shift state. + if (Keyboard.isLetterCode(code)) { + onUpdateShiftStateInternal(autoCaps); + } } public void onToggleShift() { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d2b1e9bca..e6478b683 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1496,7 +1496,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (null != ic) swapSwapperAndSpaceWhileInBatchEdit(ic); } - switcher.updateShiftState(); if (mSettingsValues.isWordSeparator(code)) { Utils.Stats.onSeparator((char)code, x, y); } else { @@ -1581,7 +1580,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar Utils.Stats.onSeparator((char)primaryCode, x, y); - mKeyboardSwitcher.updateShiftState(); if (ic != null) { ic.endBatchEdit(); } |