From 350f23f67e2a380452403643e1d1d7aa544da6b7 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 30 Jun 2014 21:16:39 +0900 Subject: [PATCH] [HW3] Some refactoring Change-Id: I303ce084a56c6ec709d3eab239a4d9d2274d0dea --- .../android/inputmethod/latin/LatinIME.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 865ff07d6..44ce26360 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1336,6 +1336,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } 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); // TODO: Modify this when we support suggestions with hard keyboard if (!hasSuggestionStripView()) { @@ -1399,18 +1410,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void showSuggestionStrip(final SuggestedWords sourceSuggestedWords) { final SuggestedWords suggestedWords = 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) { setNeutralSuggestionStrip(); } else { - mInputLogic.mWordComposer.setAutoCorrection(autoCorrection); setSuggestedWords(suggestedWords); } // Cache the auto-correction in accessibility code so we can speak it if the user