aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-02-26 16:47:55 +0900
committerJean Chalard <jchalard@google.com>2014-03-04 14:46:04 +0900
commit030da519de96c9103bde923e1495dc158a36a43b (patch)
tree4fe4cbfea06b62247d6705424fa10dee5429b22d /java/src
parente110018e2a7cc5809aaadb4c0e9cfef70760543f (diff)
downloadlatinime-030da519de96c9103bde923e1495dc158a36a43b.tar.gz
latinime-030da519de96c9103bde923e1495dc158a36a43b.tar.xz
latinime-030da519de96c9103bde923e1495dc158a36a43b.zip
[IL115] Cleanup continues
Bug: 8636060 Change-Id: I944b10ec9798eec57d986e1075ba348aa0892cae
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java53
1 files changed, 25 insertions, 28 deletions
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 7be60fd31..06561b56f 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -1228,10 +1228,15 @@ public final class InputLogic {
SuggestedWords.NOT_A_SEQUENCE_NUMBER, new OnGetSuggestedWordsCallback() {
@Override
public void onGetSuggestedWords(final SuggestedWords suggestedWords) {
- final SuggestedWords suggestedWordsWithMaybeOlderSuggestions =
- maybeRetrieveOlderSuggestions(mWordComposer.getTypedWord(),
- suggestedWords, mSuggestedWords);
- holder.set(suggestedWordsWithMaybeOlderSuggestions);
+ final String typedWord = mWordComposer.getTypedWord();
+ // Show new suggestions if we have at least one. Otherwise keep the old
+ // suggestions with the new typed word. Exception: if the length of the
+ // typed word is <= 1 (after a deletion typically) we clear old suggestions.
+ if (suggestedWords.size() > 1 || typedWord.length() <= 1) {
+ holder.set(suggestedWords);
+ } else {
+ holder.set(retrieveOlderSuggestions(typedWord, mSuggestedWords));
+ }
}
}
);
@@ -1656,32 +1661,24 @@ public final class InputLogic {
}
/**
- * Given a typed word and computed suggested words, return an object that may or may not
- * contain older suggestions according to the contents of the current suggestions.
+ * Make a {@link com.android.inputmethod.latin.SuggestedWords} object containing a typed word
+ * and obsolete suggestions.
+ * See {@link com.android.inputmethod.latin.SuggestedWords#getTypedWordAndPreviousSuggestions(
+ * String, com.android.inputmethod.latin.SuggestedWords)}.
* @param typedWord The typed word as a string.
- * @param suggestedWords The computed suggested words for this typed word.
- * @param previousSuggestedWords The previous suggested words.
- * @return suggestions possibly enriched with older suggestions.
+ * @param previousSuggestedWords The previously suggested words.
+ * @return Obsolete suggestions with the newly typed word.
*/
- private SuggestedWords maybeRetrieveOlderSuggestions(final String typedWord,
- final SuggestedWords suggestedWords, final SuggestedWords previousSuggestedWords) {
- // TODO: consolidate this into performUpdateSuggestionStripSync?
- // We update the suggestion strip only when we have some suggestions to show, i.e. when
- // the suggestion count is > 1; else, we leave the old suggestions, with the typed word
- // replaced with the new one. However, when the length of the typed word is 1 or 0 (after
- // a deletion typically), we do want to remove the old suggestions.
- if (suggestedWords.size() > 1 || typedWord.length() <= 1) {
- return suggestedWords;
- } else {
- final SuggestedWords oldSuggestedWords =
- previousSuggestedWords.isPunctuationSuggestions() ? SuggestedWords.EMPTY
- : previousSuggestedWords;
- final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
- SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord, oldSuggestedWords);
- return new SuggestedWords(typedWordAndPreviousSuggestions, null /* rawSuggestions */,
- false /* typedWordValid */, false /* hasAutoCorrectionCandidate */,
- true /* isObsoleteSuggestions */, false /* isPrediction */);
- }
+ private SuggestedWords retrieveOlderSuggestions(final String typedWord,
+ final SuggestedWords previousSuggestedWords) {
+ final SuggestedWords oldSuggestedWords =
+ previousSuggestedWords.isPunctuationSuggestions() ? SuggestedWords.EMPTY
+ : previousSuggestedWords;
+ final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
+ SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord, oldSuggestedWords);
+ return new SuggestedWords(typedWordAndPreviousSuggestions, null /* rawSuggestions */,
+ false /* typedWordValid */, false /* hasAutoCorrectionCandidate */,
+ true /* isObsoleteSuggestions */, false /* isPrediction */);
}
/**