From dc1b84d96cf7fc4ee21cf7df8a12bc7913ffd64e Mon Sep 17 00:00:00 2001 From: Jean Chalard <jchalard@google.com> Date: Fri, 6 Jul 2012 12:15:45 +0900 Subject: [PATCH] Defer testing composition to a later time (A70) This is not exactly the same logically speaking, because it's theoretically possible that the composing state changed in between the message enqueueing and it's retrieval. However in the practice, if the composing state changed the message *must* have been cancelled and resent, else the behavior breaks. So this actually is more robust, and removes some obscure requirements on the calling code. In the practice, it should also make the cancelUpdateSuggestionStrip message useless, although this change does not yet remove it. Change-Id: I75141920ce64e38e2f92e9c02b6c979936eee9a9 --- .../android/inputmethod/latin/LatinIME.java | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index c8fdbca5e8..20f6a8d71e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -177,9 +177,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public static class UIHandler extends StaticInnerHandlerWrapper<LatinIME> { private static final int MSG_UPDATE_SHIFT_STATE = 1; - private static final int MSG_SET_BIGRAM_PREDICTIONS = 5; private static final int MSG_PENDING_IMS_CALLBACK = 6; - private static final int MSG_UPDATE_SUGGESTIONS = 7; + private static final int MSG_UPDATE_SUGGESTION_STRIP = 7; private int mDelayUpdateSuggestions; private int mDelayUpdateShiftState; @@ -205,35 +204,26 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final LatinIME latinIme = getOuterInstance(); final KeyboardSwitcher switcher = latinIme.mKeyboardSwitcher; switch (msg.what) { - case MSG_UPDATE_SUGGESTIONS: - latinIme.updateSuggestionsOrPredictions(false /* isPredictions */); + case MSG_UPDATE_SUGGESTION_STRIP: + latinIme.updateSuggestionsOrPredictions( + !getOuterInstance().mWordComposer.isComposingWord()); break; case MSG_UPDATE_SHIFT_STATE: switcher.updateShiftState(); break; - case MSG_SET_BIGRAM_PREDICTIONS: - latinIme.updateSuggestionsOrPredictions(true /* isPredictions */); - break; } } public void postUpdateSuggestionStrip() { - cancelUpdateSuggestionStrip(); - if (getOuterInstance().mWordComposer.isComposingWord()) { - sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTIONS), mDelayUpdateSuggestions); - } else { - sendMessageDelayed(obtainMessage(MSG_SET_BIGRAM_PREDICTIONS), - mDelayUpdateSuggestions); - } + sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTION_STRIP), mDelayUpdateSuggestions); } public void cancelUpdateSuggestionStrip() { - removeMessages(MSG_UPDATE_SUGGESTIONS); - removeMessages(MSG_SET_BIGRAM_PREDICTIONS); + removeMessages(MSG_UPDATE_SUGGESTION_STRIP); } public boolean hasPendingUpdateSuggestions() { - return hasMessages(MSG_UPDATE_SUGGESTIONS); + return hasMessages(MSG_UPDATE_SUGGESTION_STRIP); } public void postUpdateShiftState() { -- GitLab