diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/inputlogic')
-rw-r--r-- | java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java | 15 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java | 6 |
2 files changed, 11 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 4c7dc6499..ec6bd289a 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -130,7 +130,11 @@ public final class InputLogic { // so we try using some heuristics to find out about these and fix them. mConnection.tryFixLyingCursorPosition(); cancelDoubleSpacePeriodCountdown(); - mInputLogicHandler = new InputLogicHandler(mLatinIME, this); + if (InputLogicHandler.NULL_HANDLER == mInputLogicHandler) { + mInputLogicHandler = new InputLogicHandler(mLatinIME, this); + } else { + mInputLogicHandler.reset(); + } } /** @@ -141,8 +145,7 @@ public final class InputLogic { mConnection.finishComposingText(); } resetComposingState(true /* alsoResetLastComposedWord */); - mInputLogicHandler.destroy(); - mInputLogicHandler = InputLogicHandler.NULL_HANDLER; + mInputLogicHandler.reset(); } /** @@ -513,14 +516,12 @@ public final class InputLogic { mWordComposer); } } - final int wordComposerSize = mWordComposer.size(); - // Since isComposingWord() is true, the size is at least 1. if (mWordComposer.isCursorFrontOrMiddleOfComposingWord()) { // If we are in the middle of a recorrection, we need to commit the recorrection // first so that we can insert the batch input at the current cursor position. resetEntireInputState(mConnection.getExpectedSelectionStart(), mConnection.getExpectedSelectionEnd(), true /* clearSuggestionStrip */); - } else if (wordComposerSize <= 1) { + } else if (mWordComposer.isSingleLetter()) { // We auto-correct the previous (typed, not gestured) string iff it's one character // long. The reason for this is, even in the middle of gesture typing, you'll still // tap one-letter words and you want them auto-corrected (typically, "i" in English @@ -738,7 +739,7 @@ public final class InputLogic { if (isComposingWord) { mWordComposer.add(inputTransaction.mEvent); // If it's the first letter, make note of auto-caps state - if (mWordComposer.size() == 1) { + if (mWordComposer.isSingleLetter()) { // We pass 1 to getPreviousWordForSuggestion because we were not composing a word // yet, so the word we want is the 1st word before the cursor. mWordComposer.setCapitalizedModeAndPreviousWordAtStartComposingTime( diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java index db96de305..42f0d7c00 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java @@ -43,7 +43,7 @@ class InputLogicHandler implements Handler.Callback { // is initialized, though probably only the monkey can actually do this. public static final InputLogicHandler NULL_HANDLER = new InputLogicHandler() { @Override - public void destroy() {} + public void reset() {} @Override public boolean handleMessage(final Message msg) { return true; } @Override @@ -75,8 +75,8 @@ class InputLogicHandler implements Handler.Callback { mInputLogic = inputLogic; } - public void destroy() { - mNonUIThreadHandler.getLooper().quit(); + public void reset() { + mNonUIThreadHandler.removeCallbacksAndMessages(null); } /** |