aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-01-20 12:06:44 +0900
committerTadashi G. Takaoka <takaoka@google.com>2014-01-20 12:08:25 +0900
commit3033cc51b82889188fe6ac8ae1e3bec34529e5d0 (patch)
tree70f77a27a11a9ed2f44e9a9392bd736b40bec056 /java
parent3f3b0af5b759ef87fbc42935a53b6827c7237f05 (diff)
downloadlatinime-3033cc51b82889188fe6ac8ae1e3bec34529e5d0.tar.gz
latinime-3033cc51b82889188fe6ac8ae1e3bec34529e5d0.tar.xz
latinime-3033cc51b82889188fe6ac8ae1e3bec34529e5d0.zip
Refactor logic to retrieve relevant suggestions a bit
Change-Id: Ic7d2cbb2c1b2deaa4e735484bdc7413c0b3b1939
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java38
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java3
2 files changed, 18 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 3fca4fd19..d3e6a1bc2 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1407,7 +1407,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO[IL]: Move this to InputLogic
public SuggestedWords maybeRetrieveOlderSuggestions(final String typedWord,
- final SuggestedWords suggestedWords) {
+ final SuggestedWords suggestedWords, final SuggestedWords previousSuggestedWords) {
// TODO: consolidate this into getSuggestedWords
// 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
@@ -1420,28 +1420,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|| mSuggestionStripView.isShowingAddToDictionaryHint()) {
return suggestedWords;
} else {
- return getOlderSuggestions(typedWord);
- }
- }
-
- private SuggestedWords getOlderSuggestions(final String typedWord) {
- SuggestedWords previousSuggestedWords = mInputLogic.mSuggestedWords;
- if (previousSuggestedWords
- == mSettings.getCurrent().mSpacingAndPunctuations.mSuggestPuncList) {
- previousSuggestedWords = SuggestedWords.EMPTY;
- }
- if (typedWord == null) {
- return previousSuggestedWords;
+ final SuggestedWords punctuationList =
+ mSettings.getCurrent().mSpacingAndPunctuations.mSuggestPuncList;
+ final SuggestedWords oldSuggestedWords = previousSuggestedWords == punctuationList
+ ? SuggestedWords.EMPTY : previousSuggestedWords;
+ if (TextUtils.isEmpty(typedWord)) {
+ return oldSuggestedWords;
+ }
+ final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
+ SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord, oldSuggestedWords);
+ return new SuggestedWords(typedWordAndPreviousSuggestions,
+ false /* typedWordValid */,
+ false /* hasAutoCorrectionCandidate */,
+ false /* isPunctuationSuggestions */,
+ true /* isObsoleteSuggestions */,
+ false /* isPrediction */);
}
- final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
- SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord,
- previousSuggestedWords);
- return new SuggestedWords(typedWordAndPreviousSuggestions,
- false /* typedWordValid */,
- false /* hasAutoCorrectionCandidate */,
- false /* isPunctuationSuggestions */,
- true /* isObsoleteSuggestions */,
- false /* isPrediction */);
}
private void showSuggestionStripWithTypedWord(final SuggestedWords suggestedWords,
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 3ff20791f..d290daa7f 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -1031,7 +1031,8 @@ public final class InputLogic {
public void onGetSuggestedWords(final SuggestedWords suggestedWords) {
final SuggestedWords suggestedWordsWithMaybeOlderSuggestions =
mLatinIME.maybeRetrieveOlderSuggestions(
- mWordComposer.getTypedWord(), suggestedWords);
+ mWordComposer.getTypedWord(), suggestedWords,
+ mSuggestedWords);
holder.set(suggestedWordsWithMaybeOlderSuggestions);
}
}