aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-02-19 18:08:40 -0800
committerJean Chalard <jchalard@google.com>2012-02-21 15:12:01 -0800
commit2649e42d756132ad763d6db5f9de1f901bbefd06 (patch)
tree902fcf3cb7cce2ba4d18c6bfc6cce691864a9d4c /java/src
parent5eeff7cf547e3694315473a91bed0d5afdc5709e (diff)
downloadlatinime-2649e42d756132ad763d6db5f9de1f901bbefd06.tar.gz
latinime-2649e42d756132ad763d6db5f9de1f901bbefd06.tar.xz
latinime-2649e42d756132ad763d6db5f9de1f901bbefd06.zip
Extract a method to reset the ime state
Change-Id: I921184b85b94418cf360508ee3f67e85b10b3d72
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java38
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)