From 6c92ee127df50509d364a2b6d428b223d2cbaa6e Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 16 Nov 2010 00:28:50 -0800 Subject: [PATCH] Refactor symbol key state into KeyboardSwitcher Change-Id: Idce4e9bf070b08b8a930fd8e800df9c4d8829f8f --- .../inputmethod/latin/KeyboardSwitcher.java | 18 ++++++++++++++++++ .../android/inputmethod/latin/LatinIME.java | 9 ++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java index fa3cf2224..fdcf0ad4e 100644 --- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java @@ -75,6 +75,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha private final LatinIME mInputMethodService; private final LanguageSwitcher mLanguageSwitcher; + private ModifierKeyState mSymbolKeyState = new ModifierKeyState(); private KeyboardId mSymbolsId; private KeyboardId mSymbolsShiftedId; @@ -382,6 +383,23 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mInputView.setShiftLocked(shiftLocked); } + public void onPressSymbol() { + mSymbolKeyState.onPress(); + } + + public void onReleaseSymbol() { + mSymbolKeyState.onRelease(); + } + + public boolean isSymbolMomentary() { + return mSymbolKeyState.isMomentary(); + } + + public void onOtherKeyPressed() { + // TODO: shift key state will be handled too. + mSymbolKeyState.onOtherKeyPressed(); + } + public void toggleShift() { if (isAlphabetMode()) return; diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b3ac17b07..c18174b57 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -241,7 +241,6 @@ public class LatinIME extends InputMethodService // Modifier keys state private final ModifierKeyState mShiftKeyState = new ModifierKeyState(); - private final ModifierKeyState mSymbolKeyState = new ModifierKeyState(); private Tutorial mTutorial; @@ -2323,11 +2322,11 @@ public class LatinIME extends InputMethodService handleShift(); } } else if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_MODE_CHANGE) { - mSymbolKeyState.onPress(); + switcher.onPressSymbol(); changeKeyboardMode(); } else { mShiftKeyState.onOtherKeyPressed(); - mSymbolKeyState.onOtherKeyPressed(); + switcher.onOtherKeyPressed(); } } @@ -2352,10 +2351,10 @@ public class LatinIME extends InputMethodService } mShiftKeyState.onRelease(); } else if (distinctMultiTouch && primaryCode == BaseKeyboard.KEYCODE_MODE_CHANGE) { - if (mSymbolKeyState.isMomentary()) { + if (switcher.isSymbolMomentary()) { changeKeyboardMode(); } - mSymbolKeyState.onRelease(); + switcher.onReleaseSymbol(); } }