Skip to content
Snippets Groups Projects
Commit 3033cc51 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Refactor logic to retrieve relevant suggestions a bit

Change-Id: Ic7d2cbb2c1b2deaa4e735484bdc7413c0b3b1939
parent 3f3b0af5
No related branches found
No related tags found
No related merge requests found
...@@ -1407,7 +1407,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ...@@ -1407,7 +1407,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO[IL]: Move this to InputLogic // TODO[IL]: Move this to InputLogic
public SuggestedWords maybeRetrieveOlderSuggestions(final String typedWord, public SuggestedWords maybeRetrieveOlderSuggestions(final String typedWord,
final SuggestedWords suggestedWords) { final SuggestedWords suggestedWords, final SuggestedWords previousSuggestedWords) {
// TODO: consolidate this into getSuggestedWords // TODO: consolidate this into getSuggestedWords
// We update the suggestion strip only when we have some suggestions to show, i.e. when // 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 // 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 ...@@ -1420,28 +1420,22 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|| mSuggestionStripView.isShowingAddToDictionaryHint()) { || mSuggestionStripView.isShowingAddToDictionaryHint()) {
return suggestedWords; return suggestedWords;
} else { } else {
return getOlderSuggestions(typedWord); final SuggestedWords punctuationList =
} mSettings.getCurrent().mSpacingAndPunctuations.mSuggestPuncList;
} final SuggestedWords oldSuggestedWords = previousSuggestedWords == punctuationList
? SuggestedWords.EMPTY : previousSuggestedWords;
private SuggestedWords getOlderSuggestions(final String typedWord) { if (TextUtils.isEmpty(typedWord)) {
SuggestedWords previousSuggestedWords = mInputLogic.mSuggestedWords; return oldSuggestedWords;
if (previousSuggestedWords }
== mSettings.getCurrent().mSpacingAndPunctuations.mSuggestPuncList) { final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
previousSuggestedWords = SuggestedWords.EMPTY; SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord, oldSuggestedWords);
} return new SuggestedWords(typedWordAndPreviousSuggestions,
if (typedWord == null) { false /* typedWordValid */,
return previousSuggestedWords; 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, private void showSuggestionStripWithTypedWord(final SuggestedWords suggestedWords,
......
...@@ -1031,7 +1031,8 @@ public final class InputLogic { ...@@ -1031,7 +1031,8 @@ public final class InputLogic {
public void onGetSuggestedWords(final SuggestedWords suggestedWords) { public void onGetSuggestedWords(final SuggestedWords suggestedWords) {
final SuggestedWords suggestedWordsWithMaybeOlderSuggestions = final SuggestedWords suggestedWordsWithMaybeOlderSuggestions =
mLatinIME.maybeRetrieveOlderSuggestions( mLatinIME.maybeRetrieveOlderSuggestions(
mWordComposer.getTypedWord(), suggestedWords); mWordComposer.getTypedWord(), suggestedWords,
mSuggestedWords);
holder.set(suggestedWordsWithMaybeOlderSuggestions); holder.set(suggestedWordsWithMaybeOlderSuggestions);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment