Make the Builder private
Change-Id: I2184084f4b7729c4324f8291d548bd4c4c2872a1
This commit is contained in:
parent
5b0643f50d
commit
7d55c891af
4 changed files with 30 additions and 17 deletions
|
@ -926,16 +926,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
final List<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords =
|
||||
SuggestedWords.getFromApplicationSpecifiedCompletions(
|
||||
applicationSpecifiedCompletions);
|
||||
SuggestedWords.Builder builder = new SuggestedWords.Builder(applicationSuggestedWords,
|
||||
final SuggestedWords suggestedWords = SuggestedWords.getSuggestedWords(
|
||||
applicationSuggestedWords,
|
||||
false /* typedWordValid */,
|
||||
false /* hasMinimalSuggestion */,
|
||||
false /* allowsToBeAutoCorrected */,
|
||||
false /* isPunctuationSuggestions */,
|
||||
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||
// When in fullscreen mode, show completions generated by the application
|
||||
final SuggestedWords words = builder.build();
|
||||
final boolean isAutoCorrection = false;
|
||||
setSuggestions(words, isAutoCorrection);
|
||||
setSuggestions(suggestedWords, isAutoCorrection);
|
||||
setAutoCorrectionIndicator(isAutoCorrection);
|
||||
// TODO: is this the right thing to do? What should we auto-correct to in
|
||||
// this case? This says to keep whatever the user typed.
|
||||
|
@ -1789,14 +1789,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
|
||||
SuggestedWords.getTypedWordAndPreviousSuggestions(
|
||||
typedWord, previousSuggestions);
|
||||
final SuggestedWords.Builder obsoleteSuggestionsBuilder =
|
||||
new SuggestedWords.Builder(typedWordAndPreviousSuggestions,
|
||||
final SuggestedWords obsoleteSuggestedWords =
|
||||
SuggestedWords.getSuggestedWords(typedWordAndPreviousSuggestions,
|
||||
false /* typedWordValid */,
|
||||
false /* hasMinimalSuggestion */,
|
||||
false /* allowsToBeAutoCorrected */,
|
||||
false /* isPunctuationSuggestions */,
|
||||
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||
showSuggestions(obsoleteSuggestionsBuilder.build(), typedWord);
|
||||
showSuggestions(obsoleteSuggestedWords, typedWord);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -183,13 +183,12 @@ public class SettingsValues {
|
|||
KeySpecParser.getLabel(puncSpec)));
|
||||
}
|
||||
}
|
||||
final SuggestedWords.Builder builder = new SuggestedWords.Builder(puncList,
|
||||
return SuggestedWords.getSuggestedWords(puncList,
|
||||
false /* typedWordValid */,
|
||||
false /* hasMinimalSuggestion */,
|
||||
false /* allowsToBeAutoCorrected */,
|
||||
true /* isPunctuationSuggestions */,
|
||||
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static SuggestedWords createSuggestPuncOutputTextList(final String[] puncs) {
|
||||
|
@ -206,13 +205,12 @@ public class SettingsValues {
|
|||
}
|
||||
}
|
||||
}
|
||||
final SuggestedWords.Builder builder = new SuggestedWords.Builder(puncOutputTextList,
|
||||
return SuggestedWords.getSuggestedWords(puncOutputTextList,
|
||||
false /* typedWordValid */,
|
||||
false /* hasMinimalSuggestion */,
|
||||
false /* allowsToBeAutoCorrected */,
|
||||
true /* isPunctuationSuggestions */,
|
||||
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static String createWordSeparators(final String weakSpaceStrippers,
|
||||
|
|
|
@ -269,13 +269,13 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
|
||||
StringUtils.removeDupes(mSuggestions);
|
||||
|
||||
return new SuggestedWords.Builder(
|
||||
return SuggestedWords.getSuggestedWords(
|
||||
SuggestedWords.getFromCharSequenceList(mSuggestions),
|
||||
false /* typedWordValid */,
|
||||
false /* hasMinimalSuggestion */,
|
||||
false /* allowsToBeAutoCorrected */,
|
||||
false /* isPunctuationSuggestions */,
|
||||
false /* shouldBlockAutoCorrectionBySafetyNet */).build();
|
||||
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||
}
|
||||
|
||||
// TODO: cleanup dictionaries looking up and suggestions building with SuggestedWords.Builder
|
||||
|
@ -445,12 +445,12 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
} else {
|
||||
shouldBlockAutoCorrectionBySatefyNet = false;
|
||||
}
|
||||
return new SuggestedWords.Builder(scoreInfoList,
|
||||
return SuggestedWords.getSuggestedWords(scoreInfoList,
|
||||
!allowsToBeAutoCorrected /* typedWordValid */,
|
||||
autoCorrectionAvailable /* hasMinimalSuggestion */,
|
||||
allowsToBeAutoCorrected /* allowsToBeAutoCorrected */,
|
||||
false /* isPunctuationSuggestions */,
|
||||
shouldBlockAutoCorrectionBySatefyNet).build();
|
||||
shouldBlockAutoCorrectionBySatefyNet);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ public class SuggestedWords {
|
|||
public final boolean mAllowsToBeAutoCorrected;
|
||||
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
||||
|
||||
SuggestedWords(final boolean typedWordValid,
|
||||
private SuggestedWords(final boolean typedWordValid,
|
||||
final boolean hasAutoCorrectionCandidate,
|
||||
final boolean isPunctuationSuggestions,
|
||||
final boolean shouldBlockAutoCorrectionBySafetyNet,
|
||||
|
@ -76,7 +76,7 @@ public class SuggestedWords {
|
|||
+ " mIsPunctuationSuggestions=" + mIsPunctuationSuggestions;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private static class Builder {
|
||||
private final boolean mTypedWordValid;
|
||||
private final boolean mHasMinimalSuggestion;
|
||||
private final boolean mIsPunctuationSuggestions;
|
||||
|
@ -84,7 +84,7 @@ public class SuggestedWords {
|
|||
private final boolean mAllowsToBeAutoCorrected;
|
||||
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
||||
|
||||
public Builder(final List<SuggestedWordInfo> suggestedWordInfoList,
|
||||
private Builder(final List<SuggestedWordInfo> suggestedWordInfoList,
|
||||
final boolean typedWordValid,
|
||||
final boolean hasMinimalSuggestion,
|
||||
final boolean allowsToBeAutoCorrected,
|
||||
|
@ -105,6 +105,21 @@ public class SuggestedWords {
|
|||
}
|
||||
}
|
||||
|
||||
public static SuggestedWords getSuggestedWords(
|
||||
final List<SuggestedWordInfo> suggestedWordInfoList,
|
||||
final boolean typedWordValid,
|
||||
final boolean hasMinimalSuggestion,
|
||||
final boolean allowsToBeAutoCorrected,
|
||||
final boolean isPunctuationSuggestions,
|
||||
final boolean shouldBlockAutoCorrectionBySafetyNet) {
|
||||
return new Builder(suggestedWordInfoList,
|
||||
typedWordValid,
|
||||
hasMinimalSuggestion,
|
||||
allowsToBeAutoCorrected,
|
||||
isPunctuationSuggestions,
|
||||
shouldBlockAutoCorrectionBySafetyNet).build();
|
||||
}
|
||||
|
||||
public static ArrayList<SuggestedWordInfo> getFromCharSequenceList(
|
||||
final List<CharSequence> wordList) {
|
||||
final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>();
|
||||
|
|
Loading…
Reference in a new issue