am 8616e4c0: Remove typedWord from the arguments of showSuggestionStrip.

* commit '8616e4c03d79ce963e660107285d30093c6e8499':
  Remove typedWord from the arguments of showSuggestionStrip.
This commit is contained in:
Yuichiro Hanada 2013-09-02 06:37:16 -07:00 committed by Android Git Automerger
commit 2be5da0f9d

View file

@ -1827,7 +1827,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords, private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords,
final boolean dismissGestureFloatingPreviewText) { final boolean dismissGestureFloatingPreviewText) {
showSuggestionStrip(suggestedWords, null); showSuggestionStrip(suggestedWords);
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
mainKeyboardView.showGestureFloatingPreviewText(suggestedWords); mainKeyboardView.showGestureFloatingPreviewText(suggestedWords);
if (dismissGestureFloatingPreviewText) { if (dismissGestureFloatingPreviewText) {
@ -2343,12 +2343,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return; return;
} }
final String typedWord = mWordComposer.getTypedWord();
getSuggestedWordsOrOlderSuggestions(Suggest.SESSION_TYPING, getSuggestedWordsOrOlderSuggestions(Suggest.SESSION_TYPING,
new OnGetSuggestedWordsCallback() { new OnGetSuggestedWordsCallback() {
@Override @Override
public void onGetSuggestedWords(SuggestedWords suggestedWords) { public void onGetSuggestedWords(SuggestedWords suggestedWords) {
showSuggestionStrip(suggestedWords, typedWord); showSuggestionStrip(suggestedWords);
} }
}); });
} }
@ -2429,16 +2428,16 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
false /* isPrediction */); false /* isPrediction */);
} }
private void showSuggestionStrip(final SuggestedWords suggestedWords, final String typedWord) { private void showSuggestionStrip(final SuggestedWords suggestedWords) {
if (suggestedWords.isEmpty()) { if (suggestedWords.isEmpty()) {
clearSuggestionStrip(); clearSuggestionStrip();
return; return;
} }
final String autoCorrection; final String autoCorrection;
if (suggestedWords.mWillAutoCorrect) { if (suggestedWords.mWillAutoCorrect) {
autoCorrection = suggestedWords.getWord(1); autoCorrection = suggestedWords.getWord(SuggestedWords.INDEX_OF_AUTO_CORRECTION);
} else { } else {
autoCorrection = typedWord; autoCorrection = suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD);
} }
mWordComposer.setAutoCorrection(autoCorrection); mWordComposer.setAutoCorrection(autoCorrection);
final boolean isAutoCorrection = suggestedWords.willAutoCorrect(); final boolean isAutoCorrection = suggestedWords.willAutoCorrect();
@ -2708,8 +2707,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Since there is only one word, willAutoCorrect is false. // Since there is only one word, willAutoCorrect is false.
suggestedWords = suggestedWordsIncludingTypedWord; suggestedWords = suggestedWordsIncludingTypedWord;
} }
unsetIsAutoCorrectionIndicatorOnAndCallShowSuggestionStrip(suggestedWords, unsetIsAutoCorrectionIndicatorOnAndCallShowSuggestionStrip(suggestedWords);
typedWord);
}}); }});
} else { } else {
// We found suggestion spans in the word. We'll create the SuggestedWords out of // We found suggestion spans in the word. We'll create the SuggestedWords out of
@ -2718,12 +2716,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
true /* typedWordValid */, false /* willAutoCorrect */, true /* typedWordValid */, false /* willAutoCorrect */,
false /* isPunctuationSuggestions */, false /* isObsoleteSuggestions */, false /* isPunctuationSuggestions */, false /* isObsoleteSuggestions */,
false /* isPrediction */); false /* isPrediction */);
unsetIsAutoCorrectionIndicatorOnAndCallShowSuggestionStrip(suggestedWords, typedWord); unsetIsAutoCorrectionIndicatorOnAndCallShowSuggestionStrip(suggestedWords);
} }
} }
public void unsetIsAutoCorrectionIndicatorOnAndCallShowSuggestionStrip( public void unsetIsAutoCorrectionIndicatorOnAndCallShowSuggestionStrip(
final SuggestedWords suggestedWords, final String typedWord) { final SuggestedWords suggestedWords) {
// Note that it's very important here that suggestedWords.mWillAutoCorrect is false. // Note that it's very important here that suggestedWords.mWillAutoCorrect is false.
// We never want to auto-correct on a resumed suggestion. Please refer to the three places // We never want to auto-correct on a resumed suggestion. Please refer to the three places
// above in restartSuggestionsOnWordTouchedByCursor() where suggestedWords is affected. // above in restartSuggestionsOnWordTouchedByCursor() where suggestedWords is affected.
@ -2731,7 +2729,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// the text to adapt it. // the text to adapt it.
// TODO: remove mIsAutoCorrectionIndicatorOn (see comment on definition) // TODO: remove mIsAutoCorrectionIndicatorOn (see comment on definition)
mIsAutoCorrectionIndicatorOn = false; mIsAutoCorrectionIndicatorOn = false;
showSuggestionStrip(suggestedWords, typedWord); showSuggestionStrip(suggestedWords);
} }
/** /**