From 88bf1ba5263f5a5c1df367ddc401db4109ef8677 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Tue, 13 Mar 2012 20:39:21 +0900 Subject: [PATCH] Move up the static methods of the Builder Change-Id: Ic3e07b745b7b24cae0f772ea49e0de615b44caf9 --- .../android/inputmethod/latin/LatinIME.java | 4 +- .../android/inputmethod/latin/Suggest.java | 4 +- .../inputmethod/latin/SuggestedWords.java | 76 +++++++++---------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index a6d2b7a05..08d54c6ff 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -924,7 +924,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } final List applicationSuggestedWords = - SuggestedWords.Builder.getFromApplicationSpecifiedCompletions( + SuggestedWords.getFromApplicationSpecifiedCompletions( applicationSpecifiedCompletions); SuggestedWords.Builder builder = new SuggestedWords.Builder(applicationSuggestedWords, false /* typedWordValid */, @@ -1788,7 +1788,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar previousSuggestions = SuggestedWords.EMPTY; } final ArrayList typedWordAndPreviousSuggestions = - SuggestedWords.Builder.getTypedWordAndPreviousSuggestions( + SuggestedWords.getTypedWordAndPreviousSuggestions( typedWord, previousSuggestions); final SuggestedWords.Builder obsoleteSuggestionsBuilder = new SuggestedWords.Builder(typedWordAndPreviousSuggestions, diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index b02c9738e..3acbd2792 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -270,7 +270,7 @@ public class Suggest implements Dictionary.WordCallback { StringUtils.removeDupes(mSuggestions); return new SuggestedWords.Builder( - SuggestedWords.Builder.getFromCharSequenceList(mSuggestions), + SuggestedWords.getFromCharSequenceList(mSuggestions), false /* typedWordValid */, false /* hasMinimalSuggestion */, false /* allowsToBeAutoCorrected */, @@ -428,7 +428,7 @@ public class Suggest implements Dictionary.WordCallback { "--", false)); } } else { - scoreInfoList = SuggestedWords.Builder.getFromCharSequenceList(mSuggestions); + scoreInfoList = SuggestedWords.getFromCharSequenceList(mSuggestions); } boolean autoCorrectionAvailable = hasAutoCorrection; diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 0def1d419..5fae06f73 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -98,44 +98,6 @@ public class SuggestedWords { mShouldBlockAutoCorrectionBySafetyNet = shouldBlockAutoCorrectionBySafetyNet; } - public static ArrayList getFromCharSequenceList( - final List wordList) { - final ArrayList result = new ArrayList(); - for (CharSequence word : wordList) { - if (null != word) result.add(new SuggestedWordInfo(word, null, false)); - } - return result; - } - - public static List getFromApplicationSpecifiedCompletions( - final CompletionInfo[] infos) { - final ArrayList result = new ArrayList(); - for (CompletionInfo info : infos) { - if (null != info) result.add(new SuggestedWordInfo(info.getText(), null, false)); - } - return result; - } - - // Should get rid of the first one (what the user typed previously) from suggestions - // and replace it with what the user currently typed. - public static ArrayList getTypedWordAndPreviousSuggestions( - final CharSequence typedWord, final SuggestedWords previousSuggestions) { - final ArrayList suggestionsList = new ArrayList(); - final HashSet alreadySeen = new HashSet(); - suggestionsList.add(new SuggestedWordInfo(typedWord, null, false)); - alreadySeen.add(typedWord.toString()); - final int previousSize = previousSuggestions.size(); - for (int pos = 1; pos < previousSize; pos++) { - final String prevWord = previousSuggestions.getWord(pos).toString(); - // Filter out duplicate suggestion. - if (!alreadySeen.contains(prevWord)) { - suggestionsList.add(new SuggestedWordInfo(prevWord, null, true)); - alreadySeen.add(prevWord); - } - } - return suggestionsList; - } - public SuggestedWords build() { return new SuggestedWords(mTypedWordValid, mHasMinimalSuggestion, mIsPunctuationSuggestions, mShouldBlockAutoCorrectionBySafetyNet, @@ -143,6 +105,44 @@ public class SuggestedWords { } } + public static ArrayList getFromCharSequenceList( + final List wordList) { + final ArrayList result = new ArrayList(); + for (CharSequence word : wordList) { + if (null != word) result.add(new SuggestedWordInfo(word, null, false)); + } + return result; + } + + public static List getFromApplicationSpecifiedCompletions( + final CompletionInfo[] infos) { + final ArrayList result = new ArrayList(); + for (CompletionInfo info : infos) { + if (null != info) result.add(new SuggestedWordInfo(info.getText(), null, false)); + } + return result; + } + + // Should get rid of the first one (what the user typed previously) from suggestions + // and replace it with what the user currently typed. + public static ArrayList getTypedWordAndPreviousSuggestions( + final CharSequence typedWord, final SuggestedWords previousSuggestions) { + final ArrayList suggestionsList = new ArrayList(); + final HashSet alreadySeen = new HashSet(); + suggestionsList.add(new SuggestedWordInfo(typedWord, null, false)); + alreadySeen.add(typedWord.toString()); + final int previousSize = previousSuggestions.size(); + for (int pos = 1; pos < previousSize; pos++) { + final String prevWord = previousSuggestions.getWord(pos).toString(); + // Filter out duplicate suggestion. + if (!alreadySeen.contains(prevWord)) { + suggestionsList.add(new SuggestedWordInfo(prevWord, null, true)); + alreadySeen.add(prevWord); + } + } + return suggestionsList; + } + public static class SuggestedWordInfo { public final CharSequence mWord; private final CharSequence mDebugString;