am 350f23f6: [HW3] Some refactoring

* commit '350f23f67e2a380452403643e1d1d7aa544da6b7':
  [HW3] Some refactoring
This commit is contained in:
Jean Chalard 2014-07-01 09:24:37 +00:00 committed by Android Git Automerger
commit f4a8a0a28b

View file

@ -1336,6 +1336,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} }
private void setSuggestedWords(final SuggestedWords suggestedWords) { private void setSuggestedWords(final SuggestedWords suggestedWords) {
if (SuggestedWords.EMPTY != suggestedWords) {
final String autoCorrection;
if (suggestedWords.mWillAutoCorrect) {
autoCorrection = suggestedWords.getWord(SuggestedWords.INDEX_OF_AUTO_CORRECTION);
} else {
// We can't use suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD)
// because it may differ from mWordComposer.mTypedWord.
autoCorrection = suggestedWords.mTypedWord;
}
mInputLogic.mWordComposer.setAutoCorrection(autoCorrection);
}
mInputLogic.setSuggestedWords(suggestedWords); mInputLogic.setSuggestedWords(suggestedWords);
// TODO: Modify this when we support suggestions with hard keyboard // TODO: Modify this when we support suggestions with hard keyboard
if (!hasSuggestionStripView()) { if (!hasSuggestionStripView()) {
@ -1399,18 +1410,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void showSuggestionStrip(final SuggestedWords sourceSuggestedWords) { public void showSuggestionStrip(final SuggestedWords sourceSuggestedWords) {
final SuggestedWords suggestedWords = final SuggestedWords suggestedWords =
sourceSuggestedWords.isEmpty() ? SuggestedWords.EMPTY : sourceSuggestedWords; sourceSuggestedWords.isEmpty() ? SuggestedWords.EMPTY : sourceSuggestedWords;
final String autoCorrection;
if (suggestedWords.mWillAutoCorrect) {
autoCorrection = suggestedWords.getWord(SuggestedWords.INDEX_OF_AUTO_CORRECTION);
} else {
// We can't use suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD)
// because it may differ from mWordComposer.mTypedWord.
autoCorrection = sourceSuggestedWords.mTypedWord;
}
if (SuggestedWords.EMPTY == suggestedWords) { if (SuggestedWords.EMPTY == suggestedWords) {
setNeutralSuggestionStrip(); setNeutralSuggestionStrip();
} else { } else {
mInputLogic.mWordComposer.setAutoCorrection(autoCorrection);
setSuggestedWords(suggestedWords); setSuggestedWords(suggestedWords);
} }
// Cache the auto-correction in accessibility code so we can speak it if the user // Cache the auto-correction in accessibility code so we can speak it if the user