Merge "Kill methods with side-effects"
This commit is contained in:
commit
ae649580f4
2 changed files with 14 additions and 18 deletions
|
@ -28,6 +28,7 @@ import com.android.inputmethod.compat.InputTypeCompatUtils;
|
||||||
import com.android.inputmethod.compat.VibratorCompatWrapper;
|
import com.android.inputmethod.compat.VibratorCompatWrapper;
|
||||||
import com.android.inputmethod.keyboard.internal.KeySpecParser;
|
import com.android.inputmethod.keyboard.internal.KeySpecParser;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -174,28 +175,34 @@ public class SettingsValues {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SuggestedWords createSuggestPuncList(final String[] puncs) {
|
private static SuggestedWords createSuggestPuncList(final String[] puncs) {
|
||||||
final SuggestedWords.Builder builder = new SuggestedWords.Builder();
|
final ArrayList<CharSequence> puncList = new ArrayList<CharSequence>();
|
||||||
if (puncs != null) {
|
if (puncs != null) {
|
||||||
for (final String puncSpec : puncs) {
|
for (final String puncSpec : puncs) {
|
||||||
builder.addWord(KeySpecParser.getLabel(puncSpec));
|
puncList.add(KeySpecParser.getLabel(puncSpec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.setIsPunctuationSuggestions().build();
|
final SuggestedWords.Builder builder = new SuggestedWords.Builder()
|
||||||
|
.addWords(puncList, null)
|
||||||
|
.setIsPunctuationSuggestions();
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SuggestedWords createSuggestPuncOutputTextList(final String[] puncs) {
|
private static SuggestedWords createSuggestPuncOutputTextList(final String[] puncs) {
|
||||||
final SuggestedWords.Builder builder = new SuggestedWords.Builder();
|
final ArrayList<CharSequence> puncOutputTextList = new ArrayList<CharSequence>();
|
||||||
if (puncs != null) {
|
if (puncs != null) {
|
||||||
for (final String puncSpec : puncs) {
|
for (final String puncSpec : puncs) {
|
||||||
final String outputText = KeySpecParser.getOutputText(puncSpec);
|
final String outputText = KeySpecParser.getOutputText(puncSpec);
|
||||||
if (outputText != null) {
|
if (outputText != null) {
|
||||||
builder.addWord(outputText);
|
puncOutputTextList.add(outputText);
|
||||||
} else {
|
} else {
|
||||||
builder.addWord(KeySpecParser.getLabel(puncSpec));
|
puncOutputTextList.add(KeySpecParser.getLabel(puncSpec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder.setIsPunctuationSuggestions().build();
|
final SuggestedWords.Builder builder = new SuggestedWords.Builder()
|
||||||
|
.addWords(puncOutputTextList, null)
|
||||||
|
.setIsPunctuationSuggestions();
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String createWordSeparators(final String weakSpaceStrippers,
|
private static String createWordSeparators(final String weakSpaceStrippers,
|
||||||
|
|
|
@ -104,17 +104,6 @@ public class SuggestedWords {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addWord(CharSequence word) {
|
|
||||||
return addWord(word, null, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder addWord(CharSequence word, CharSequence debugString,
|
|
||||||
boolean isPreviousSuggestedWord) {
|
|
||||||
SuggestedWordInfo info = new SuggestedWordInfo(word, debugString,
|
|
||||||
isPreviousSuggestedWord);
|
|
||||||
return addWord(word, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* package for tests */
|
/* package for tests */
|
||||||
Builder addWord(CharSequence word, SuggestedWordInfo suggestedWordInfo) {
|
Builder addWord(CharSequence word, SuggestedWordInfo suggestedWordInfo) {
|
||||||
if (!TextUtils.isEmpty(suggestedWordInfo.mWord)) {
|
if (!TextUtils.isEmpty(suggestedWordInfo.mWord)) {
|
||||||
|
|
Loading…
Reference in a new issue