From c60fea852d0eaaed7f212dbab0af500d07188c69 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 13 Mar 2012 19:26:52 +0900 Subject: [PATCH] Make the suggested word list final in Builder. Change-Id: I2ddfab00dc8c141fc989a051f16eb2b3571b7e86 --- java/src/com/android/inputmethod/latin/LatinIME.java | 7 +++---- .../com/android/inputmethod/latin/SettingsValues.java | 6 ++---- java/src/com/android/inputmethod/latin/Suggest.java | 10 +++++----- .../com/android/inputmethod/latin/SuggestedWords.java | 11 ++--------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index a7985c37d..bd502a030 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -926,8 +926,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final List applicationSuggestedWords = SuggestedWords.Builder.getFromApplicationSpecifiedCompletions( applicationSpecifiedCompletions); - SuggestedWords.Builder builder = new SuggestedWords.Builder() - .setWords(applicationSuggestedWords) + SuggestedWords.Builder builder = new SuggestedWords.Builder(applicationSuggestedWords) .setTypedWordValid(false) .setHasMinimalSuggestion(false); // When in fullscreen mode, show completions generated by the application @@ -1786,8 +1785,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final ArrayList typedWordAndPreviousSuggestions = SuggestedWords.Builder.getTypedWordAndPreviousSuggestions( typedWord, previousSuggestions); - final SuggestedWords.Builder obsoleteSuggestionsBuilder = new SuggestedWords.Builder() - .setWords(typedWordAndPreviousSuggestions) + final SuggestedWords.Builder obsoleteSuggestionsBuilder = + new SuggestedWords.Builder(typedWordAndPreviousSuggestions) .setTypedWordValid(false) .setHasMinimalSuggestion(false); diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java index 9abea66b2..591f9f5a7 100644 --- a/java/src/com/android/inputmethod/latin/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/SettingsValues.java @@ -183,8 +183,7 @@ public class SettingsValues { KeySpecParser.getLabel(puncSpec))); } } - final SuggestedWords.Builder builder = new SuggestedWords.Builder() - .setWords(puncList) + final SuggestedWords.Builder builder = new SuggestedWords.Builder(puncList) .setIsPunctuationSuggestions(); return builder.build(); } @@ -203,8 +202,7 @@ public class SettingsValues { } } } - final SuggestedWords.Builder builder = new SuggestedWords.Builder() - .setWords(puncOutputTextList) + final SuggestedWords.Builder builder = new SuggestedWords.Builder(puncOutputTextList) .setIsPunctuationSuggestions(); return builder.build(); } diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 3015d75ce..40e9ef8e7 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -269,8 +269,8 @@ public class Suggest implements Dictionary.WordCallback { StringUtils.removeDupes(mSuggestions); - return new SuggestedWords.Builder() - .setWords(SuggestedWords.Builder.getFromCharSequenceList(mSuggestions)) + return new SuggestedWords.Builder( + SuggestedWords.Builder.getFromCharSequenceList(mSuggestions)) .setAllowsToBeAutoCorrected(false); } @@ -423,11 +423,11 @@ public class Suggest implements Dictionary.WordCallback { scoreInfoList.add(new SuggestedWords.SuggestedWordInfo(mSuggestions.get(i), "--", false)); } - builder = new SuggestedWords.Builder().setWords(scoreInfoList) + builder = new SuggestedWords.Builder(scoreInfoList) .setAllowsToBeAutoCorrected(allowsToBeAutoCorrected); } else { - builder = new SuggestedWords.Builder() - .setWords(SuggestedWords.Builder.getFromCharSequenceList(mSuggestions)) + builder = new SuggestedWords.Builder( + SuggestedWords.Builder.getFromCharSequenceList(mSuggestions)) .setAllowsToBeAutoCorrected(allowsToBeAutoCorrected); } diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index a9699af52..676563e1d 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -16,7 +16,6 @@ package com.android.inputmethod.latin; -import android.text.TextUtils; import android.view.inputmethod.CompletionInfo; import java.util.ArrayList; @@ -79,16 +78,10 @@ public class SuggestedWords { private boolean mIsPunctuationSuggestions; private boolean mShouldBlockAutoCorrectionBySafetyNet; private boolean mAllowsToBeAutoCorrected; - private List mSuggestedWordInfoList = - new ArrayList(); + private final List mSuggestedWordInfoList; - public Builder() { - // Nothing to do here. - } - - public Builder setWords(List suggestedWordInfoList) { + public Builder(final List suggestedWordInfoList) { mSuggestedWordInfoList = suggestedWordInfoList; - return this; } public static List getFromCharSequenceList(