Add to SuggestedWords a missing parameter, and use it.
Also stop using Builder between its creation and the call to the #build() method. Change-Id: Ie1fc3ec7b6f4c7c3789f672f4e26b4bf58c3e062
This commit is contained in:
parent
2e2519ee91
commit
ec471c72f8
2 changed files with 14 additions and 8 deletions
|
@ -1769,6 +1769,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// getSuggestedWordBuilder handles gracefully a null value of prevWord
|
// getSuggestedWordBuilder handles gracefully a null value of prevWord
|
||||||
final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(mWordComposer,
|
final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(mWordComposer,
|
||||||
prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(), mCorrectionMode);
|
prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(), mCorrectionMode);
|
||||||
|
final SuggestedWords suggestions = builder.build();
|
||||||
|
|
||||||
// Basically, we update the suggestion strip only when suggestion count > 1. However,
|
// Basically, we update the suggestion strip only when suggestion count > 1. However,
|
||||||
// there is an exception: We update the suggestion strip whenever typed word's length
|
// there is an exception: We update the suggestion strip whenever typed word's length
|
||||||
|
@ -1776,9 +1777,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// in most cases, suggestion count is 1 when typed word's length is 1, but we do always
|
// in most cases, suggestion count is 1 when typed word's length is 1, but we do always
|
||||||
// need to clear the previous state when the user starts typing a word (i.e. typed word's
|
// need to clear the previous state when the user starts typing a word (i.e. typed word's
|
||||||
// length == 1).
|
// length == 1).
|
||||||
if (builder.size() > 1 || typedWord.length() == 1 || !builder.allowsToBeAutoCorrected()
|
if (suggestions.size() > 1 || typedWord.length() == 1
|
||||||
|
|| !suggestions.mAllowsToBeAutoCorrected
|
||||||
|| mSuggestionsView.isShowingAddToDictionaryHint()) {
|
|| mSuggestionsView.isShowingAddToDictionaryHint()) {
|
||||||
showSuggestions(builder.build(), typedWord);
|
showSuggestions(suggestions, typedWord);
|
||||||
} else {
|
} else {
|
||||||
SuggestedWords previousSuggestions = mSuggestionsView.getSuggestions();
|
SuggestedWords previousSuggestions = mSuggestionsView.getSuggestions();
|
||||||
if (previousSuggestions == mSettingsValues.mSuggestPuncList) {
|
if (previousSuggestions == mSettingsValues.mSuggestPuncList) {
|
||||||
|
|
|
@ -25,21 +25,25 @@ import java.util.List;
|
||||||
|
|
||||||
public class SuggestedWords {
|
public class SuggestedWords {
|
||||||
public static final SuggestedWords EMPTY = new SuggestedWords(false, false, false, false,
|
public static final SuggestedWords EMPTY = new SuggestedWords(false, false, false, false,
|
||||||
Collections.<SuggestedWordInfo>emptyList());
|
false, Collections.<SuggestedWordInfo>emptyList());
|
||||||
|
|
||||||
public final boolean mTypedWordValid;
|
public final boolean mTypedWordValid;
|
||||||
public final boolean mHasAutoCorrectionCandidate;
|
public final boolean mHasAutoCorrectionCandidate;
|
||||||
public final boolean mIsPunctuationSuggestions;
|
public final boolean mIsPunctuationSuggestions;
|
||||||
|
public final boolean mAllowsToBeAutoCorrected;
|
||||||
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
||||||
|
|
||||||
SuggestedWords(boolean typedWordValid,
|
SuggestedWords(final boolean typedWordValid,
|
||||||
boolean hasAutoCorrectionCandidate, boolean isPunctuationSuggestions,
|
final boolean hasAutoCorrectionCandidate,
|
||||||
boolean shouldBlockAutoCorrectionBySafetyNet,
|
final boolean isPunctuationSuggestions,
|
||||||
List<SuggestedWordInfo> suggestedWordInfoList) {
|
final boolean shouldBlockAutoCorrectionBySafetyNet,
|
||||||
|
final boolean allowsToBeAutoCorrected,
|
||||||
|
final List<SuggestedWordInfo> suggestedWordInfoList) {
|
||||||
mTypedWordValid = typedWordValid;
|
mTypedWordValid = typedWordValid;
|
||||||
mHasAutoCorrectionCandidate = hasAutoCorrectionCandidate
|
mHasAutoCorrectionCandidate = hasAutoCorrectionCandidate
|
||||||
&& !shouldBlockAutoCorrectionBySafetyNet;
|
&& !shouldBlockAutoCorrectionBySafetyNet;
|
||||||
mIsPunctuationSuggestions = isPunctuationSuggestions;
|
mIsPunctuationSuggestions = isPunctuationSuggestions;
|
||||||
|
mAllowsToBeAutoCorrected = allowsToBeAutoCorrected;
|
||||||
mSuggestedWordInfoList = suggestedWordInfoList;
|
mSuggestedWordInfoList = suggestedWordInfoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +142,7 @@ public class SuggestedWords {
|
||||||
public SuggestedWords build() {
|
public SuggestedWords build() {
|
||||||
return new SuggestedWords(mTypedWordValid, mHasMinimalSuggestion,
|
return new SuggestedWords(mTypedWordValid, mHasMinimalSuggestion,
|
||||||
mIsPunctuationSuggestions, mShouldBlockAutoCorrectionBySafetyNet,
|
mIsPunctuationSuggestions, mShouldBlockAutoCorrectionBySafetyNet,
|
||||||
mSuggestedWordInfoList);
|
mAllowsToBeAutoCorrected, mSuggestedWordInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
|
|
Loading…
Reference in a new issue