diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 66 |
1 files changed, 25 insertions, 41 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 944fa73c8..e8ea5e39d 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -193,9 +193,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (msg.arg2 == ARG2_WITH_TYPED_WORD) { final Pair<SuggestedWords, String> p = (Pair<SuggestedWords, String>) msg.obj; - latinIme.showSuggestionStripWithTypedWord(p.first, p.second); + // [IL]: this is the only place where the second arg is not + // suggestedWords.mTypedWord. + latinIme.showSuggestionStrip(p.first, p.second); } else { - latinIme.showSuggestionStrip((SuggestedWords) msg.obj); + final SuggestedWords suggestedWords = (SuggestedWords) msg.obj; + latinIme.showSuggestionStrip(suggestedWords, suggestedWords.mTypedWord); } } else { latinIme.showGesturePreviewAndSuggestionStrip((SuggestedWords) msg.obj, @@ -1020,17 +1023,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void setSuggestionStripShownInternal(final boolean shown, final boolean needsInputViewShown) { // TODO: Modify this if we support suggestions with hard keyboard - if (onEvaluateInputViewShown() && mSuggestionStripView != null) { - final boolean inputViewShown = mKeyboardSwitcher.isShowingMainKeyboardOrEmojiPalettes(); - final boolean shouldShowSuggestions = shown - && (needsInputViewShown ? inputViewShown : true); - if (isFullscreenMode()) { - mSuggestionStripView.setVisibility( - shouldShowSuggestions ? View.VISIBLE : View.GONE); - } else { - mSuggestionStripView.setVisibility( - shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE); - } + if (!onEvaluateInputViewShown() || null == mSuggestionStripView) { + return; + } + final boolean inputViewShown = mKeyboardSwitcher.isShowingMainKeyboardOrEmojiPalettes(); + final boolean shouldShowSuggestions = shown + && (needsInputViewShown ? inputViewShown : true); + if (shouldShowSuggestions) { + mSuggestionStripView.setVisibility(View.VISIBLE); + } else { + mSuggestionStripView.setVisibility(isFullscreenMode() ? View.GONE : View.INVISIBLE); } } @@ -1271,7 +1273,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // This method must run on the UI Thread. private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords, final boolean dismissGestureFloatingPreviewText) { - showSuggestionStrip(suggestedWords); + showSuggestionStrip(suggestedWords, suggestedWords.mTypedWord); final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); mainKeyboardView.showGestureFloatingPreviewText(suggestedWords); if (dismissGestureFloatingPreviewText) { @@ -1325,27 +1327,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } // TODO[IL]: Define a clear interface for this - public void setSuggestedWords(final SuggestedWords words, final boolean shouldShow) { + public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow) { + mInputLogic.setSuggestedWords(suggestedWords); if (mSuggestionStripView != null) { - mSuggestionStripView.setSuggestions( - words, SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype())); - mKeyboardSwitcher.onAutoCorrectionStateChanged(words.mWillAutoCorrect); - } - mInputLogic.mSuggestedWords = words; - final boolean newAutoCorrectionIndicator = words.mWillAutoCorrect; - // Put a blue underline to a word in TextView which will be auto-corrected. - if (mInputLogic.mIsAutoCorrectionIndicatorOn != newAutoCorrectionIndicator - && mInputLogic.mWordComposer.isComposingWord()) { - mInputLogic.mIsAutoCorrectionIndicatorOn = newAutoCorrectionIndicator; - final CharSequence textWithUnderline = - mInputLogic.getTextWithUnderline(mInputLogic.mWordComposer.getTypedWord()); - // TODO: when called from an updateSuggestionStrip() call that results from a posted - // message, this is called outside any batch edit. Potentially, this may result in some - // janky flickering of the screen, although the display speed makes it unlikely in - // the practice. - mInputLogic.mConnection.setComposingText(textWithUnderline, 1); - } - setSuggestionStripShownInternal(shouldShow, true /* needsInputViewShown */); + mSuggestionStripView.setSuggestions(suggestedWords, + SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype())); + mKeyboardSwitcher.onAutoCorrectionStateChanged(suggestedWords.mWillAutoCorrect); + setSuggestionStripShownInternal(shouldShow, true /* needsInputViewShown */); + } } // TODO[IL]: Move this out of LatinIME. @@ -1419,7 +1408,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } } - private void showSuggestionStripWithTypedWord(final SuggestedWords sourceSuggestedWords, + // TODO[IL]: Define a clean interface for this + public void showSuggestionStrip(final SuggestedWords sourceSuggestedWords, final String typedWord) { final SuggestedWords suggestedWords = sourceSuggestedWords.isEmpty() ? SuggestedWords.EMPTY : sourceSuggestedWords; @@ -1440,12 +1430,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen AccessibilityUtils.getInstance().setAutoCorrection(suggestedWords, typedWord); } - // TODO[IL]: Define a clean interface for this - public void showSuggestionStrip(final SuggestedWords suggestedWords) { - showSuggestionStripWithTypedWord(suggestedWords, suggestedWords.isEmpty() ? null - : suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD)); - } - // Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener} // interface @Override |