diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java index 680ff0d255f83c85f146726243709a50798a386e..52096c8435fcb80007797ff7b06cccfb0d333a05 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java @@ -42,7 +42,6 @@ import java.io.IOException; import java.lang.ref.SoftReference; import java.util.HashMap; import java.util.Locale; -import java.util.Map; /** * This class represents a set of keyboards. Each of them represents a different keyboard @@ -75,7 +74,7 @@ public class KeyboardSet { } public static class KeysCache { - private final Map<Key, Key> mMap; + private final HashMap<Key, Key> mMap; public KeysCache() { mMap = new HashMap<Key, Key>(); @@ -108,7 +107,7 @@ public class KeyboardSet { int mOrientation; int mWidth; // KeyboardSet element id to keyboard layout XML id map. - final Map<Integer, Integer> mKeyboardSetElementIdToXmlIdMap = + final HashMap<Integer, Integer> mKeyboardSetElementIdToXmlIdMap = new HashMap<Integer, Integer>(); Params() {} } diff --git a/java/src/com/android/inputmethod/latin/AutoCorrection.java b/java/src/com/android/inputmethod/latin/AutoCorrection.java index 9c35f8f6f4ab35c0841b025670238cf4b7808ab3..ef88f9906e618b1949a5f48aae26f721df73e9ad 100644 --- a/java/src/com/android/inputmethod/latin/AutoCorrection.java +++ b/java/src/com/android/inputmethod/latin/AutoCorrection.java @@ -20,7 +20,7 @@ import android.text.TextUtils; import android.util.Log; import java.util.ArrayList; -import java.util.Map; +import java.util.HashMap; public class AutoCorrection { private static final boolean DBG = LatinImeLogger.sDBG; @@ -30,7 +30,7 @@ public class AutoCorrection { // Purely static class: can't instantiate. } - public static CharSequence computeAutoCorrectionWord(Map<String, Dictionary> dictionaries, + public static CharSequence computeAutoCorrectionWord(HashMap<String, Dictionary> dictionaries, WordComposer wordComposer, ArrayList<CharSequence> suggestions, int[] sortedScores, CharSequence consideredWord, double autoCorrectionThreshold, CharSequence whitelistedWord) { @@ -47,7 +47,7 @@ public class AutoCorrection { } public static boolean isValidWord( - Map<String, Dictionary> dictionaries, CharSequence word, boolean ignoreCase) { + HashMap<String, Dictionary> dictionaries, CharSequence word, boolean ignoreCase) { if (TextUtils.isEmpty(word)) { return false; } @@ -72,7 +72,7 @@ public class AutoCorrection { } public static boolean allowsToBeAutoCorrected( - Map<String, Dictionary> dictionaries, CharSequence word, boolean ignoreCase) { + HashMap<String, Dictionary> dictionaries, CharSequence word, boolean ignoreCase) { final WhitelistDictionary whitelistDictionary = (WhitelistDictionary)dictionaries.get(Suggest.DICT_KEY_WHITELIST); // If "word" is in the whitelist dictionary, it should not be auto corrected. @@ -87,9 +87,9 @@ public class AutoCorrection { return whiteListedWord != null; } - private static boolean hasAutoCorrectionForConsideredWord(Map<String, Dictionary> dictionaries, - WordComposer wordComposer, ArrayList<CharSequence> suggestions, - CharSequence consideredWord) { + private static boolean hasAutoCorrectionForConsideredWord( + HashMap<String, Dictionary> dictionaries, WordComposer wordComposer, + ArrayList<CharSequence> suggestions, CharSequence consideredWord) { if (TextUtils.isEmpty(consideredWord)) return false; return wordComposer.size() > 1 && suggestions.size() > 0 && !allowsToBeAutoCorrected(dictionaries, consideredWord, false); diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java index 79441c557bde4ca98fdb7dbbdd034c1a46354e5a..1c24cd11d3241892c12f077d8913a129b56ac98a 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java @@ -25,7 +25,6 @@ import android.util.Log; import java.io.File; import java.util.ArrayList; -import java.util.List; import java.util.Locale; /** @@ -264,9 +263,9 @@ class BinaryDictionaryGetter { * - Gets a file name from the fallback resource passed as an argument. * If that fails: * - Returns null. - * @return The address of a valid file, or null. + * @return The list of addresses of valid dictionary files, or null. */ - public static List<AssetFileAddress> getDictionaryFiles(final Locale locale, + public static ArrayList<AssetFileAddress> getDictionaryFiles(final Locale locale, final Context context, final int fallbackResId) { // cacheWordListsFromContentProvider returns the list of files it copied to local diff --git a/java/src/com/android/inputmethod/latin/DictionaryCollection.java b/java/src/com/android/inputmethod/latin/DictionaryCollection.java index c19a5a718afb82d49c4c70d7cd2ad7ede42dbec1..5de770a4a5a19f3521368fd16dd41a27f8bf0e9b 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryCollection.java +++ b/java/src/com/android/inputmethod/latin/DictionaryCollection.java @@ -22,7 +22,6 @@ import android.util.Log; import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; /** @@ -30,7 +29,7 @@ import java.util.concurrent.CopyOnWriteArrayList; */ public class DictionaryCollection extends Dictionary { private final String TAG = DictionaryCollection.class.getSimpleName(); - protected final List<Dictionary> mDictionaries; + protected final CopyOnWriteArrayList<Dictionary> mDictionaries; public DictionaryCollection() { mDictionaries = new CopyOnWriteArrayList<Dictionary>(); diff --git a/java/src/com/android/inputmethod/latin/DictionaryFactory.java b/java/src/com/android/inputmethod/latin/DictionaryFactory.java index 7a81f7bd59b8a6d9294c660eec2292275cdae1f6..77c685c504a2847d6ab0fe5ea5cb5295f63951d3 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFactory.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFactory.java @@ -22,8 +22,8 @@ import android.content.res.Resources; import android.util.Log; import java.io.File; +import java.util.ArrayList; import java.util.LinkedList; -import java.util.List; import java.util.Locale; /** @@ -52,8 +52,8 @@ public class DictionaryFactory { return new DictionaryCollection(createBinaryDictionary(context, fallbackResId, locale)); } - final List<Dictionary> dictList = new LinkedList<Dictionary>(); - final List<AssetFileAddress> assetFileList = + final LinkedList<Dictionary> dictList = new LinkedList<Dictionary>(); + final ArrayList<AssetFileAddress> assetFileList = BinaryDictionaryGetter.getDictionaryFiles(locale, context, fallbackResId); if (null != assetFileList) { for (final AssetFileAddress f : assetFileList) { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 234a501de62b8018a1c1389cabde0708df873e9f..d5cd35db6e499b055a706dce084e7c2e9bbf4481 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -73,7 +73,6 @@ import com.android.inputmethod.latin.suggestions.SuggestionsView; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; -import java.util.List; import java.util.Locale; /** @@ -919,7 +918,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return; } - final List<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords = + final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords = SuggestedWords.getFromApplicationSpecifiedCompletions( applicationSpecifiedCompletions); final SuggestedWords suggestedWords = new SuggestedWords( diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java index 5390ee39eff5b38e1334acda79467d8f4ac69e9a..683dafa86d474028d547571d2da7216d83f2ad53 100644 --- a/java/src/com/android/inputmethod/latin/LatinImeLogger.java +++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java @@ -22,8 +22,6 @@ import android.view.inputmethod.EditorInfo; import com.android.inputmethod.keyboard.Keyboard; -import java.util.List; - public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChangeListener { public static boolean sDBG = false; diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java index 4346a367107b8d0d8269a2cb0e8d30c2e2203e24..020b57caf9f005c762de62f2f0ca51ffe598d73b 100644 --- a/java/src/com/android/inputmethod/latin/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/SettingsValues.java @@ -30,8 +30,6 @@ import com.android.inputmethod.keyboard.internal.KeySpecParser; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.List; import java.util.Locale; public class SettingsValues { diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 69754d769b0f059e7572f39ac175b2f5fe96b225..08f0e425b1caf157319bf583dbb8515744da3394 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -30,15 +30,12 @@ import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; -import java.util.Map; -import java.util.Set; /** * This class loads a dictionary and provides a list of suggestions for a given sequence of * characters. This includes corrections and completions. */ public class Suggest implements Dictionary.WordCallback { - public static final String TAG = Suggest.class.getSimpleName(); public static final int APPROX_MAX_WORD_LENGTH = 32; @@ -87,8 +84,10 @@ public class Suggest implements Dictionary.WordCallback { private Dictionary mMainDict; private ContactsDictionary mContactsDict; private WhitelistDictionary mWhiteListDictionary; - private final Map<String, Dictionary> mUnigramDictionaries = new HashMap<String, Dictionary>(); - private final Map<String, Dictionary> mBigramDictionaries = new HashMap<String, Dictionary>(); + private final HashMap<String, Dictionary> mUnigramDictionaries = + new HashMap<String, Dictionary>(); + private final HashMap<String, Dictionary> mBigramDictionaries = + new HashMap<String, Dictionary>(); private int mPrefMaxSuggestions = 18; @@ -142,7 +141,7 @@ public class Suggest implements Dictionary.WordCallback { initWhitelistAndAutocorrectAndPool(context, locale); } - private static void addOrReplaceDictionary(Map<String, Dictionary> dictionaries, String key, + private static void addOrReplaceDictionary(HashMap<String, Dictionary> dictionaries, String key, Dictionary dict) { final Dictionary oldDict = (dict == null) ? dictionaries.remove(key) @@ -177,7 +176,7 @@ public class Suggest implements Dictionary.WordCallback { return mContactsDict; } - public Map<String, Dictionary> getUnigramDictionaries() { + public HashMap<String, Dictionary> getUnigramDictionaries() { return mUnigramDictionaries; } @@ -563,7 +562,7 @@ public class Suggest implements Dictionary.WordCallback { } public void close() { - final Set<Dictionary> dictionaries = new HashSet<Dictionary>(); + final HashSet<Dictionary> dictionaries = new HashSet<Dictionary>(); dictionaries.addAll(mUnigramDictionaries.values()); dictionaries.addAll(mBigramDictionaries.values()); for (final Dictionary dictionary : dictionaries) { diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index b63bc6c29e2058db274f80ba964ac6d9b2792a59..ef8e58e0c6bd1bbcdb0c92be1988fdf14eff6f24 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -21,22 +21,20 @@ import android.view.inputmethod.CompletionInfo; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; -import java.util.List; public class SuggestedWords { public static final SuggestedWords EMPTY = new SuggestedWords( - Collections.<SuggestedWordInfo>emptyList(), false, false, false, false, false); + new ArrayList<SuggestedWordInfo>(0), false, false, false, false, false); public final boolean mTypedWordValid; public final boolean mHasAutoCorrectionCandidate; public final boolean mIsPunctuationSuggestions; public final boolean mAllowsToBeAutoCorrected; public final boolean mIsObsoleteSuggestions; - private final List<SuggestedWordInfo> mSuggestedWordInfoList; + private final ArrayList<SuggestedWordInfo> mSuggestedWordInfoList; - public SuggestedWords(final List<SuggestedWordInfo> suggestedWordInfoList, + public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList, final boolean typedWordValid, final boolean hasAutoCorrectionCandidate, final boolean allowsToBeAutoCorrected, @@ -82,7 +80,7 @@ public class SuggestedWords { } public static ArrayList<SuggestedWordInfo> getFromCharSequenceList( - final List<CharSequence> wordList) { + final ArrayList<CharSequence> wordList) { final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>(); for (CharSequence word : wordList) { if (null != word) result.add(new SuggestedWordInfo(word)); @@ -90,7 +88,7 @@ public class SuggestedWords { return result; } - public static List<SuggestedWordInfo> getFromApplicationSpecifiedCompletions( + public static ArrayList<SuggestedWordInfo> getFromApplicationSpecifiedCompletions( final CompletionInfo[] infos) { final ArrayList<SuggestedWordInfo> result = new ArrayList<SuggestedWordInfo>(); for (CompletionInfo info : infos) { diff --git a/java/src/com/android/inputmethod/latin/XmlParseUtils.java b/java/src/com/android/inputmethod/latin/XmlParseUtils.java index e14c71cb5ed4fc71273fbcc85926a4ebda02af9f..481cdfa47dde64717d1945841536b592f5775903 100644 --- a/java/src/com/android/inputmethod/latin/XmlParseUtils.java +++ b/java/src/com/android/inputmethod/latin/XmlParseUtils.java @@ -24,6 +24,10 @@ import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; public class XmlParseUtils { + private XmlParseUtils() { + // This utility class is not publicly instantiable. + } + @SuppressWarnings("serial") public static class ParseException extends XmlPullParserException { public ParseException(String msg, XmlPullParser parser) { diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java index d3c3afb73515b2e2501af51ec3f883aab92e99c6..286bf0aea934d98d8e9c6e652553a56d163e8870 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java @@ -66,7 +66,6 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.Utils; import java.util.ArrayList; -import java.util.List; public class SuggestionsView extends RelativeLayout implements OnClickListener, OnLongClickListener { @@ -144,9 +143,9 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, public final float mMinMoreSuggestionsWidth; public final int mMoreSuggestionsBottomGap; - private final List<TextView> mWords; - private final List<View> mDividers; - private final List<TextView> mInfos; + private final ArrayList<TextView> mWords; + private final ArrayList<View> mDividers; + private final ArrayList<TextView> mInfos; private final int mColorValidTypedWord; private final int mColorTypedWord; @@ -174,7 +173,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, private final TextView mHintToSaveView; public SuggestionsViewParams(Context context, AttributeSet attrs, int defStyle, - List<TextView> words, List<View> dividers, List<TextView> infos) { + ArrayList<TextView> words, ArrayList<View> dividers, ArrayList<TextView> infos) { mWords = words; mDividers = dividers; mInfos = infos;