Remove a useless parameter.

Change-Id: I7625bf17158c207ad7e8cd496bef825704173c4c
main
Jean Chalard 2012-03-13 15:05:44 +09:00
parent 6fbcd0d219
commit d0d4074392
4 changed files with 40 additions and 27 deletions

View File

@ -922,11 +922,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return;
}
final List<CharSequence> applicationSuggestedWords =
final List<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords =
SuggestedWords.Builder.getFromApplicationSpecifiedCompletions(
applicationSpecifiedCompletions);
SuggestedWords.Builder builder = new SuggestedWords.Builder()
.addWords(applicationSuggestedWords, null)
.addWords(applicationSuggestedWords)
.setTypedWordValid(false)
.setHasMinimalSuggestion(false);
// When in fullscreen mode, show completions generated by the application

View File

@ -175,32 +175,36 @@ public class SettingsValues {
}
private static SuggestedWords createSuggestPuncList(final String[] puncs) {
final ArrayList<CharSequence> puncList = new ArrayList<CharSequence>();
final ArrayList<SuggestedWords.SuggestedWordInfo> puncList =
new ArrayList<SuggestedWords.SuggestedWordInfo>();
if (puncs != null) {
for (final String puncSpec : puncs) {
puncList.add(KeySpecParser.getLabel(puncSpec));
puncList.add(new SuggestedWords.SuggestedWordInfo(
KeySpecParser.getLabel(puncSpec)));
}
}
final SuggestedWords.Builder builder = new SuggestedWords.Builder()
.addWords(puncList, null)
.addWords(puncList)
.setIsPunctuationSuggestions();
return builder.build();
}
private static SuggestedWords createSuggestPuncOutputTextList(final String[] puncs) {
final ArrayList<CharSequence> puncOutputTextList = new ArrayList<CharSequence>();
final ArrayList<SuggestedWords.SuggestedWordInfo> puncOutputTextList =
new ArrayList<SuggestedWords.SuggestedWordInfo>();
if (puncs != null) {
for (final String puncSpec : puncs) {
final String outputText = KeySpecParser.getOutputText(puncSpec);
if (outputText != null) {
puncOutputTextList.add(outputText);
puncOutputTextList.add(new SuggestedWords.SuggestedWordInfo(outputText));
} else {
puncOutputTextList.add(KeySpecParser.getLabel(puncSpec));
puncOutputTextList.add(new SuggestedWords.SuggestedWordInfo(
KeySpecParser.getLabel(puncSpec)));
}
}
}
final SuggestedWords.Builder builder = new SuggestedWords.Builder()
.addWords(puncOutputTextList, null)
.addWords(puncOutputTextList)
.setIsPunctuationSuggestions();
return builder.build();
}

View File

@ -291,7 +291,8 @@ public class Suggest implements Dictionary.WordCallback {
StringUtils.removeDupes(mSuggestions);
return new SuggestedWords.Builder().addWords(mSuggestions, null)
return new SuggestedWords.Builder()
.addWords(SuggestedWords.Builder.getFromCharSequenceList(mSuggestions))
.setAllowsToBeAutoCorrected(false)
.setHasAutoCorrection(false);
}
@ -445,11 +446,12 @@ public class Suggest implements Dictionary.WordCallback {
scoreInfoList.add(new SuggestedWords.SuggestedWordInfo(mSuggestions.get(i),
"--", false));
}
builder = new SuggestedWords.Builder().addWords(mSuggestions, scoreInfoList)
builder = new SuggestedWords.Builder().addWords(scoreInfoList)
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected)
.setHasAutoCorrection(hasAutoCorrection);
} else {
builder = new SuggestedWords.Builder().addWords(mSuggestions, null)
builder = new SuggestedWords.Builder()
.addWords(SuggestedWords.Builder.getFromCharSequenceList(mSuggestions))
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected)
.setHasAutoCorrection(hasAutoCorrection);
}

View File

@ -87,19 +87,17 @@ public class SuggestedWords {
// Nothing to do here.
}
public Builder addWords(List<CharSequence> words,
List<SuggestedWordInfo> suggestedWordInfoList) {
final int N = words.size();
// TODO: the following method is a wrapper to satisfy tests. Update tests and remove it.
public Builder addWords(final List<CharSequence> words,
final List<SuggestedWordInfo> suggestedWordInfoList) {
return addWords(suggestedWordInfoList);
}
public Builder addWords(List<SuggestedWordInfo> suggestedWordInfoList) {
final int N = suggestedWordInfoList.size();
for (int i = 0; i < N; ++i) {
final CharSequence word = words.get(i);
SuggestedWordInfo suggestedWordInfo = null;
if (suggestedWordInfoList != null) {
suggestedWordInfo = suggestedWordInfoList.get(i);
}
if (suggestedWordInfo == null) {
suggestedWordInfo = new SuggestedWordInfo(word);
}
addWord(word, suggestedWordInfo);
SuggestedWordInfo suggestedWordInfo = suggestedWordInfoList.get(i);
addWord(suggestedWordInfo.mWord, suggestedWordInfo);
}
return this;
}
@ -113,11 +111,20 @@ public class SuggestedWords {
return this;
}
public static List<CharSequence> getFromApplicationSpecifiedCompletions(
public static List<SuggestedWordInfo> getFromCharSequenceList(
final List<CharSequence> wordList) {
final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>();
for (CharSequence word : wordList) {
if (null != word) result.add(new SuggestedWordInfo(word, null, false));
}
return result;
}
public static List<SuggestedWordInfo> getFromApplicationSpecifiedCompletions(
final CompletionInfo[] infos) {
final ArrayList<CharSequence> result = new ArrayList<CharSequence>();
final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>();
for (CompletionInfo info : infos) {
if (null != info) result.add(info.getText());
if (null != info) result.add(new SuggestedWordInfo(info.getText(), null, false));
}
return result;
}