diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 9a800ba38..307021a37 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -462,7 +462,7 @@ public class LatinIME extends InputMethodService private void initSuggest() { updateAutoTextEnabled(); - String locale = mSubtypeSwitcher.getInputLanguage(); + String locale = mSubtypeSwitcher.getInputLocaleStr(); Resources orig = getResources(); Locale savedLocale = mSubtypeSwitcher.changeSystemLocale(new Locale(locale)); @@ -519,6 +519,7 @@ public class LatinIME extends InputMethodService @Override public void onConfigurationChanged(Configuration conf) { mSubtypeSwitcher.onConfigurationChanged(conf); + onLanguageChanged(); updateAutoTextEnabled(); // If orientation changed while predicting, commit the change @@ -577,9 +578,11 @@ public class LatinIME extends InputMethodService return; } + SubtypeSwitcher.getInstance().updateParametersOnStartInputView(); + if (mRefreshKeyboardRequired) { mRefreshKeyboardRequired = false; - toggleLanguage(true, true); + onLanguageChanged(); } TextEntryState.newSession(this); @@ -1001,7 +1004,8 @@ public class LatinIME extends InputMethodService return true; } // Enable shift key and DPAD to do selections - if (mKeyboardSwitcher.isInputViewShown() && mKeyboardSwitcher.isShifted()) { + if (mKeyboardSwitcher.isInputViewShown() + && mKeyboardSwitcher.isShiftedOrShiftLocked()) { event = new KeyEvent(event.getDownTime(), event.getEventTime(), event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getDeviceId(), event.getScanCode(), @@ -1370,7 +1374,7 @@ public class LatinIME extends InputMethodService } } KeyboardSwitcher switcher = mKeyboardSwitcher; - if (switcher.isShifted()) { + if (switcher.isShiftedOrShiftLocked()) { if (keyCodes == null || keyCodes[0] < Character.MIN_CODE_POINT || keyCodes[0] > Character.MAX_CODE_POINT) { return; @@ -1389,7 +1393,8 @@ public class LatinIME extends InputMethodService } } if (mPredicting) { - if (mComposing.length() == 0 && switcher.isAlphabetMode() && switcher.isShifted()) { + if (mComposing.length() == 0 && switcher.isAlphabetMode() + && switcher.isShiftedOrShiftLocked()) { mWord.setFirstCharCapitalized(true); } mComposing.append((char) primaryCode); @@ -1674,7 +1679,7 @@ public class LatinIME extends InputMethodService final List<CharSequence> nBest = new ArrayList<CharSequence>(); KeyboardSwitcher switcher = mKeyboardSwitcher; boolean capitalizeFirstWord = preferCapitalization() - || (switcher.isAlphabetMode() && switcher.isShifted()); + || (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked()); for (String c : mVoiceResults.candidates) { if (capitalizeFirstWord) { c = Character.toUpperCase(c.charAt(0)) + c.substring(1, c.length()); @@ -2176,8 +2181,18 @@ public class LatinIME extends InputMethodService return mWord.isFirstCharCapitalized(); } + // Notify that Language has been changed and toggleLanguage will update KeyboaredID according + // to new Language. + private void onLanguageChanged() { + toggleLanguage(true, true); + } + + // "reset" and "next" are used only for USE_SPACEBAR_LANGUAGE_SWITCHER. private void toggleLanguage(boolean reset, boolean next) { - mSubtypeSwitcher.toggleLanguage(reset, next); + if (SubtypeSwitcher.USE_SPACEBAR_LANGUAGE_SWITCHER) { + mSubtypeSwitcher.toggleLanguage(reset, next); + } + // Reload keyboard because the current language has been changed. KeyboardSwitcher switcher = mKeyboardSwitcher; final int mode = switcher.getKeyboardMode(); final EditorInfo attribute = getCurrentInputEditorInfo(); @@ -2249,7 +2264,7 @@ public class LatinIME extends InputMethodService return new FieldContext( getCurrentInputConnection(), getCurrentInputEditorInfo(), - mSubtypeSwitcher.getInputLanguage(), + mSubtypeSwitcher.getInputLocaleStr(), mSubtypeSwitcher.getEnabledLanguages()); } @@ -2372,7 +2387,7 @@ public class LatinIME extends InputMethodService private void updateAutoTextEnabled() { if (mSuggest == null) return; mSuggest.setAutoTextEnabled(mQuickFixes - && SubtypeSwitcher.getInstance().isSystemLocaleSameAsInputLocale()); + && SubtypeSwitcher.getInstance().isSystemLanguageSameAsInputLanguage()); } private void updateSuggestionVisibility(SharedPreferences prefs) { @@ -2419,7 +2434,7 @@ public class LatinIME extends InputMethodService sp.getBoolean(PREF_HAS_USED_VOICE_INPUT_UNSUPPORTED_LOCALE, false); mLocaleSupportedForVoiceInput = SubtypeSwitcher.getInstance().isVoiceSupported( - SubtypeSwitcher.getInstance().getInputLanguage()); + SubtypeSwitcher.getInstance().getInputLocaleStr()); mAutoCorrectEnabled = isAutoCorrectEnabled(sp); mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(sp); @@ -2580,6 +2595,7 @@ public class LatinIME extends InputMethodService @Override public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype) { - SubtypeSwitcher.getInstance().onCurrentInputMethodSubtypeChanged(subtype); + SubtypeSwitcher.getInstance().updateSubtype(subtype); + onLanguageChanged(); } } |