Make the suggested word list final in Builder.

Change-Id: I2ddfab00dc8c141fc989a051f16eb2b3571b7e86
This commit is contained in:
Jean Chalard 2012-03-13 19:26:52 +09:00
parent 08adb09e14
commit c60fea852d
4 changed files with 12 additions and 22 deletions

View file

@ -926,8 +926,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final List<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords = final List<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords =
SuggestedWords.Builder.getFromApplicationSpecifiedCompletions( SuggestedWords.Builder.getFromApplicationSpecifiedCompletions(
applicationSpecifiedCompletions); applicationSpecifiedCompletions);
SuggestedWords.Builder builder = new SuggestedWords.Builder() SuggestedWords.Builder builder = new SuggestedWords.Builder(applicationSuggestedWords)
.setWords(applicationSuggestedWords)
.setTypedWordValid(false) .setTypedWordValid(false)
.setHasMinimalSuggestion(false); .setHasMinimalSuggestion(false);
// When in fullscreen mode, show completions generated by the application // When in fullscreen mode, show completions generated by the application
@ -1786,8 +1785,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions = final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
SuggestedWords.Builder.getTypedWordAndPreviousSuggestions( SuggestedWords.Builder.getTypedWordAndPreviousSuggestions(
typedWord, previousSuggestions); typedWord, previousSuggestions);
final SuggestedWords.Builder obsoleteSuggestionsBuilder = new SuggestedWords.Builder() final SuggestedWords.Builder obsoleteSuggestionsBuilder =
.setWords(typedWordAndPreviousSuggestions) new SuggestedWords.Builder(typedWordAndPreviousSuggestions)
.setTypedWordValid(false) .setTypedWordValid(false)
.setHasMinimalSuggestion(false); .setHasMinimalSuggestion(false);

View file

@ -183,8 +183,7 @@ public class SettingsValues {
KeySpecParser.getLabel(puncSpec))); KeySpecParser.getLabel(puncSpec)));
} }
} }
final SuggestedWords.Builder builder = new SuggestedWords.Builder() final SuggestedWords.Builder builder = new SuggestedWords.Builder(puncList)
.setWords(puncList)
.setIsPunctuationSuggestions(); .setIsPunctuationSuggestions();
return builder.build(); return builder.build();
} }
@ -203,8 +202,7 @@ public class SettingsValues {
} }
} }
} }
final SuggestedWords.Builder builder = new SuggestedWords.Builder() final SuggestedWords.Builder builder = new SuggestedWords.Builder(puncOutputTextList)
.setWords(puncOutputTextList)
.setIsPunctuationSuggestions(); .setIsPunctuationSuggestions();
return builder.build(); return builder.build();
} }

View file

@ -269,8 +269,8 @@ public class Suggest implements Dictionary.WordCallback {
StringUtils.removeDupes(mSuggestions); StringUtils.removeDupes(mSuggestions);
return new SuggestedWords.Builder() return new SuggestedWords.Builder(
.setWords(SuggestedWords.Builder.getFromCharSequenceList(mSuggestions)) SuggestedWords.Builder.getFromCharSequenceList(mSuggestions))
.setAllowsToBeAutoCorrected(false); .setAllowsToBeAutoCorrected(false);
} }
@ -423,11 +423,11 @@ public class Suggest implements Dictionary.WordCallback {
scoreInfoList.add(new SuggestedWords.SuggestedWordInfo(mSuggestions.get(i), scoreInfoList.add(new SuggestedWords.SuggestedWordInfo(mSuggestions.get(i),
"--", false)); "--", false));
} }
builder = new SuggestedWords.Builder().setWords(scoreInfoList) builder = new SuggestedWords.Builder(scoreInfoList)
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected); .setAllowsToBeAutoCorrected(allowsToBeAutoCorrected);
} else { } else {
builder = new SuggestedWords.Builder() builder = new SuggestedWords.Builder(
.setWords(SuggestedWords.Builder.getFromCharSequenceList(mSuggestions)) SuggestedWords.Builder.getFromCharSequenceList(mSuggestions))
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected); .setAllowsToBeAutoCorrected(allowsToBeAutoCorrected);
} }

View file

@ -16,7 +16,6 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import android.text.TextUtils;
import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.CompletionInfo;
import java.util.ArrayList; import java.util.ArrayList;
@ -79,16 +78,10 @@ public class SuggestedWords {
private boolean mIsPunctuationSuggestions; private boolean mIsPunctuationSuggestions;
private boolean mShouldBlockAutoCorrectionBySafetyNet; private boolean mShouldBlockAutoCorrectionBySafetyNet;
private boolean mAllowsToBeAutoCorrected; private boolean mAllowsToBeAutoCorrected;
private List<SuggestedWordInfo> mSuggestedWordInfoList = private final List<SuggestedWordInfo> mSuggestedWordInfoList;
new ArrayList<SuggestedWordInfo>();
public Builder() { public Builder(final List<SuggestedWordInfo> suggestedWordInfoList) {
// Nothing to do here.
}
public Builder setWords(List<SuggestedWordInfo> suggestedWordInfoList) {
mSuggestedWordInfoList = suggestedWordInfoList; mSuggestedWordInfoList = suggestedWordInfoList;
return this;
} }
public static List<SuggestedWordInfo> getFromCharSequenceList( public static List<SuggestedWordInfo> getFromCharSequenceList(