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 =
SuggestedWords.Builder.getFromApplicationSpecifiedCompletions(
applicationSpecifiedCompletions);
SuggestedWords.Builder builder = new SuggestedWords.Builder()
.setWords(applicationSuggestedWords)
SuggestedWords.Builder builder = new SuggestedWords.Builder(applicationSuggestedWords)
.setTypedWordValid(false)
.setHasMinimalSuggestion(false);
// 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 =
SuggestedWords.Builder.getTypedWordAndPreviousSuggestions(
typedWord, previousSuggestions);
final SuggestedWords.Builder obsoleteSuggestionsBuilder = new SuggestedWords.Builder()
.setWords(typedWordAndPreviousSuggestions)
final SuggestedWords.Builder obsoleteSuggestionsBuilder =
new SuggestedWords.Builder(typedWordAndPreviousSuggestions)
.setTypedWordValid(false)
.setHasMinimalSuggestion(false);

View File

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

View File

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

View File

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