diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index dcb114682..f284f0d65 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -894,29 +894,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (((mWordComposer.isComposingWord()) || mVoiceProxy.isVoiceInputHighlighted()) && (selectionChanged || noComposingSpan)) { - resetComposingState(true /* alsoResetLastComposedWord */); - updateSuggestions(); - final InputConnection ic = getCurrentInputConnection(); - if (ic != null) { - ic.finishComposingText(); - } - mComposingStateManager.onFinishComposingText(); - mVoiceProxy.setVoiceInputHighlighted(false); + resetEntireInputState(); } else if (!mWordComposer.isComposingWord()) { - // We need to do this to clear the last composed word. - resetComposingState(true /* alsoResetLastComposedWord */); - updateSuggestions(); - // Calling finishComposingText() here is harmless because there - // is no composing word, so it's a no-op. - final InputConnection ic = getCurrentInputConnection(); - if (ic != null) { - ic.finishComposingText(); - } - // Likewise, this is a no-op since we are not composing text - mComposingStateManager.onFinishComposingText(); - // The cursor moved so it's safe to assume that the voice input - // is not highlighted - mVoiceProxy.setVoiceInputHighlighted(false); + resetEntireInputState(); } mHandler.postUpdateShiftState(); @@ -1126,6 +1106,20 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return super.onKeyUp(keyCode, event); } + // This will reset the whole input state to the starting state. It will clear + // the composing word, reset the last composed word, tell the inputconnection + // and the composingStateManager about it. + private void resetEntireInputState() { + resetComposingState(true /* alsoResetLastComposedWord */); + updateSuggestions(); + final InputConnection ic = getCurrentInputConnection(); + if (ic != null) { + ic.finishComposingText(); + } + mComposingStateManager.onFinishComposingText(); + mVoiceProxy.setVoiceInputHighlighted(false); + } + private void resetComposingState(final boolean alsoResetLastComposedWord) { mWordComposer.reset(); if (alsoResetLastComposedWord) |