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 =
|
final List<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords =
|
||||||
SuggestedWords.getFromApplicationSpecifiedCompletions(
|
SuggestedWords.getFromApplicationSpecifiedCompletions(
|
||||||
applicationSpecifiedCompletions);
|
applicationSpecifiedCompletions);
|
||||||
SuggestedWords.Builder builder = new SuggestedWords.Builder(applicationSuggestedWords,
|
final SuggestedWords suggestedWords = SuggestedWords.getSuggestedWords(
|
||||||
|
applicationSuggestedWords,
|
||||||
false /* typedWordValid */,
|
false /* typedWordValid */,
|
||||||
false /* hasMinimalSuggestion */,
|
false /* hasMinimalSuggestion */,
|
||||||
false /* allowsToBeAutoCorrected */,
|
false /* allowsToBeAutoCorrected */,
|
||||||
false /* isPunctuationSuggestions */,
|
false /* isPunctuationSuggestions */,
|
||||||
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||||
// When in fullscreen mode, show completions generated by the application
|
// When in fullscreen mode, show completions generated by the application
|
||||||
final SuggestedWords words = builder.build();
|
|
||||||
final boolean isAutoCorrection = false;
|
final boolean isAutoCorrection = false;
|
||||||
setSuggestions(words, isAutoCorrection);
|
setSuggestions(suggestedWords, isAutoCorrection);
|
||||||
setAutoCorrectionIndicator(isAutoCorrection);
|
setAutoCorrectionIndicator(isAutoCorrection);
|
||||||
// TODO: is this the right thing to do? What should we auto-correct to in
|
// 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.
|
// 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 =
|
final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
|
||||||
SuggestedWords.getTypedWordAndPreviousSuggestions(
|
SuggestedWords.getTypedWordAndPreviousSuggestions(
|
||||||
typedWord, previousSuggestions);
|
typedWord, previousSuggestions);
|
||||||
final SuggestedWords.Builder obsoleteSuggestionsBuilder =
|
final SuggestedWords obsoleteSuggestedWords =
|
||||||
new SuggestedWords.Builder(typedWordAndPreviousSuggestions,
|
SuggestedWords.getSuggestedWords(typedWordAndPreviousSuggestions,
|
||||||
false /* typedWordValid */,
|
false /* typedWordValid */,
|
||||||
false /* hasMinimalSuggestion */,
|
false /* hasMinimalSuggestion */,
|
||||||
false /* allowsToBeAutoCorrected */,
|
false /* allowsToBeAutoCorrected */,
|
||||||
false /* isPunctuationSuggestions */,
|
false /* isPunctuationSuggestions */,
|
||||||
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||||
showSuggestions(obsoleteSuggestionsBuilder.build(), typedWord);
|
showSuggestions(obsoleteSuggestedWords, typedWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,13 +183,12 @@ public class SettingsValues {
|
||||||
KeySpecParser.getLabel(puncSpec)));
|
KeySpecParser.getLabel(puncSpec)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final SuggestedWords.Builder builder = new SuggestedWords.Builder(puncList,
|
return SuggestedWords.getSuggestedWords(puncList,
|
||||||
false /* typedWordValid */,
|
false /* typedWordValid */,
|
||||||
false /* hasMinimalSuggestion */,
|
false /* hasMinimalSuggestion */,
|
||||||
false /* allowsToBeAutoCorrected */,
|
false /* allowsToBeAutoCorrected */,
|
||||||
true /* isPunctuationSuggestions */,
|
true /* isPunctuationSuggestions */,
|
||||||
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SuggestedWords createSuggestPuncOutputTextList(final String[] puncs) {
|
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 /* typedWordValid */,
|
||||||
false /* hasMinimalSuggestion */,
|
false /* hasMinimalSuggestion */,
|
||||||
false /* allowsToBeAutoCorrected */,
|
false /* allowsToBeAutoCorrected */,
|
||||||
true /* isPunctuationSuggestions */,
|
true /* isPunctuationSuggestions */,
|
||||||
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||||
return builder.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String createWordSeparators(final String weakSpaceStrippers,
|
private static String createWordSeparators(final String weakSpaceStrippers,
|
||||||
|
|
|
@ -269,13 +269,13 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
|
|
||||||
StringUtils.removeDupes(mSuggestions);
|
StringUtils.removeDupes(mSuggestions);
|
||||||
|
|
||||||
return new SuggestedWords.Builder(
|
return SuggestedWords.getSuggestedWords(
|
||||||
SuggestedWords.getFromCharSequenceList(mSuggestions),
|
SuggestedWords.getFromCharSequenceList(mSuggestions),
|
||||||
false /* typedWordValid */,
|
false /* typedWordValid */,
|
||||||
false /* hasMinimalSuggestion */,
|
false /* hasMinimalSuggestion */,
|
||||||
false /* allowsToBeAutoCorrected */,
|
false /* allowsToBeAutoCorrected */,
|
||||||
false /* isPunctuationSuggestions */,
|
false /* isPunctuationSuggestions */,
|
||||||
false /* shouldBlockAutoCorrectionBySafetyNet */).build();
|
false /* shouldBlockAutoCorrectionBySafetyNet */);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: cleanup dictionaries looking up and suggestions building with SuggestedWords.Builder
|
// TODO: cleanup dictionaries looking up and suggestions building with SuggestedWords.Builder
|
||||||
|
@ -445,12 +445,12 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
} else {
|
} else {
|
||||||
shouldBlockAutoCorrectionBySatefyNet = false;
|
shouldBlockAutoCorrectionBySatefyNet = false;
|
||||||
}
|
}
|
||||||
return new SuggestedWords.Builder(scoreInfoList,
|
return SuggestedWords.getSuggestedWords(scoreInfoList,
|
||||||
!allowsToBeAutoCorrected /* typedWordValid */,
|
!allowsToBeAutoCorrected /* typedWordValid */,
|
||||||
autoCorrectionAvailable /* hasMinimalSuggestion */,
|
autoCorrectionAvailable /* hasMinimalSuggestion */,
|
||||||
allowsToBeAutoCorrected /* allowsToBeAutoCorrected */,
|
allowsToBeAutoCorrected /* allowsToBeAutoCorrected */,
|
||||||
false /* isPunctuationSuggestions */,
|
false /* isPunctuationSuggestions */,
|
||||||
shouldBlockAutoCorrectionBySatefyNet).build();
|
shouldBlockAutoCorrectionBySatefyNet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class SuggestedWords {
|
||||||
public final boolean mAllowsToBeAutoCorrected;
|
public final boolean mAllowsToBeAutoCorrected;
|
||||||
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
||||||
|
|
||||||
SuggestedWords(final boolean typedWordValid,
|
private SuggestedWords(final boolean typedWordValid,
|
||||||
final boolean hasAutoCorrectionCandidate,
|
final boolean hasAutoCorrectionCandidate,
|
||||||
final boolean isPunctuationSuggestions,
|
final boolean isPunctuationSuggestions,
|
||||||
final boolean shouldBlockAutoCorrectionBySafetyNet,
|
final boolean shouldBlockAutoCorrectionBySafetyNet,
|
||||||
|
@ -76,7 +76,7 @@ public class SuggestedWords {
|
||||||
+ " mIsPunctuationSuggestions=" + mIsPunctuationSuggestions;
|
+ " mIsPunctuationSuggestions=" + mIsPunctuationSuggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
private static class Builder {
|
||||||
private final boolean mTypedWordValid;
|
private final boolean mTypedWordValid;
|
||||||
private final boolean mHasMinimalSuggestion;
|
private final boolean mHasMinimalSuggestion;
|
||||||
private final boolean mIsPunctuationSuggestions;
|
private final boolean mIsPunctuationSuggestions;
|
||||||
|
@ -84,7 +84,7 @@ public class SuggestedWords {
|
||||||
private final boolean mAllowsToBeAutoCorrected;
|
private final boolean mAllowsToBeAutoCorrected;
|
||||||
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
||||||
|
|
||||||
public Builder(final List<SuggestedWordInfo> suggestedWordInfoList,
|
private Builder(final List<SuggestedWordInfo> suggestedWordInfoList,
|
||||||
final boolean typedWordValid,
|
final boolean typedWordValid,
|
||||||
final boolean hasMinimalSuggestion,
|
final boolean hasMinimalSuggestion,
|
||||||
final boolean allowsToBeAutoCorrected,
|
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(
|
public static ArrayList<SuggestedWordInfo> getFromCharSequenceList(
|
||||||
final List<CharSequence> wordList) {
|
final List<CharSequence> wordList) {
|
||||||
final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>();
|
final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>();
|
||||||
|
|
Loading…
Reference in a new issue