Make still more members of the Builder final.

Change-Id: Ic455f97247da5e40d4939555ab639ecffef36e2d
main
Jean Chalard 2012-03-13 20:05:00 +09:00
parent edf5daa8ed
commit 2e2519ee91
4 changed files with 22 additions and 22 deletions

View File

@ -927,10 +927,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
SuggestedWords.Builder.getFromApplicationSpecifiedCompletions(
applicationSpecifiedCompletions);
SuggestedWords.Builder builder = new SuggestedWords.Builder(applicationSuggestedWords,
false /* typedWordValid */,
false /* hasMinimalSuggestion */,
false /* allowsToBeAutoCorrected */,
false /* isPunctuationSuggestions */)
.setTypedWordValid(false)
.setHasMinimalSuggestion(false);
false /* isPunctuationSuggestions */);
// When in fullscreen mode, show completions generated by the application
final SuggestedWords words = builder.build();
final boolean isAutoCorrection = false;
@ -1789,11 +1789,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
typedWord, previousSuggestions);
final SuggestedWords.Builder obsoleteSuggestionsBuilder =
new SuggestedWords.Builder(typedWordAndPreviousSuggestions,
false /* typedWordValid */,
false /* hasMinimalSuggestion */,
false /* allowsToBeAutoCorrected */,
false /* isPunctuationSuggestions */)
.setTypedWordValid(false)
.setHasMinimalSuggestion(false);
false /* isPunctuationSuggestions */);
showSuggestions(obsoleteSuggestionsBuilder.build(), typedWord);
}
}

View File

@ -184,6 +184,8 @@ public class SettingsValues {
}
}
final SuggestedWords.Builder builder = new SuggestedWords.Builder(puncList,
false /* typedWordValid */,
false /* hasMinimalSuggestion */,
false /* allowsToBeAutoCorrected */,
true /* isPunctuationSuggestions */);
return builder.build();
@ -204,6 +206,8 @@ public class SettingsValues {
}
}
final SuggestedWords.Builder builder = new SuggestedWords.Builder(puncOutputTextList,
false /* typedWordValid */,
false /* hasMinimalSuggestion */,
false /* allowsToBeAutoCorrected */,
true /* isPunctuationSuggestions */);
return builder.build();

View File

@ -271,6 +271,8 @@ public class Suggest implements Dictionary.WordCallback {
return new SuggestedWords.Builder(
SuggestedWords.Builder.getFromCharSequenceList(mSuggestions),
false /* typedWordValid */,
false /* hasMinimalSuggestion */,
false /* allowsToBeAutoCorrected */,
false /* isPunctuationSuggestions */);
}
@ -435,10 +437,11 @@ public class Suggest implements Dictionary.WordCallback {
}
// Don't auto-correct words with multiple capital letter
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
builder = new SuggestedWords.Builder(scoreInfoList, allowsToBeAutoCorrected,
builder = new SuggestedWords.Builder(scoreInfoList,
!allowsToBeAutoCorrected /* typedWordValid */,
autoCorrectionAvailable /* hasMinimalSuggestion */,
allowsToBeAutoCorrected /* allowsToBeAutoCorrected */,
false /* isPunctuationSuggestions */);
builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion(
autoCorrectionAvailable);
if (allowsToBeAutoCorrected && builder.size() > 1 && mAutoCorrectionThreshold > 0
&& Suggest.shouldBlockAutoCorrectionBySafetyNet(typedWord, builder.getWord(1))) {
builder.setShouldBlockAutoCorrectionBySafetyNet();

View File

@ -73,17 +73,21 @@ public class SuggestedWords {
}
public static class Builder {
private boolean mTypedWordValid;
private boolean mHasMinimalSuggestion;
private final boolean mTypedWordValid;
private final boolean mHasMinimalSuggestion;
private final boolean mIsPunctuationSuggestions;
private boolean mShouldBlockAutoCorrectionBySafetyNet;
private final boolean mAllowsToBeAutoCorrected;
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
public Builder(final List<SuggestedWordInfo> suggestedWordInfoList,
final boolean typedWordValid,
final boolean hasMinimalSuggestion,
final boolean allowsToBeAutoCorrected,
final boolean isPunctuationSuggestions) {
mSuggestedWordInfoList = suggestedWordInfoList;
mTypedWordValid = typedWordValid;
mHasMinimalSuggestion = hasMinimalSuggestion;
mAllowsToBeAutoCorrected = allowsToBeAutoCorrected;
mIsPunctuationSuggestions = isPunctuationSuggestions;
}
@ -106,16 +110,6 @@ public class SuggestedWords {
return result;
}
public Builder setTypedWordValid(boolean typedWordValid) {
mTypedWordValid = typedWordValid;
return this;
}
public Builder setHasMinimalSuggestion(boolean hasMinimalSuggestion) {
mHasMinimalSuggestion = hasMinimalSuggestion;
return this;
}
public Builder setShouldBlockAutoCorrectionBySafetyNet() {
mShouldBlockAutoCorrectionBySafetyNet = true;
return this;