diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index fe6ad4901..c0938cf97 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1219,22 +1219,25 @@ public final class LatinIME extends InputMethodService implements KeyboardAction mConnection.performEditorAction(actionId); } + // TODO: Revise the language switch key behavior to make it much smarter and more reasonable. private void handleLanguageSwitchKey() { - final boolean includesOtherImes = mCurrentSettings.mIncludesOtherImesInLanguageSwitchList; final IBinder token = getWindow().getWindow().getAttributes().token; + if (mCurrentSettings.mIncludesOtherImesInLanguageSwitchList) { + mImm.switchToNextInputMethod(token, false /* onlyCurrentIme */); + return; + } if (mShouldSwitchToLastSubtype) { final InputMethodSubtype lastSubtype = mImm.getLastInputMethodSubtype(); final boolean lastSubtypeBelongsToThisIme = ImfUtils.checkIfSubtypeBelongsToThisImeAndEnabled(this, lastSubtype); - if ((includesOtherImes || lastSubtypeBelongsToThisIme) - && mImm.switchToLastInputMethod(token)) { + if (lastSubtypeBelongsToThisIme && mImm.switchToLastInputMethod(token)) { mShouldSwitchToLastSubtype = false; } else { - mImm.switchToNextInputMethod(token, !includesOtherImes); + mImm.switchToNextInputMethod(token, true /* onlyCurrentIme */); mShouldSwitchToLastSubtype = true; } } else { - mImm.switchToNextInputMethod(token, !includesOtherImes); + mImm.switchToNextInputMethod(token, true /* onlyCurrentIme */); } } @@ -1515,8 +1518,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords, final boolean dismissGestureFloatingPreviewText) { - final String batchInputText = (suggestedWords.size() > 0) - ? suggestedWords.getWord(0) : null; + final String batchInputText = suggestedWords.isEmpty() + ? null : suggestedWords.getWord(0); final KeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); mainKeyboardView.showGestureFloatingPreviewText(batchInputText); showSuggestionStrip(suggestedWords, null); @@ -1534,8 +1537,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction public void onEndBatchInput(final InputPointers batchPointers) { final SuggestedWords suggestedWords = BatchInputUpdater.getInstance().onEndBatchInput( batchPointers, this); - final String batchInputText = (suggestedWords.size() > 0) - ? suggestedWords.getWord(0) : null; + final String batchInputText = suggestedWords.isEmpty() + ? null : suggestedWords.getWord(0); if (TextUtils.isEmpty(batchInputText)) { return; } @@ -1960,19 +1963,15 @@ public final class LatinIME extends InputMethodService implements KeyboardAction private void showSuggestionStrip(final SuggestedWords suggestedWords, final CharSequence typedWord) { - if (null == suggestedWords || suggestedWords.size() <= 0) { + if (suggestedWords.isEmpty()) { clearSuggestionStrip(); return; } final CharSequence autoCorrection; - if (suggestedWords.size() > 0) { - if (suggestedWords.mWillAutoCorrect) { - autoCorrection = suggestedWords.getWord(1); - } else { - autoCorrection = typedWord; - } + if (suggestedWords.mWillAutoCorrect) { + autoCorrection = suggestedWords.getWord(1); } else { - autoCorrection = null; + autoCorrection = typedWord; } mWordComposer.setAutoCorrection(autoCorrection); final boolean isAutoCorrection = suggestedWords.willAutoCorrect(); |