am 6726bc90: Merge "Use Java 7 diamond operator"

* commit '6726bc90014c8d9c1710e4b52aa019d3e945f407':
  Use Java 7 diamond operator
main
Tadashi G. Takaoka 2014-05-23 16:44:51 +00:00 committed by Android Git Automerger
commit 3b500f7bd1
141 changed files with 366 additions and 592 deletions

View File

@ -17,7 +17,8 @@
# Keep classes that are used as a parameter type of methods that are also marked as keep # Keep classes that are used as a parameter type of methods that are also marked as keep
# to preserve changing those methods' signature. # to preserve changing those methods' signature.
-keep class com.android.inputmethod.latin.utils.LanguageModelParam
-keep class com.android.inputmethod.latin.AssetFileAddress -keep class com.android.inputmethod.latin.AssetFileAddress
-keep class com.android.inputmethod.latin.makedict.ProbabilityInfo
-keep class com.android.inputmethod.latin.Dictionary -keep class com.android.inputmethod.latin.Dictionary
-keep class com.android.inputmethod.latin.PrevWordsInfo
-keep class com.android.inputmethod.latin.makedict.ProbabilityInfo
-keep class com.android.inputmethod.latin.utils.LanguageModelParam

View File

@ -17,13 +17,8 @@
package com.android.inputmethod.accessibility; package com.android.inputmethod.accessibility;
import android.content.Context; import android.content.Context;
import android.os.SystemClock;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import android.view.MotionEvent;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardId;

View File

@ -27,7 +27,6 @@ import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.SuggestionSpanPickedNotificationReceiver; import com.android.inputmethod.latin.SuggestionSpanPickedNotificationReceiver;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
@ -73,7 +72,7 @@ public final class SuggestionSpanUtils {
return pickedWord; return pickedWord;
} }
final ArrayList<String> suggestionsList = CollectionUtils.newArrayList(); final ArrayList<String> suggestionsList = new ArrayList<>();
for (int i = 0; i < suggestedWords.size(); ++i) { for (int i = 0; i < suggestedWords.size(); ++i) {
if (suggestionsList.size() >= SuggestionSpan.SUGGESTIONS_MAX_SIZE) { if (suggestionsList.size() >= SuggestionSpan.SUGGESTIONS_MAX_SIZE) {
break; break;

View File

@ -16,7 +16,6 @@
package com.android.inputmethod.dictionarypack; package com.android.inputmethod.dictionarypack;
import android.app.DownloadManager;
import android.app.DownloadManager.Request; import android.app.DownloadManager.Request;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context; import android.content.Context;
@ -600,7 +599,7 @@ public final class ActionBatch {
private final Queue<Action> mActions; private final Queue<Action> mActions;
public ActionBatch() { public ActionBatch() {
mActions = new LinkedList<Action>(); mActions = new LinkedList<>();
} }
public void add(final Action a) { public void add(final Action a) {

View File

@ -29,7 +29,6 @@ import android.view.View;
import android.widget.ProgressBar; import android.widget.ProgressBar;
public class DictionaryDownloadProgressBar extends ProgressBar { public class DictionaryDownloadProgressBar extends ProgressBar {
@SuppressWarnings("unused")
private static final String TAG = DictionaryDownloadProgressBar.class.getSimpleName(); private static final String TAG = DictionaryDownloadProgressBar.class.getSimpleName();
private static final int NOT_A_DOWNLOADMANAGER_PENDING_ID = 0; private static final int NOT_A_DOWNLOADMANAGER_PENDING_ID = 0;
@ -119,7 +118,6 @@ public class DictionaryDownloadProgressBar extends ProgressBar {
try { try {
final UpdateHelper updateHelper = new UpdateHelper(); final UpdateHelper updateHelper = new UpdateHelper();
final Query query = new Query().setFilterById(mId); final Query query = new Query().setFilterById(mId);
int lastProgress = 0;
setIndeterminate(true); setIndeterminate(true);
while (!isInterrupted()) { while (!isInterrupted()) {
final Cursor cursor = mDownloadManagerWrapper.query(query); final Cursor cursor = mDownloadManagerWrapper.query(query);

View File

@ -18,8 +18,6 @@ package com.android.inputmethod.dictionarypack;
import android.view.View; import android.view.View;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -39,8 +37,8 @@ public class DictionaryListInterfaceState {
public int mStatus = MetadataDbHelper.STATUS_UNKNOWN; public int mStatus = MetadataDbHelper.STATUS_UNKNOWN;
} }
private HashMap<String, State> mWordlistToState = CollectionUtils.newHashMap(); private HashMap<String, State> mWordlistToState = new HashMap<>();
private ArrayList<View> mViewCache = CollectionUtils.newArrayList(); private ArrayList<View> mViewCache = new ArrayList<>();
public boolean isOpen(final String wordlistId) { public boolean isOpen(final String wordlistId) {
final State state = mWordlistToState.get(wordlistId); final State state = mWordlistToState.get(wordlistId);

View File

@ -357,7 +357,7 @@ public final class DictionaryProvider extends ContentProvider {
return Collections.<WordListInfo>emptyList(); return Collections.<WordListInfo>emptyList();
} }
try { try {
final HashMap<String, WordListInfo> dicts = new HashMap<String, WordListInfo>(); final HashMap<String, WordListInfo> dicts = new HashMap<>();
final int idIndex = results.getColumnIndex(MetadataDbHelper.WORDLISTID_COLUMN); final int idIndex = results.getColumnIndex(MetadataDbHelper.WORDLISTID_COLUMN);
final int localeIndex = results.getColumnIndex(MetadataDbHelper.LOCALE_COLUMN); final int localeIndex = results.getColumnIndex(MetadataDbHelper.LOCALE_COLUMN);
final int localFileNameIndex = final int localFileNameIndex =

View File

@ -33,13 +33,13 @@ import android.preference.PreferenceGroup;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import android.util.Log; import android.util.Log;
import android.view.animation.AnimationUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
@ -67,8 +67,8 @@ public final class DictionarySettingsFragment extends PreferenceFragment
private boolean mChangedSettings; private boolean mChangedSettings;
private DictionaryListInterfaceState mDictionaryListInterfaceState = private DictionaryListInterfaceState mDictionaryListInterfaceState =
new DictionaryListInterfaceState(); new DictionaryListInterfaceState();
private TreeMap<String, WordListPreference> mCurrentPreferenceMap = // never null
new TreeMap<String, WordListPreference>(); // never null private TreeMap<String, WordListPreference> mCurrentPreferenceMap = new TreeMap<>();
private final BroadcastReceiver mConnectivityChangedReceiver = new BroadcastReceiver() { private final BroadcastReceiver mConnectivityChangedReceiver = new BroadcastReceiver() {
@Override @Override
@ -280,19 +280,18 @@ public final class DictionarySettingsFragment extends PreferenceFragment
: activity.getContentResolver().query(contentUri, null, null, null, null); : activity.getContentResolver().query(contentUri, null, null, null, null);
if (null == cursor) { if (null == cursor) {
final ArrayList<Preference> result = new ArrayList<Preference>(); final ArrayList<Preference> result = new ArrayList<>();
result.add(createErrorMessage(activity, R.string.cannot_connect_to_dict_service)); result.add(createErrorMessage(activity, R.string.cannot_connect_to_dict_service));
return result; return result;
} }
try { try {
if (!cursor.moveToFirst()) { if (!cursor.moveToFirst()) {
final ArrayList<Preference> result = new ArrayList<Preference>(); final ArrayList<Preference> result = new ArrayList<>();
result.add(createErrorMessage(activity, R.string.no_dictionaries_available)); result.add(createErrorMessage(activity, R.string.no_dictionaries_available));
return result; return result;
} else { } else {
final String systemLocaleString = Locale.getDefault().toString(); final String systemLocaleString = Locale.getDefault().toString();
final TreeMap<String, WordListPreference> prefMap = final TreeMap<String, WordListPreference> prefMap = new TreeMap<>();
new TreeMap<String, WordListPreference>();
final int idIndex = cursor.getColumnIndex(MetadataDbHelper.WORDLISTID_COLUMN); final int idIndex = cursor.getColumnIndex(MetadataDbHelper.WORDLISTID_COLUMN);
final int versionIndex = cursor.getColumnIndex(MetadataDbHelper.VERSION_COLUMN); final int versionIndex = cursor.getColumnIndex(MetadataDbHelper.VERSION_COLUMN);
final int localeIndex = cursor.getColumnIndex(MetadataDbHelper.LOCALE_COLUMN); final int localeIndex = cursor.getColumnIndex(MetadataDbHelper.LOCALE_COLUMN);

View File

@ -175,7 +175,7 @@ public final class LocaleUtils {
return saveLocale; return saveLocale;
} }
private static final HashMap<String, Locale> sLocaleCache = new HashMap<String, Locale>(); private static final HashMap<String, Locale> sLocaleCache = new HashMap<>();
/** /**
* Creates a locale from a string specification. * Creates a locale from a string specification.

View File

@ -160,7 +160,7 @@ public class MetadataDbHelper extends SQLiteOpenHelper {
// this legacy database. New clients should make sure to always pass a client ID so as // this legacy database. New clients should make sure to always pass a client ID so as
// to avoid conflicts. // to avoid conflicts.
final String clientId = null != clientIdOrNull ? clientIdOrNull : ""; final String clientId = null != clientIdOrNull ? clientIdOrNull : "";
if (null == sInstanceMap) sInstanceMap = new TreeMap<String, MetadataDbHelper>(); if (null == sInstanceMap) sInstanceMap = new TreeMap<>();
MetadataDbHelper helper = sInstanceMap.get(clientId); MetadataDbHelper helper = sInstanceMap.get(clientId);
if (null == helper) { if (null == helper) {
helper = new MetadataDbHelper(context, clientId); helper = new MetadataDbHelper(context, clientId);
@ -639,7 +639,7 @@ public class MetadataDbHelper extends SQLiteOpenHelper {
public static ArrayList<DownloadRecord> getDownloadRecordsForDownloadId(final Context context, public static ArrayList<DownloadRecord> getDownloadRecordsForDownloadId(final Context context,
final long downloadId) { final long downloadId) {
final SQLiteDatabase defaultDb = getDb(context, ""); final SQLiteDatabase defaultDb = getDb(context, "");
final ArrayList<DownloadRecord> results = new ArrayList<DownloadRecord>(); final ArrayList<DownloadRecord> results = new ArrayList<>();
final Cursor cursor = defaultDb.query(CLIENT_TABLE_NAME, CLIENT_TABLE_COLUMNS, final Cursor cursor = defaultDb.query(CLIENT_TABLE_NAME, CLIENT_TABLE_COLUMNS,
null, null, null, null, null); null, null, null, null, null);
try { try {
@ -923,7 +923,7 @@ public class MetadataDbHelper extends SQLiteOpenHelper {
// - Remove the old entry from the table // - Remove the old entry from the table
// - Erase the old file // - Erase the old file
// We start by gathering the names of the files we should delete. // We start by gathering the names of the files we should delete.
final List<String> filenames = new LinkedList<String>(); final List<String> filenames = new LinkedList<>();
final Cursor c = db.query(METADATA_TABLE_NAME, final Cursor c = db.query(METADATA_TABLE_NAME,
new String[] { LOCAL_FILENAME_COLUMN }, new String[] { LOCAL_FILENAME_COLUMN },
LOCALE_COLUMN + " = ? AND " + LOCALE_COLUMN + " = ? AND " +

View File

@ -43,7 +43,7 @@ public class MetadataHandler {
* @return the constructed list of wordlist metadata. * @return the constructed list of wordlist metadata.
*/ */
private static List<WordListMetadata> makeMetadataObject(final Cursor results) { private static List<WordListMetadata> makeMetadataObject(final Cursor results) {
final ArrayList<WordListMetadata> buildingMetadata = new ArrayList<WordListMetadata>(); final ArrayList<WordListMetadata> buildingMetadata = new ArrayList<>();
if (null != results && results.moveToFirst()) { if (null != results && results.moveToFirst()) {
final int localeColumn = results.getColumnIndex(MetadataDbHelper.LOCALE_COLUMN); final int localeColumn = results.getColumnIndex(MetadataDbHelper.LOCALE_COLUMN);
final int typeColumn = results.getColumnIndex(MetadataDbHelper.TYPE_COLUMN); final int typeColumn = results.getColumnIndex(MetadataDbHelper.TYPE_COLUMN);

View File

@ -52,7 +52,7 @@ public class MetadataParser {
*/ */
private static WordListMetadata parseOneWordList(final JsonReader reader) private static WordListMetadata parseOneWordList(final JsonReader reader)
throws IOException, BadFormatException { throws IOException, BadFormatException {
final TreeMap<String, String> arguments = new TreeMap<String, String>(); final TreeMap<String, String> arguments = new TreeMap<>();
reader.beginObject(); reader.beginObject();
while (reader.hasNext()) { while (reader.hasNext()) {
final String name = reader.nextName(); final String name = reader.nextName();
@ -100,7 +100,7 @@ public class MetadataParser {
public static List<WordListMetadata> parseMetadata(final InputStreamReader input) public static List<WordListMetadata> parseMetadata(final InputStreamReader input)
throws IOException, BadFormatException { throws IOException, BadFormatException {
JsonReader reader = new JsonReader(input); JsonReader reader = new JsonReader(input);
final ArrayList<WordListMetadata> readInfo = new ArrayList<WordListMetadata>(); final ArrayList<WordListMetadata> readInfo = new ArrayList<>();
reader.beginArray(); reader.beginArray();
while (reader.hasNext()) { while (reader.hasNext()) {
final WordListMetadata thisMetadata = parseOneWordList(reader); final WordListMetadata thisMetadata = parseOneWordList(reader);

View File

@ -177,7 +177,7 @@ public final class UpdateHandler {
*/ */
public static boolean tryUpdate(final Context context, final boolean updateNow) { public static boolean tryUpdate(final Context context, final boolean updateNow) {
// TODO: loop through all clients instead of only doing the default one. // TODO: loop through all clients instead of only doing the default one.
final TreeSet<String> uris = new TreeSet<String>(); final TreeSet<String> uris = new TreeSet<>();
final Cursor cursor = MetadataDbHelper.queryClientIds(context); final Cursor cursor = MetadataDbHelper.queryClientIds(context);
if (null == cursor) return false; if (null == cursor) return false;
try { try {
@ -557,7 +557,7 @@ public final class UpdateHandler {
// Instantiation of a parameterized type is not possible in Java, so it's not possible to // Instantiation of a parameterized type is not possible in Java, so it's not possible to
// return the same type of list that was passed - probably the same reason why Collections // return the same type of list that was passed - probably the same reason why Collections
// does not do it. So we need to decide statically which concrete type to return. // does not do it. So we need to decide statically which concrete type to return.
return new LinkedList<T>(src); return new LinkedList<>(src);
} }
/** /**
@ -740,10 +740,10 @@ public final class UpdateHandler {
final ActionBatch actions = new ActionBatch(); final ActionBatch actions = new ActionBatch();
// Upgrade existing word lists // Upgrade existing word lists
DebugLogUtils.l("Comparing dictionaries"); DebugLogUtils.l("Comparing dictionaries");
final Set<String> wordListIds = new TreeSet<String>(); final Set<String> wordListIds = new TreeSet<>();
// TODO: Can these be null? // TODO: Can these be null?
if (null == from) from = new ArrayList<WordListMetadata>(); if (null == from) from = new ArrayList<>();
if (null == to) to = new ArrayList<WordListMetadata>(); if (null == to) to = new ArrayList<>();
for (WordListMetadata wlData : from) wordListIds.add(wlData.mId); for (WordListMetadata wlData : from) wordListIds.add(wlData.mId);
for (WordListMetadata wlData : to) wordListIds.add(wlData.mId); for (WordListMetadata wlData : to) wordListIds.add(wlData.mId);
for (String id : wordListIds) { for (String id : wordListIds) {

View File

@ -20,7 +20,6 @@ import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -44,8 +43,8 @@ public class CombinerChain {
private SpannableStringBuilder mStateFeedback; private SpannableStringBuilder mStateFeedback;
private final ArrayList<Combiner> mCombiners; private final ArrayList<Combiner> mCombiners;
private static final HashMap<String, Class> IMPLEMENTED_COMBINERS private static final HashMap<String, Class<? extends Combiner>> IMPLEMENTED_COMBINERS =
= new HashMap<String, Class>(); new HashMap<>();
static { static {
IMPLEMENTED_COMBINERS.put("MyanmarReordering", MyanmarReordering.class); IMPLEMENTED_COMBINERS.put("MyanmarReordering", MyanmarReordering.class);
} }
@ -63,7 +62,7 @@ public class CombinerChain {
* @param combinerList A list of combiners to be applied in order. * @param combinerList A list of combiners to be applied in order.
*/ */
public CombinerChain(final String initialText, final Combiner... combinerList) { public CombinerChain(final String initialText, final Combiner... combinerList) {
mCombiners = CollectionUtils.newArrayList(); mCombiners = new ArrayList<>();
// The dead key combiner is always active, and always first // The dead key combiner is always active, and always first
mCombiners.add(new DeadKeyCombiner()); mCombiners.add(new DeadKeyCombiner());
for (final Combiner combiner : combinerList) { for (final Combiner combiner : combinerList) {
@ -87,7 +86,7 @@ public class CombinerChain {
* @param newEvent the new event to process * @param newEvent the new event to process
*/ */
public void processEvent(final ArrayList<Event> previousEvents, final Event newEvent) { public void processEvent(final ArrayList<Event> previousEvents, final Event newEvent) {
final ArrayList<Event> modifiablePreviousEvents = new ArrayList<Event>(previousEvents); final ArrayList<Event> modifiablePreviousEvents = new ArrayList<>(previousEvents);
Event event = newEvent; Event event = newEvent;
for (final Combiner combiner : mCombiners) { for (final Combiner combiner : mCombiners) {
// A combiner can never return more than one event; it can return several // A combiner can never return more than one event; it can return several
@ -136,12 +135,13 @@ public class CombinerChain {
final Combiner[] combiners = new Combiner[combinerDescriptors.length]; final Combiner[] combiners = new Combiner[combinerDescriptors.length];
int i = 0; int i = 0;
for (final String combinerDescriptor : combinerDescriptors) { for (final String combinerDescriptor : combinerDescriptors) {
final Class combinerClass = IMPLEMENTED_COMBINERS.get(combinerDescriptor); final Class<? extends Combiner> combinerClass =
IMPLEMENTED_COMBINERS.get(combinerDescriptor);
if (null == combinerClass) { if (null == combinerClass) {
throw new RuntimeException("Unknown combiner descriptor: " + combinerDescriptor); throw new RuntimeException("Unknown combiner descriptor: " + combinerDescriptor);
} }
try { try {
combiners[i++] = (Combiner)combinerClass.newInstance(); combiners[i++] = combinerClass.newInstance();
} catch (InstantiationException e) { } catch (InstantiationException e) {
throw new RuntimeException("Unable to instantiate combiner: " + combinerDescriptor, throw new RuntimeException("Unable to instantiate combiner: " + combinerDescriptor,
e); e);

View File

@ -17,7 +17,6 @@
package com.android.inputmethod.event; package com.android.inputmethod.event;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -32,7 +31,7 @@ public class MyanmarReordering implements Combiner {
// U+200B ZERO WIDTH SPACE // U+200B ZERO WIDTH SPACE
private final static int ZERO_WIDTH_NON_JOINER = 0x200B; // should be 0x200C private final static int ZERO_WIDTH_NON_JOINER = 0x200B; // should be 0x200C
private final ArrayList<Event> mCurrentEvents = CollectionUtils.newArrayList(); private final ArrayList<Event> mCurrentEvents = new ArrayList<>();
// List of consonants : // List of consonants :
// U+1000 MYANMAR LETTER KA // U+1000 MYANMAR LETTER KA

View File

@ -22,9 +22,9 @@ import com.android.inputmethod.keyboard.internal.KeyVisualAttributes;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.KeyboardParams; import com.android.inputmethod.keyboard.internal.KeyboardParams;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.CoordinateUtils;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -83,7 +83,7 @@ public class Keyboard {
public final List<Key> mAltCodeKeysWhileTyping; public final List<Key> mAltCodeKeysWhileTyping;
public final KeyboardIconsSet mIconsSet; public final KeyboardIconsSet mIconsSet;
private final SparseArray<Key> mKeyCache = CollectionUtils.newSparseArray(); private final SparseArray<Key> mKeyCache = new SparseArray<>();
private final ProximityInfo mProximityInfo; private final ProximityInfo mProximityInfo;
private final boolean mProximityCharsCorrectionEnabled; private final boolean mProximityCharsCorrectionEnabled;
@ -103,8 +103,7 @@ public class Keyboard {
mTopPadding = params.mTopPadding; mTopPadding = params.mTopPadding;
mVerticalGap = params.mVerticalGap; mVerticalGap = params.mVerticalGap;
mSortedKeys = Collections.unmodifiableList( mSortedKeys = Collections.unmodifiableList(new ArrayList<>(params.mSortedKeys));
CollectionUtils.newArrayList(params.mSortedKeys));
mShiftKeys = Collections.unmodifiableList(params.mShiftKeys); mShiftKeys = Collections.unmodifiableList(params.mShiftKeys);
mAltCodeKeysWhileTyping = Collections.unmodifiableList(params.mAltCodeKeysWhileTyping); mAltCodeKeysWhileTyping = Collections.unmodifiableList(params.mAltCodeKeysWhileTyping);
mIconsSet = params.mIconsSet; mIconsSet = params.mIconsSet;
@ -159,7 +158,7 @@ public class Keyboard {
/** /**
* Return the sorted list of keys of this keyboard. * Return the sorted list of keys of this keyboard.
* The keys are sorted from top-left to bottom-right order. * The keys are sorted from top-left to bottom-right order.
* The list may contain {@link Spacer} object as well. * The list may contain {@link Key.Spacer} object as well.
* @return the sorted unmodifiable list of {@link Key}s of this keyboard. * @return the sorted unmodifiable list of {@link Key}s of this keyboard.
*/ */
public List<Key> getSortedKeys() { public List<Key> getSortedKeys() {

View File

@ -41,7 +41,6 @@ import com.android.inputmethod.latin.InputAttributes;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.SubtypeSwitcher;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import com.android.inputmethod.latin.utils.XmlParseUtils; import com.android.inputmethod.latin.utils.XmlParseUtils;
@ -81,7 +80,7 @@ public final class KeyboardLayoutSet {
// them from disappearing from sKeyboardCache. // them from disappearing from sKeyboardCache.
private static final Keyboard[] sForcibleKeyboardCache = new Keyboard[FORCIBLE_CACHE_SIZE]; private static final Keyboard[] sForcibleKeyboardCache = new Keyboard[FORCIBLE_CACHE_SIZE];
private static final HashMap<KeyboardId, SoftReference<Keyboard>> sKeyboardCache = private static final HashMap<KeyboardId, SoftReference<Keyboard>> sKeyboardCache =
CollectionUtils.newHashMap(); new HashMap<>();
private static final KeysCache sKeysCache = new KeysCache(); private static final KeysCache sKeysCache = new KeysCache();
@SuppressWarnings("serial") @SuppressWarnings("serial")
@ -117,7 +116,7 @@ public final class KeyboardLayoutSet {
int mKeyboardHeight; int mKeyboardHeight;
// Sparse array of KeyboardLayoutSet element parameters indexed by element's id. // Sparse array of KeyboardLayoutSet element parameters indexed by element's id.
final SparseArray<ElementParams> mKeyboardLayoutSetElementIdToParamsMap = final SparseArray<ElementParams> mKeyboardLayoutSetElementIdToParamsMap =
CollectionUtils.newSparseArray(); new SparseArray<>();
} }
public static void clearKeyboardCache() { public static void clearKeyboardCache() {
@ -181,7 +180,7 @@ public final class KeyboardLayoutSet {
} }
final KeyboardBuilder<KeyboardParams> builder = final KeyboardBuilder<KeyboardParams> builder =
new KeyboardBuilder<KeyboardParams>(mContext, new KeyboardParams()); new KeyboardBuilder<>(mContext, new KeyboardParams());
if (id.isAlphabetKeyboard()) { if (id.isAlphabetKeyboard()) {
builder.setAutoGenerate(sKeysCache); builder.setAutoGenerate(sKeysCache);
} }
@ -192,7 +191,7 @@ public final class KeyboardLayoutSet {
} }
builder.setProximityCharsCorrectionEnabled(elementParams.mProximityCharsCorrectionEnabled); builder.setProximityCharsCorrectionEnabled(elementParams.mProximityCharsCorrectionEnabled);
final Keyboard keyboard = builder.build(); final Keyboard keyboard = builder.build();
sKeyboardCache.put(id, new SoftReference<Keyboard>(keyboard)); sKeyboardCache.put(id, new SoftReference<>(keyboard));
if ((id.mElementId == KeyboardId.ELEMENT_ALPHABET if ((id.mElementId == KeyboardId.ELEMENT_ALPHABET
|| id.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) || id.mElementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED)
&& !mParams.mIsSpellChecker) { && !mParams.mIsSpellChecker) {

View File

@ -38,7 +38,6 @@ import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.TypefaceUtils; import com.android.inputmethod.latin.utils.TypefaceUtils;
import com.android.inputmethod.research.ResearchLogger; import com.android.inputmethod.research.ResearchLogger;
@ -110,7 +109,7 @@ public class KeyboardView extends View {
/** True if all keys should be drawn */ /** True if all keys should be drawn */
private boolean mInvalidateAllKeys; private boolean mInvalidateAllKeys;
/** The keys that should be drawn */ /** The keys that should be drawn */
private final HashSet<Key> mInvalidatedKeys = CollectionUtils.newHashSet(); private final HashSet<Key> mInvalidatedKeys = new HashSet<>();
/** The working rectangle variable */ /** The working rectangle variable */
private final Rect mWorkingRect = new Rect(); private final Rect mWorkingRect = new Rect();
/** The keyboard bitmap buffer for faster updates */ /** The keyboard bitmap buffer for faster updates */

View File

@ -57,7 +57,6 @@ import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.settings.DebugSettings; import com.android.inputmethod.latin.settings.DebugSettings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.SpacebarLanguageUtils; import com.android.inputmethod.latin.utils.SpacebarLanguageUtils;
import com.android.inputmethod.latin.utils.TypefaceUtils; import com.android.inputmethod.latin.utils.TypefaceUtils;
@ -150,8 +149,7 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
private final Paint mBackgroundDimAlphaPaint = new Paint(); private final Paint mBackgroundDimAlphaPaint = new Paint();
private boolean mNeedsToDimEntireKeyboard; private boolean mNeedsToDimEntireKeyboard;
private final View mMoreKeysKeyboardContainer; private final View mMoreKeysKeyboardContainer;
private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache = private final WeakHashMap<Key, Keyboard> mMoreKeysKeyboardCache = new WeakHashMap<>();
CollectionUtils.newWeakHashMap();
private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint; private final boolean mConfigShowMoreKeysKeyboardAtTouchedPoint;
// More keys panel (used by both more keys keyboard and more suggestions view) // More keys panel (used by both more keys keyboard and more suggestions view)
// TODO: Consider extending to support multiple more keys panels // TODO: Consider extending to support multiple more keys panels

View File

@ -37,7 +37,6 @@ import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.research.ResearchLogger; import com.android.inputmethod.research.ResearchLogger;
@ -144,7 +143,7 @@ public final class PointerTracker implements PointerTrackerQueue.Element,
// TODO: Device specific parameter would be better for device specific hack? // TODO: Device specific parameter would be better for device specific hack?
private static final float PHANTOM_SUDDEN_MOVE_THRESHOLD = 0.25f; // in keyWidth private static final float PHANTOM_SUDDEN_MOVE_THRESHOLD = 0.25f; // in keyWidth
private static final ArrayList<PointerTracker> sTrackers = CollectionUtils.newArrayList(); private static final ArrayList<PointerTracker> sTrackers = new ArrayList<>();
private static final PointerTrackerQueue sPointerTrackerQueue = new PointerTrackerQueue(); private static final PointerTrackerQueue sPointerTrackerQueue = new PointerTrackerQueue();
public final int mPointerId; public final int mPointerId;

View File

@ -22,7 +22,6 @@ import android.util.Log;
import com.android.inputmethod.keyboard.internal.TouchPositionCorrection; import com.android.inputmethod.keyboard.internal.TouchPositionCorrection;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.JniUtils; import com.android.inputmethod.latin.utils.JniUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -55,6 +54,7 @@ public class ProximityInfo {
private final List<Key>[] mGridNeighbors; private final List<Key>[] mGridNeighbors;
private final String mLocaleStr; private final String mLocaleStr;
@SuppressWarnings("unchecked")
ProximityInfo(final String localeStr, final int gridWidth, final int gridHeight, ProximityInfo(final String localeStr, final int gridWidth, final int gridHeight,
final int minWidth, final int height, final int mostCommonKeyWidth, final int minWidth, final int height, final int mostCommonKeyWidth,
final int mostCommonKeyHeight, final List<Key> sortedKeys, final int mostCommonKeyHeight, final List<Key> sortedKeys,
@ -360,7 +360,7 @@ y |---+---+---+---+-v-+-|-+---+---+---+---+---| | thresholdBase and get
for (int i = 0; i < gridSize; ++i) { for (int i = 0; i < gridSize; ++i) {
final int indexStart = i * keyCount; final int indexStart = i * keyCount;
final int indexEnd = indexStart + neighborCountPerCell[i]; final int indexEnd = indexStart + neighborCountPerCell[i];
final ArrayList<Key> neighbors = CollectionUtils.newArrayList(indexEnd - indexStart); final ArrayList<Key> neighbors = new ArrayList<>(indexEnd - indexStart);
for (int index = indexStart; index < indexEnd; index++) { for (int index = indexStart; index < indexEnd; index++) {
neighbors.add(neighborsFlatBuffer[index]); neighbors.add(neighborsFlatBuffer[index]);
} }

View File

@ -23,7 +23,6 @@ import android.util.Log;
import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.JsonUtils; import com.android.inputmethod.latin.utils.JsonUtils;
import java.util.ArrayDeque; import java.util.ArrayDeque;
@ -47,8 +46,8 @@ final class DynamicGridKeyboard extends Keyboard {
private final int mColumnsNum; private final int mColumnsNum;
private final int mMaxKeyCount; private final int mMaxKeyCount;
private final boolean mIsRecents; private final boolean mIsRecents;
private final ArrayDeque<GridKey> mGridKeys = CollectionUtils.newArrayDeque(); private final ArrayDeque<GridKey> mGridKeys = new ArrayDeque<>();
private final ArrayDeque<Key> mPendingKeys = CollectionUtils.newArrayDeque(); private final ArrayDeque<Key> mPendingKeys = new ArrayDeque<>();
private List<Key> mCachedGridKeys; private List<Key> mCachedGridKeys;
@ -131,7 +130,7 @@ final class DynamicGridKeyboard extends Keyboard {
} }
private void saveRecentKeys() { private void saveRecentKeys() {
final ArrayList<Object> keys = CollectionUtils.newArrayList(); final ArrayList<Object> keys = new ArrayList<>();
for (final Key key : mGridKeys) { for (final Key key : mGridKeys) {
if (key.getOutputText() != null) { if (key.getOutputText() != null) {
keys.add(key.getOutputText()); keys.add(key.getOutputText());

View File

@ -31,7 +31,6 @@ import com.android.inputmethod.keyboard.KeyboardLayoutSet;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -101,12 +100,11 @@ final class EmojiCategory {
private final Resources mRes; private final Resources mRes;
private final int mMaxPageKeyCount; private final int mMaxPageKeyCount;
private final KeyboardLayoutSet mLayoutSet; private final KeyboardLayoutSet mLayoutSet;
private final HashMap<String, Integer> mCategoryNameToIdMap = CollectionUtils.newHashMap(); private final HashMap<String, Integer> mCategoryNameToIdMap = new HashMap<>();
private final int[] mCategoryTabIconId = new int[sCategoryName.length]; private final int[] mCategoryTabIconId = new int[sCategoryName.length];
private final ArrayList<CategoryProperties> mShownCategories = private final ArrayList<CategoryProperties> mShownCategories = new ArrayList<>();
CollectionUtils.newArrayList(); private final ConcurrentHashMap<Long, DynamicGridKeyboard> mCategoryKeyboardMap =
private final ConcurrentHashMap<Long, DynamicGridKeyboard> new ConcurrentHashMap<>();
mCategoryKeyboardMap = new ConcurrentHashMap<Long, DynamicGridKeyboard>();
private int mCurrentCategoryId = EmojiCategory.ID_UNSPECIFIED; private int mCurrentCategoryId = EmojiCategory.ID_UNSPECIFIED;
private int mCurrentCategoryPageId = 0; private int mCurrentCategoryPageId = 0;
@ -257,7 +255,7 @@ final class EmojiCategory {
final int temp = sum; final int temp = sum;
sum += properties.mPageCount; sum += properties.mPageCount;
if (sum > position) { if (sum > position) {
return new Pair<Integer, Integer>(properties.mCategoryId, position - temp); return new Pair<>(properties.mCategoryId, position - temp);
} }
} }
return null; return null;
@ -343,7 +341,7 @@ final class EmojiCategory {
}; };
private static Key[][] sortKeysIntoPages(final List<Key> inKeys, final int maxPageCount) { private static Key[][] sortKeysIntoPages(final List<Key> inKeys, final int maxPageCount) {
final ArrayList<Key> keys = CollectionUtils.newArrayList(inKeys); final ArrayList<Key> keys = new ArrayList<>(inKeys);
Collections.sort(keys, EMOJI_KEY_COMPARATOR); Collections.sort(keys, EMOJI_KEY_COMPARATOR);
final int pageCount = (keys.size() - 1) / maxPageCount + 1; final int pageCount = (keys.size() - 1) / maxPageCount + 1;
final Key[][] retval = new Key[pageCount][maxPageCount]; final Key[][] retval = new Key[pageCount][maxPageCount];

View File

@ -27,7 +27,6 @@ import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardView; import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
final class EmojiPalettesAdapter extends PagerAdapter { final class EmojiPalettesAdapter extends PagerAdapter {
private static final String TAG = EmojiPalettesAdapter.class.getSimpleName(); private static final String TAG = EmojiPalettesAdapter.class.getSimpleName();
@ -35,8 +34,7 @@ final class EmojiPalettesAdapter extends PagerAdapter {
private final EmojiPageKeyboardView.OnKeyEventListener mListener; private final EmojiPageKeyboardView.OnKeyEventListener mListener;
private final DynamicGridKeyboard mRecentsKeyboard; private final DynamicGridKeyboard mRecentsKeyboard;
private final SparseArray<EmojiPageKeyboardView> mActiveKeyboardViews = private final SparseArray<EmojiPageKeyboardView> mActiveKeyboardViews = new SparseArray<>();
CollectionUtils.newSparseArray();
private final EmojiCategory mEmojiCategory; private final EmojiCategory mEmojiCategory;
private int mActivePosition = 0; private int mActivePosition = 0;

View File

@ -24,7 +24,6 @@ import android.graphics.PorterDuffXfermode;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.CoordinateUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,7 +31,7 @@ import java.util.ArrayList;
public final class DrawingPreviewPlacerView extends RelativeLayout { public final class DrawingPreviewPlacerView extends RelativeLayout {
private final int[] mKeyboardViewOrigin = CoordinateUtils.newInstance(); private final int[] mKeyboardViewOrigin = CoordinateUtils.newInstance();
private final ArrayList<AbstractDrawingPreview> mPreviews = CollectionUtils.newArrayList(); private final ArrayList<AbstractDrawingPreview> mPreviews = new ArrayList<>();
public DrawingPreviewPlacerView(final Context context, final AttributeSet attrs) { public DrawingPreviewPlacerView(final Context context, final AttributeSet attrs) {
super(context, attrs); super(context, attrs);

View File

@ -29,15 +29,13 @@ import android.util.SparseArray;
import android.view.View; import android.view.View;
import com.android.inputmethod.keyboard.PointerTracker; import com.android.inputmethod.keyboard.PointerTracker;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper; import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
/** /**
* Draw preview graphics of multiple gesture trails during gesture input. * Draw preview graphics of multiple gesture trails during gesture input.
*/ */
public final class GestureTrailsDrawingPreview extends AbstractDrawingPreview { public final class GestureTrailsDrawingPreview extends AbstractDrawingPreview {
private final SparseArray<GestureTrailDrawingPoints> mGestureTrails = private final SparseArray<GestureTrailDrawingPoints> mGestureTrails = new SparseArray<>();
CollectionUtils.newSparseArray();
private final GestureTrailDrawingParams mDrawingParams; private final GestureTrailDrawingParams mDrawingParams;
private final Paint mGesturePaint; private final Paint mGesturePaint;
private int mOffscreenWidth; private int mOffscreenWidth;

View File

@ -32,7 +32,6 @@ import android.widget.TextView;
import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.ViewLayoutUtils; import com.android.inputmethod.latin.utils.ViewLayoutUtils;
@ -48,9 +47,9 @@ import java.util.HashSet;
*/ */
public final class KeyPreviewChoreographer { public final class KeyPreviewChoreographer {
// Free {@link TextView} pool that can be used for key preview. // Free {@link TextView} pool that can be used for key preview.
private final ArrayDeque<TextView> mFreeKeyPreviewTextViews = CollectionUtils.newArrayDeque(); private final ArrayDeque<TextView> mFreeKeyPreviewTextViews = new ArrayDeque<>();
// Map from {@link Key} to {@link TextView} that is currently being displayed as key preview. // Map from {@link Key} to {@link TextView} that is currently being displayed as key preview.
private final HashMap<Key,TextView> mShowingKeyPreviewTextViews = CollectionUtils.newHashMap(); private final HashMap<Key,TextView> mShowingKeyPreviewTextViews = new HashMap<>();
private final KeyPreviewDrawParams mParams; private final KeyPreviewDrawParams mParams;
@ -83,7 +82,7 @@ public final class KeyPreviewChoreographer {
} }
public void dismissAllKeyPreviews() { public void dismissAllKeyPreviews() {
for (final Key key : new HashSet<Key>(mShowingKeyPreviewTextViews.keySet())) { for (final Key key : new HashSet<>(mShowingKeyPreviewTextViews.keySet())) {
dismissKeyPreview(key, false /* withAnimation */); dismissKeyPreview(key, false /* withAnimation */);
} }
} }

View File

@ -21,7 +21,6 @@ import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.XmlParseUtils; import com.android.inputmethod.latin.utils.XmlParseUtils;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -34,7 +33,7 @@ public final class KeyStylesSet {
private static final String TAG = KeyStylesSet.class.getSimpleName(); private static final String TAG = KeyStylesSet.class.getSimpleName();
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private final HashMap<String, KeyStyle> mStyles = CollectionUtils.newHashMap(); private final HashMap<String, KeyStyle> mStyles = new HashMap<>();
private final KeyboardTextsSet mTextsSet; private final KeyboardTextsSet mTextsSet;
private final KeyStyle mEmptyKeyStyle; private final KeyStyle mEmptyKeyStyle;
@ -75,7 +74,7 @@ public final class KeyStylesSet {
private static final class DeclaredKeyStyle extends KeyStyle { private static final class DeclaredKeyStyle extends KeyStyle {
private final HashMap<String, KeyStyle> mStyles; private final HashMap<String, KeyStyle> mStyles;
private final String mParentStyleName; private final String mParentStyleName;
private final SparseArray<Object> mStyleAttributes = CollectionUtils.newSparseArray(); private final SparseArray<Object> mStyleAttributes = new SparseArray<>();
public DeclaredKeyStyle(final String parentStyleName, final KeyboardTextsSet textsSet, public DeclaredKeyStyle(final String parentStyleName, final KeyboardTextsSet textsSet,
final HashMap<String, KeyStyle> styles) { final HashMap<String, KeyStyle> styles) {

View File

@ -17,14 +17,13 @@
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap; import java.util.HashMap;
public final class KeyboardCodesSet { public final class KeyboardCodesSet {
public static final String PREFIX_CODE = "!code/"; public static final String PREFIX_CODE = "!code/";
private static final HashMap<String, Integer> sNameToIdMap = CollectionUtils.newHashMap(); private static final HashMap<String, Integer> sNameToIdMap = new HashMap<>();
private KeyboardCodesSet() { private KeyboardCodesSet() {
// This utility class is not publicly instantiable. // This utility class is not publicly instantiable.

View File

@ -23,7 +23,6 @@ import android.util.Log;
import android.util.SparseIntArray; import android.util.SparseIntArray;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap; import java.util.HashMap;
@ -60,7 +59,7 @@ public final class KeyboardIconsSet {
private static final SparseIntArray ATTR_ID_TO_ICON_ID = new SparseIntArray(); private static final SparseIntArray ATTR_ID_TO_ICON_ID = new SparseIntArray();
// Icon name to icon id map. // Icon name to icon id map.
private static final HashMap<String, Integer> sNameToIdsMap = CollectionUtils.newHashMap(); private static final HashMap<String, Integer> sNameToIdsMap = new HashMap<>();
private static final Object[] NAMES_AND_ATTR_IDS = { private static final Object[] NAMES_AND_ATTR_IDS = {
NAME_UNDEFINED, ATTR_UNDEFINED, NAME_UNDEFINED, ATTR_UNDEFINED,

View File

@ -21,7 +21,6 @@ import android.util.SparseIntArray;
import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
@ -61,9 +60,9 @@ public class KeyboardParams {
public int GRID_HEIGHT; public int GRID_HEIGHT;
// Keys are sorted from top-left to bottom-right order. // Keys are sorted from top-left to bottom-right order.
public final SortedSet<Key> mSortedKeys = new TreeSet<Key>(ROW_COLUMN_COMPARATOR); public final SortedSet<Key> mSortedKeys = new TreeSet<>(ROW_COLUMN_COMPARATOR);
public final ArrayList<Key> mShiftKeys = CollectionUtils.newArrayList(); public final ArrayList<Key> mShiftKeys = new ArrayList<>();
public final ArrayList<Key> mAltCodeKeysWhileTyping = CollectionUtils.newArrayList(); public final ArrayList<Key> mAltCodeKeysWhileTyping = new ArrayList<>();
public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet(); public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
public final KeyboardTextsSet mTextsSet = new KeyboardTextsSet(); public final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
public final KeyStylesSet mKeyStyles = new KeyStylesSet(mTextsSet); public final KeyStylesSet mKeyStyles = new KeyStylesSet(mTextsSet);

View File

@ -23,7 +23,6 @@ import android.util.Xml;
import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.ResourceUtils;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -44,7 +43,7 @@ public final class KeyboardRow {
/** The height of this row. */ /** The height of this row. */
private final int mRowHeight; private final int mRowHeight;
private final ArrayDeque<RowAttributes> mRowAttributesStack = CollectionUtils.newArrayDeque(); private final ArrayDeque<RowAttributes> mRowAttributesStack = new ArrayDeque<>();
private static class RowAttributes { private static class RowAttributes {
/** Default width of a key in this row. */ /** Default width of a key in this row. */

View File

@ -22,7 +22,6 @@ import android.text.TextUtils;
import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.RunInLocale; import com.android.inputmethod.latin.utils.RunInLocale;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -38,7 +37,7 @@ public final class KeyboardTextsSet {
private String[] mTextsTable; private String[] mTextsTable;
// Resource name to text map. // Resource name to text map.
private HashMap<String, String> mResourceNameToTextsMap = CollectionUtils.newHashMap(); private HashMap<String, String> mResourceNameToTextsMap = new HashMap<>();
public void setLocale(final Locale locale, final Context context) { public void setLocale(final Locale locale, final Context context) {
mTextsTable = KeyboardTextsTable.getTextsTable(locale); mTextsTable = KeyboardTextsTable.getTextsTable(locale);

View File

@ -16,8 +16,6 @@
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
@ -44,14 +42,12 @@ import java.util.Locale;
*/ */
public final class KeyboardTextsTable { public final class KeyboardTextsTable {
// Name to index map. // Name to index map.
private static final HashMap<String, Integer> sNameToIndexesMap = CollectionUtils.newHashMap(); private static final HashMap<String, Integer> sNameToIndexesMap = new HashMap<>();
// Locale to texts table map. // Locale to texts table map.
private static final HashMap<String, String[]> sLocaleToTextsTableMap = private static final HashMap<String, String[]> sLocaleToTextsTableMap = new HashMap<>();
CollectionUtils.newHashMap();
// TODO: Remove this variable after debugging. // TODO: Remove this variable after debugging.
// Texts table to locale maps. // Texts table to locale maps.
private static final HashMap<String[], String> sTextsTableToLocaleMap = private static final HashMap<String[], String> sTextsTableToLocaleMap = new HashMap<>();
CollectionUtils.newHashMap();
public static String getText(final String name, final String[] textsTable) { public static String getText(final String name, final String[] textsTable) {
final Integer indexObj = sNameToIndexesMap.get(name); final Integer indexObj = sNameToIndexesMap.get(name);

View File

@ -17,12 +17,11 @@
package com.android.inputmethod.keyboard.internal; package com.android.inputmethod.keyboard.internal;
import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.HashMap; import java.util.HashMap;
public final class KeysCache { public final class KeysCache {
private final HashMap<Key, Key> mMap = CollectionUtils.newHashMap(); private final HashMap<Key, Key> mMap = new HashMap<>();
public void clear() { public void clear() {
mMap.clear(); mMap.clear();

View File

@ -149,7 +149,7 @@ public final class MoreKeySpec {
// Skip empty entry. // Skip empty entry.
if (pos - start > 0) { if (pos - start > 0) {
if (list == null) { if (list == null) {
list = CollectionUtils.newArrayList(); list = new ArrayList<>();
} }
list.add(text.substring(start, pos)); list.add(text.substring(start, pos));
} }

View File

@ -18,8 +18,6 @@ package com.android.inputmethod.keyboard.internal;
import android.util.Log; import android.util.Log;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
public final class PointerTrackerQueue { public final class PointerTrackerQueue {
@ -37,7 +35,7 @@ public final class PointerTrackerQueue {
// Note: {@link #mExpandableArrayOfActivePointers} and {@link #mArraySize} are synchronized by // Note: {@link #mExpandableArrayOfActivePointers} and {@link #mArraySize} are synchronized by
// {@link #mExpandableArrayOfActivePointers} // {@link #mExpandableArrayOfActivePointers}
private final ArrayList<Element> mExpandableArrayOfActivePointers = private final ArrayList<Element> mExpandableArrayOfActivePointers =
CollectionUtils.newArrayList(INITIAL_CAPACITY); new ArrayList<>(INITIAL_CAPACITY);
private int mArraySize = 0; private int mArraySize = 0;
public int size() { public int size() {

View File

@ -30,7 +30,6 @@ import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.WordProperty; import com.android.inputmethod.latin.makedict.WordProperty;
import com.android.inputmethod.latin.settings.NativeSuggestOptions; import com.android.inputmethod.latin.settings.NativeSuggestOptions;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils; import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.FileUtils; import com.android.inputmethod.latin.utils.FileUtils;
import com.android.inputmethod.latin.utils.JniUtils; import com.android.inputmethod.latin.utils.JniUtils;
import com.android.inputmethod.latin.utils.LanguageModelParam; import com.android.inputmethod.latin.utils.LanguageModelParam;
@ -104,8 +103,7 @@ public final class BinaryDictionary extends Dictionary {
private final NativeSuggestOptions mNativeSuggestOptions = new NativeSuggestOptions(); private final NativeSuggestOptions mNativeSuggestOptions = new NativeSuggestOptions();
private final SparseArray<DicTraverseSession> mDicTraverseSessions = private final SparseArray<DicTraverseSession> mDicTraverseSessions = new SparseArray<>();
CollectionUtils.newSparseArray();
// TODO: There should be a way to remove used DicTraverseSession objects from // TODO: There should be a way to remove used DicTraverseSession objects from
// {@code mDicTraverseSessions}. // {@code mDicTraverseSessions}.
@ -248,11 +246,11 @@ public final class BinaryDictionary extends Dictionary {
} }
final int[] outHeaderSize = new int[1]; final int[] outHeaderSize = new int[1];
final int[] outFormatVersion = new int[1]; final int[] outFormatVersion = new int[1];
final ArrayList<int[]> outAttributeKeys = CollectionUtils.newArrayList(); final ArrayList<int[]> outAttributeKeys = new ArrayList<>();
final ArrayList<int[]> outAttributeValues = CollectionUtils.newArrayList(); final ArrayList<int[]> outAttributeValues = new ArrayList<>();
getHeaderInfoNative(mNativeDict, outHeaderSize, outFormatVersion, outAttributeKeys, getHeaderInfoNative(mNativeDict, outHeaderSize, outFormatVersion, outAttributeKeys,
outAttributeValues); outAttributeValues);
final HashMap<String, String> attributes = new HashMap<String, String>(); final HashMap<String, String> attributes = new HashMap<>();
for (int i = 0; i < outAttributeKeys.size(); i++) { for (int i = 0; i < outAttributeKeys.size(); i++) {
final String attributeKey = StringUtils.getStringFromNullTerminatedCodePointArray( final String attributeKey = StringUtils.getStringFromNullTerminatedCodePointArray(
outAttributeKeys.get(i)); outAttributeKeys.get(i));
@ -312,7 +310,7 @@ public final class BinaryDictionary extends Dictionary {
inOutLanguageWeight[0] = mInputOutputLanguageWeight[0]; inOutLanguageWeight[0] = mInputOutputLanguageWeight[0];
} }
final int count = mOutputSuggestionCount[0]; final int count = mOutputSuggestionCount[0];
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList(); final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
for (int j = 0; j < count; ++j) { for (int j = 0; j < count; ++j) {
final int start = j * MAX_WORD_LENGTH; final int start = j * MAX_WORD_LENGTH;
int len = 0; int len = 0;
@ -386,10 +384,10 @@ public final class BinaryDictionary extends Dictionary {
final boolean[] outFlags = new boolean[FORMAT_WORD_PROPERTY_OUTPUT_FLAG_COUNT]; final boolean[] outFlags = new boolean[FORMAT_WORD_PROPERTY_OUTPUT_FLAG_COUNT];
final int[] outProbabilityInfo = final int[] outProbabilityInfo =
new int[FORMAT_WORD_PROPERTY_OUTPUT_PROBABILITY_INFO_COUNT]; new int[FORMAT_WORD_PROPERTY_OUTPUT_PROBABILITY_INFO_COUNT];
final ArrayList<int[]> outBigramTargets = CollectionUtils.newArrayList(); final ArrayList<int[]> outBigramTargets = new ArrayList<>();
final ArrayList<int[]> outBigramProbabilityInfo = CollectionUtils.newArrayList(); final ArrayList<int[]> outBigramProbabilityInfo = new ArrayList<>();
final ArrayList<int[]> outShortcutTargets = CollectionUtils.newArrayList(); final ArrayList<int[]> outShortcutTargets = new ArrayList<>();
final ArrayList<Integer> outShortcutProbabilities = CollectionUtils.newArrayList(); final ArrayList<Integer> outShortcutProbabilities = new ArrayList<>();
getWordPropertyNative(mNativeDict, codePoints, outCodePoints, outFlags, outProbabilityInfo, getWordPropertyNative(mNativeDict, codePoints, outCodePoints, outFlags, outProbabilityInfo,
outBigramTargets, outBigramProbabilityInfo, outShortcutTargets, outBigramTargets, outBigramProbabilityInfo, outShortcutTargets,
outShortcutProbabilities); outShortcutProbabilities);

View File

@ -29,7 +29,6 @@ import android.util.Log;
import com.android.inputmethod.dictionarypack.DictionaryPackConstants; import com.android.inputmethod.dictionarypack.DictionaryPackConstants;
import com.android.inputmethod.dictionarypack.MD5Calculator; import com.android.inputmethod.dictionarypack.MD5Calculator;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils; import com.android.inputmethod.latin.utils.DictionaryInfoUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils.DictionaryInfo; import com.android.inputmethod.latin.utils.DictionaryInfoUtils.DictionaryInfo;
import com.android.inputmethod.latin.utils.FileTransforms; import com.android.inputmethod.latin.utils.FileTransforms;
@ -44,8 +43,8 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -165,7 +164,7 @@ public final class BinaryDictionaryFileDumper {
if (cursor.getCount() <= 0 || !cursor.moveToFirst()) { if (cursor.getCount() <= 0 || !cursor.moveToFirst()) {
return Collections.<WordListInfo>emptyList(); return Collections.<WordListInfo>emptyList();
} }
final ArrayList<WordListInfo> list = CollectionUtils.newArrayList(); final ArrayList<WordListInfo> list = new ArrayList<>();
do { do {
final String wordListId = cursor.getString(0); final String wordListId = cursor.getString(0);
final String wordListLocale = cursor.getString(1); final String wordListLocale = cursor.getString(1);

View File

@ -24,7 +24,6 @@ import android.util.Log;
import com.android.inputmethod.latin.makedict.DictionaryHeader; import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils; import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils; import com.android.inputmethod.latin.utils.DictionaryInfoUtils;
import com.android.inputmethod.latin.utils.LocaleUtils; import com.android.inputmethod.latin.utils.LocaleUtils;
@ -160,7 +159,7 @@ final public class BinaryDictionaryGetter {
public static File[] getCachedWordLists(final String locale, final Context context) { public static File[] getCachedWordLists(final String locale, final Context context) {
final File[] directoryList = DictionaryInfoUtils.getCachedDirectoryList(context); final File[] directoryList = DictionaryInfoUtils.getCachedDirectoryList(context);
if (null == directoryList) return EMPTY_FILE_ARRAY; if (null == directoryList) return EMPTY_FILE_ARRAY;
final HashMap<String, FileAndMatchLevel> cacheFiles = CollectionUtils.newHashMap(); final HashMap<String, FileAndMatchLevel> cacheFiles = new HashMap<>();
for (File directory : directoryList) { for (File directory : directoryList) {
if (!directory.isDirectory()) continue; if (!directory.isDirectory()) continue;
final String dirLocale = final String dirLocale =
@ -273,7 +272,7 @@ final public class BinaryDictionaryGetter {
final DictPackSettings dictPackSettings = new DictPackSettings(context); final DictPackSettings dictPackSettings = new DictPackSettings(context);
boolean foundMainDict = false; boolean foundMainDict = false;
final ArrayList<AssetFileAddress> fileList = CollectionUtils.newArrayList(); final ArrayList<AssetFileAddress> fileList = new ArrayList<>();
// cachedWordLists may not be null, see doc for getCachedDictionaryList // cachedWordLists may not be null, see doc for getCachedDictionaryList
for (final File f : cachedWordLists) { for (final File f : cachedWordLists) {
final String wordListId = DictionaryInfoUtils.getWordListIdFromFileName(f.getName()); final String wordListId = DictionaryInfoUtils.getWordListIdFromFileName(f.getName());

View File

@ -31,7 +31,6 @@ import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.personalization.AccountUtils; import com.android.inputmethod.latin.personalization.AccountUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.ExecutorUtils; import com.android.inputmethod.latin.utils.ExecutorUtils;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
@ -180,7 +179,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
private void addWordsLocked(final Cursor cursor) { private void addWordsLocked(final Cursor cursor) {
int count = 0; int count = 0;
final ArrayList<String> names = CollectionUtils.newArrayList(); final ArrayList<String> names = new ArrayList<>();
while (!cursor.isAfterLast() && count < MAX_CONTACT_COUNT) { while (!cursor.isAfterLast() && count < MAX_CONTACT_COUNT) {
String name = cursor.getString(INDEX_NAME); String name = cursor.getString(INDEX_NAME);
if (isValidName(name)) { if (isValidName(name)) {
@ -298,7 +297,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary {
if (null == cursor) { if (null == cursor) {
return false; return false;
} }
final ArrayList<String> names = CollectionUtils.newArrayList(); final ArrayList<String> names = new ArrayList<>();
try { try {
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
while (!cursor.isAfterLast()) { while (!cursor.isAfterLast()) {

View File

@ -20,7 +20,6 @@ import android.util.Log;
import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -36,22 +35,22 @@ public final class DictionaryCollection extends Dictionary {
public DictionaryCollection(final String dictType) { public DictionaryCollection(final String dictType) {
super(dictType); super(dictType);
mDictionaries = CollectionUtils.newCopyOnWriteArrayList(); mDictionaries = new CopyOnWriteArrayList<>();
} }
public DictionaryCollection(final String dictType, final Dictionary... dictionaries) { public DictionaryCollection(final String dictType, final Dictionary... dictionaries) {
super(dictType); super(dictType);
if (null == dictionaries) { if (null == dictionaries) {
mDictionaries = CollectionUtils.newCopyOnWriteArrayList(); mDictionaries = new CopyOnWriteArrayList<>();
} else { } else {
mDictionaries = CollectionUtils.newCopyOnWriteArrayList(dictionaries); mDictionaries = new CopyOnWriteArrayList<>(dictionaries);
mDictionaries.removeAll(Collections.singleton(null)); mDictionaries.removeAll(Collections.singleton(null));
} }
} }
public DictionaryCollection(final String dictType, final Collection<Dictionary> dictionaries) { public DictionaryCollection(final String dictType, final Collection<Dictionary> dictionaries) {
super(dictType); super(dictType);
mDictionaries = CollectionUtils.newCopyOnWriteArrayList(dictionaries); mDictionaries = new CopyOnWriteArrayList<>(dictionaries);
mDictionaries.removeAll(Collections.singleton(null)); mDictionaries.removeAll(Collections.singleton(null));
} }
@ -67,7 +66,7 @@ public final class DictionaryCollection extends Dictionary {
ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getSuggestions(composer, ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getSuggestions(composer,
prevWordsInfo, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, prevWordsInfo, proximityInfo, blockOffensiveWords, additionalFeaturesOptions,
sessionId, inOutLanguageWeight); sessionId, inOutLanguageWeight);
if (null == suggestions) suggestions = CollectionUtils.newArrayList(); if (null == suggestions) suggestions = new ArrayList<>();
final int length = dictionaries.size(); final int length = dictionaries.size();
for (int i = 1; i < length; ++ i) { for (int i = 1; i < length; ++ i) {
final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getSuggestions(composer, final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getSuggestions(composer,

View File

@ -29,7 +29,6 @@ import com.android.inputmethod.latin.personalization.PersonalizationDataChunk;
import com.android.inputmethod.latin.personalization.PersonalizationDictionary; import com.android.inputmethod.latin.personalization.PersonalizationDictionary;
import com.android.inputmethod.latin.personalization.UserHistoryDictionary; import com.android.inputmethod.latin.personalization.UserHistoryDictionary;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations; import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DistracterFilter; import com.android.inputmethod.latin.utils.DistracterFilter;
import com.android.inputmethod.latin.utils.ExecutorUtils; import com.android.inputmethod.latin.utils.ExecutorUtils;
import com.android.inputmethod.latin.utils.LanguageModelParam; import com.android.inputmethod.latin.utils.LanguageModelParam;
@ -41,10 +40,10 @@ import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -75,7 +74,7 @@ public class DictionaryFacilitator {
}; };
private static final Map<String, Class<? extends ExpandableBinaryDictionary>> private static final Map<String, Class<? extends ExpandableBinaryDictionary>>
DICT_TYPE_TO_CLASS = CollectionUtils.newHashMap(); DICT_TYPE_TO_CLASS = new HashMap<>();
static { static {
DICT_TYPE_TO_CLASS.put(Dictionary.TYPE_USER_HISTORY, UserHistoryDictionary.class); DICT_TYPE_TO_CLASS.put(Dictionary.TYPE_USER_HISTORY, UserHistoryDictionary.class);
@ -100,7 +99,7 @@ public class DictionaryFacilitator {
public final Locale mLocale; public final Locale mLocale;
private Dictionary mMainDict; private Dictionary mMainDict;
public final ConcurrentHashMap<String, ExpandableBinaryDictionary> mSubDictMap = public final ConcurrentHashMap<String, ExpandableBinaryDictionary> mSubDictMap =
CollectionUtils.newConcurrentHashMap(); new ConcurrentHashMap<>();
public Dictionaries() { public Dictionaries() {
mLocale = null; mLocale = null;
@ -212,7 +211,7 @@ public class DictionaryFacilitator {
// We always try to have the main dictionary. Other dictionaries can be unused. // We always try to have the main dictionary. Other dictionaries can be unused.
final boolean reloadMainDictionary = localeHasBeenChanged || forceReloadMainDictionary; final boolean reloadMainDictionary = localeHasBeenChanged || forceReloadMainDictionary;
// TODO: Make subDictTypesToUse configurable by resource or a static final list. // TODO: Make subDictTypesToUse configurable by resource or a static final list.
final Set<String> subDictTypesToUse = CollectionUtils.newHashSet(); final HashSet<String> subDictTypesToUse = new HashSet<>();
if (useContactsDict) { if (useContactsDict) {
subDictTypesToUse.add(Dictionary.TYPE_CONTACTS); subDictTypesToUse.add(Dictionary.TYPE_CONTACTS);
} }
@ -231,7 +230,7 @@ public class DictionaryFacilitator {
newMainDict = mDictionaries.getDict(Dictionary.TYPE_MAIN); newMainDict = mDictionaries.getDict(Dictionary.TYPE_MAIN);
} }
final Map<String, ExpandableBinaryDictionary> subDicts = CollectionUtils.newHashMap(); final Map<String, ExpandableBinaryDictionary> subDicts = new HashMap<>();
for (final String dictType : SUB_DICT_TYPES) { for (final String dictType : SUB_DICT_TYPES) {
if (!subDictTypesToUse.contains(dictType)) { if (!subDictTypesToUse.contains(dictType)) {
// This dictionary will not be used. // This dictionary will not be used.
@ -304,7 +303,7 @@ public class DictionaryFacilitator {
final ArrayList<String> dictionaryTypes, final HashMap<String, File> dictionaryFiles, final ArrayList<String> dictionaryTypes, final HashMap<String, File> dictionaryFiles,
final Map<String, Map<String, String>> additionalDictAttributes) { final Map<String, Map<String, String>> additionalDictAttributes) {
Dictionary mainDictionary = null; Dictionary mainDictionary = null;
final Map<String, ExpandableBinaryDictionary> subDicts = CollectionUtils.newHashMap(); final Map<String, ExpandableBinaryDictionary> subDicts = new HashMap<>();
for (final String dictType : dictionaryTypes) { for (final String dictType : dictionaryTypes) {
if (dictType.equals(Dictionary.TYPE_MAIN)) { if (dictType.equals(Dictionary.TYPE_MAIN)) {

View File

@ -23,7 +23,6 @@ import android.content.res.Resources;
import android.util.Log; import android.util.Log;
import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils; import com.android.inputmethod.latin.utils.DictionaryInfoUtils;
import java.io.File; import java.io.File;
@ -55,7 +54,7 @@ public final class DictionaryFactory {
createReadOnlyBinaryDictionary(context, locale)); createReadOnlyBinaryDictionary(context, locale));
} }
final LinkedList<Dictionary> dictList = CollectionUtils.newLinkedList(); final LinkedList<Dictionary> dictList = new LinkedList<>();
final ArrayList<AssetFileAddress> assetFileList = final ArrayList<AssetFileAddress> assetFileList =
BinaryDictionaryGetter.getDictionaryFiles(locale, context); BinaryDictionaryGetter.getDictionaryFiles(locale, context);
if (null != assetFileList) { if (null != assetFileList) {

View File

@ -53,7 +53,6 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
private static final String TAG = ExpandableBinaryDictionary.class.getSimpleName(); private static final String TAG = ExpandableBinaryDictionary.class.getSimpleName();
/** Whether to print debug output to log */ /** Whether to print debug output to log */
private static boolean DEBUG = false;
private static final boolean DBG_STRESS_TEST = false; private static final boolean DBG_STRESS_TEST = false;
private static final int TIMEOUT_FOR_READ_OPS_IN_MILLISECONDS = 100; private static final int TIMEOUT_FOR_READ_OPS_IN_MILLISECONDS = 100;
@ -192,7 +191,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
} }
protected Map<String, String> getHeaderAttributeMap() { protected Map<String, String> getHeaderAttributeMap() {
HashMap<String, String> attributeMap = new HashMap<String, String>(); HashMap<String, String> attributeMap = new HashMap<>();
if (mAdditionalAttributeMap != null) { if (mAdditionalAttributeMap != null) {
attributeMap.putAll(mAdditionalAttributeMap); attributeMap.putAll(mAdditionalAttributeMap);
} }

View File

@ -20,7 +20,6 @@ import android.text.InputType;
import android.util.Log; import android.util.Log;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
@ -214,7 +213,7 @@ public final class InputAttributes {
} }
private static String toFlagsString(final int flags) { private static String toFlagsString(final int flags) {
final ArrayList<String> flagsArray = CollectionUtils.newArrayList(); final ArrayList<String> flagsArray = new ArrayList<>();
if (0 != (flags & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS)) if (0 != (flags & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS))
flagsArray.add("TYPE_TEXT_FLAG_NO_SUGGESTIONS"); flagsArray.add("TYPE_TEXT_FLAG_NO_SUGGESTIONS");
if (0 != (flags & InputType.TYPE_TEXT_FLAG_MULTI_LINE)) if (0 != (flags & InputType.TYPE_TEXT_FLAG_MULTI_LINE))

View File

@ -69,7 +69,7 @@ public final class LastComposedWord {
mInputPointers.copy(inputPointers); mInputPointers.copy(inputPointers);
} }
mTypedWord = typedWord; mTypedWord = typedWord;
mEvents = new ArrayList<Event>(events); mEvents = new ArrayList<>(events);
mCommittedWord = committedWord; mCommittedWord = committedWord;
mSeparatorString = separatorString; mSeparatorString = separatorString;
mActive = true; mActive = true;

View File

@ -81,7 +81,6 @@ import com.android.inputmethod.latin.suggestions.SuggestionStripView;
import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor; import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
import com.android.inputmethod.latin.utils.ApplicationUtils; import com.android.inputmethod.latin.utils.ApplicationUtils;
import com.android.inputmethod.latin.utils.CapsModeUtils; import com.android.inputmethod.latin.utils.CapsModeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.DialogUtils; import com.android.inputmethod.latin.utils.DialogUtils;
import com.android.inputmethod.latin.utils.DistracterFilterUsingSuggestion; import com.android.inputmethod.latin.utils.DistracterFilterUsingSuggestion;
@ -130,8 +129,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
this /* SuggestionStripViewAccessor */, mDictionaryFacilitator); this /* SuggestionStripViewAccessor */, mDictionaryFacilitator);
// We expect to have only one decoder in almost all cases, hence the default capacity of 1. // We expect to have only one decoder in almost all cases, hence the default capacity of 1.
// If it turns out we need several, it will get grown seamlessly. // If it turns out we need several, it will get grown seamlessly.
final SparseArray<HardwareEventDecoder> mHardwareEventDecoders final SparseArray<HardwareEventDecoder> mHardwareEventDecoders = new SparseArray<>(1);
= new SparseArray<HardwareEventDecoder>(1);
private View mExtractArea; private View mExtractArea;
private View mKeyPreviewBackingView; private View mKeyPreviewBackingView;

View File

@ -17,8 +17,6 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import com.android.inputmethod.keyboard.internal.KeySpecParser; import com.android.inputmethod.keyboard.internal.KeySpecParser;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -49,7 +47,7 @@ public final class PunctuationSuggestions extends SuggestedWords {
*/ */
public static PunctuationSuggestions newPunctuationSuggestions( public static PunctuationSuggestions newPunctuationSuggestions(
final String[] punctuationSpecs) { final String[] punctuationSpecs) {
final ArrayList<SuggestedWordInfo> puncuationsList = CollectionUtils.newArrayList(); final ArrayList<SuggestedWordInfo> puncuationsList = new ArrayList<>();
for (final String puncSpec : punctuationSpecs) { for (final String puncSpec : punctuationSpecs) {
puncuationsList.add(newHardCodedWordInfo(puncSpec)); puncuationsList.add(newHardCodedWordInfo(puncSpec));
} }

View File

@ -31,7 +31,6 @@ import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper; import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.Collections; import java.util.Collections;
@ -53,9 +52,9 @@ public final class RichInputMethodManager {
private InputMethodManagerCompatWrapper mImmWrapper; private InputMethodManagerCompatWrapper mImmWrapper;
private InputMethodInfoCache mInputMethodInfoCache; private InputMethodInfoCache mInputMethodInfoCache;
final HashMap<InputMethodInfo, List<InputMethodSubtype>> final HashMap<InputMethodInfo, List<InputMethodSubtype>>
mSubtypeListCacheWithImplicitlySelectedSubtypes = CollectionUtils.newHashMap(); mSubtypeListCacheWithImplicitlySelectedSubtypes = new HashMap<>();
final HashMap<InputMethodInfo, List<InputMethodSubtype>> final HashMap<InputMethodInfo, List<InputMethodSubtype>>
mSubtypeListCacheWithoutImplicitlySelectedSubtypes = CollectionUtils.newHashMap(); mSubtypeListCacheWithoutImplicitlySelectedSubtypes = new HashMap<>();
private static final int INDEX_NOT_FOUND = -1; private static final int INDEX_NOT_FOUND = -1;

View File

@ -255,8 +255,7 @@ public final class SubtypeSwitcher {
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() { public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() {
final Locale systemLocale = mResources.getConfiguration().locale; final Locale systemLocale = mResources.getConfiguration().locale;
final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes = new HashSet<>();
new HashSet<InputMethodSubtype>();
final InputMethodManager inputMethodManager = mRichImm.getInputMethodManager(); final InputMethodManager inputMethodManager = mRichImm.getInputMethodManager();
final List<InputMethodInfo> enabledInputMethodInfoList = final List<InputMethodInfo> enabledInputMethodInfoList =
inputMethodManager.getEnabledInputMethodList(); inputMethodManager.getEnabledInputMethodList();

View File

@ -24,7 +24,6 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.utils.AutoCorrectionUtils; import com.android.inputmethod.latin.utils.AutoCorrectionUtils;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils; import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
import com.android.inputmethod.latin.utils.SuggestionResults; import com.android.inputmethod.latin.utils.SuggestionResults;
@ -106,7 +105,7 @@ public final class Suggest {
final ArrayList<SuggestedWordInfo> rawSuggestions; final ArrayList<SuggestedWordInfo> rawSuggestions;
if (ProductionFlag.INCLUDE_RAW_SUGGESTIONS) { if (ProductionFlag.INCLUDE_RAW_SUGGESTIONS) {
rawSuggestions = CollectionUtils.newArrayList(); rawSuggestions = new ArrayList<>();
} else { } else {
rawSuggestions = null; rawSuggestions = null;
} }
@ -175,7 +174,7 @@ public final class Suggest {
} }
final ArrayList<SuggestedWordInfo> suggestionsContainer = final ArrayList<SuggestedWordInfo> suggestionsContainer =
CollectionUtils.newArrayList(suggestionResults); new ArrayList<>(suggestionResults);
final int suggestionsCount = suggestionsContainer.size(); final int suggestionsCount = suggestionsContainer.size();
if (isFirstCharCapitalized || isAllUpperCase || 0 != trailingSingleQuotesCount) { if (isFirstCharCapitalized || isAllUpperCase || 0 != trailingSingleQuotesCount) {
for (int i = 0; i < suggestionsCount; ++i) { for (int i = 0; i < suggestionsCount; ++i) {
@ -227,7 +226,7 @@ public final class Suggest {
final OnGetSuggestedWordsCallback callback) { final OnGetSuggestedWordsCallback callback) {
final ArrayList<SuggestedWordInfo> rawSuggestions; final ArrayList<SuggestedWordInfo> rawSuggestions;
if (ProductionFlag.INCLUDE_RAW_SUGGESTIONS) { if (ProductionFlag.INCLUDE_RAW_SUGGESTIONS) {
rawSuggestions = CollectionUtils.newArrayList(); rawSuggestions = new ArrayList<>();
} else { } else {
rawSuggestions = null; rawSuggestions = null;
} }
@ -239,7 +238,7 @@ public final class Suggest {
} }
final ArrayList<SuggestedWordInfo> suggestionsContainer = final ArrayList<SuggestedWordInfo> suggestionsContainer =
CollectionUtils.newArrayList(suggestionResults); new ArrayList<>(suggestionResults);
final int suggestionsCount = suggestionsContainer.size(); final int suggestionsCount = suggestionsContainer.size();
final boolean isFirstCharCapitalized = wordComposer.wasShiftedNoLock(); final boolean isFirstCharCapitalized = wordComposer.wasShiftedNoLock();
final boolean isAllUpperCase = wordComposer.isAllUpperCase(); final boolean isAllUpperCase = wordComposer.isAllUpperCase();
@ -282,8 +281,7 @@ public final class Suggest {
final SuggestedWordInfo typedWordInfo = suggestions.get(0); final SuggestedWordInfo typedWordInfo = suggestions.get(0);
typedWordInfo.setDebugString("+"); typedWordInfo.setDebugString("+");
final int suggestionsSize = suggestions.size(); final int suggestionsSize = suggestions.size();
final ArrayList<SuggestedWordInfo> suggestionsList = final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>(suggestionsSize);
CollectionUtils.newArrayList(suggestionsSize);
suggestionsList.add(typedWordInfo); suggestionsList.add(typedWordInfo);
// Note: i here is the index in mScores[], but the index in mSuggestions is one more // Note: i here is the index in mScores[], but the index in mSuggestions is one more
// than i because we added the typed word to mSuggestions without touching mScores. // than i because we added the typed word to mSuggestions without touching mScores.

View File

@ -19,7 +19,6 @@ package com.android.inputmethod.latin;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.CompletionInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -34,8 +33,7 @@ public class SuggestedWords {
// The maximum number of suggestions available. // The maximum number of suggestions available.
public static final int MAX_SUGGESTIONS = 18; public static final int MAX_SUGGESTIONS = 18;
private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = new ArrayList<>(0);
CollectionUtils.newArrayList(0);
public static final SuggestedWords EMPTY = new SuggestedWords( public static final SuggestedWords EMPTY = new SuggestedWords(
EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false, false, false, false); EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false, false, false, false);
@ -165,7 +163,7 @@ public class SuggestedWords {
public static ArrayList<SuggestedWordInfo> getFromApplicationSpecifiedCompletions( public static ArrayList<SuggestedWordInfo> getFromApplicationSpecifiedCompletions(
final CompletionInfo[] infos) { final CompletionInfo[] infos) {
final ArrayList<SuggestedWordInfo> result = CollectionUtils.newArrayList(); final ArrayList<SuggestedWordInfo> result = new ArrayList<>();
for (final CompletionInfo info : infos) { for (final CompletionInfo info : infos) {
if (null == info || null == info.getText()) { if (null == info || null == info.getText()) {
continue; continue;
@ -179,8 +177,8 @@ public class SuggestedWords {
// and replace it with what the user currently typed. // and replace it with what the user currently typed.
public static ArrayList<SuggestedWordInfo> getTypedWordAndPreviousSuggestions( public static ArrayList<SuggestedWordInfo> getTypedWordAndPreviousSuggestions(
final String typedWord, final SuggestedWords previousSuggestions) { final String typedWord, final SuggestedWords previousSuggestions) {
final ArrayList<SuggestedWordInfo> suggestionsList = CollectionUtils.newArrayList(); final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>();
final HashSet<String> alreadySeen = CollectionUtils.newHashSet(); final HashSet<String> alreadySeen = new HashSet<>();
suggestionsList.add(new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE, suggestionsList.add(new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE,
SuggestedWordInfo.KIND_TYPED, Dictionary.DICTIONARY_USER_TYPED, SuggestedWordInfo.KIND_TYPED, Dictionary.DICTIONARY_USER_TYPED,
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */, SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
@ -337,7 +335,7 @@ public class SuggestedWords {
// SuggestedWords is an immutable object, as much as possible. We must not just remove // SuggestedWords is an immutable object, as much as possible. We must not just remove
// words from the member ArrayList as some other parties may expect the object to never change. // words from the member ArrayList as some other parties may expect the object to never change.
public SuggestedWords getSuggestedWordsExcludingTypedWord() { public SuggestedWords getSuggestedWordsExcludingTypedWord() {
final ArrayList<SuggestedWordInfo> newSuggestions = CollectionUtils.newArrayList(); final ArrayList<SuggestedWordInfo> newSuggestions = new ArrayList<>();
String typedWord = null; String typedWord = null;
for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) { for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) {
final SuggestedWordInfo info = mSuggestedWordInfoList.get(i); final SuggestedWordInfo info = mSuggestedWordInfoList.get(i);
@ -361,7 +359,7 @@ public class SuggestedWords {
// we should only suggest replacements for this last word. // we should only suggest replacements for this last word.
// TODO: make this work with languages without spaces. // TODO: make this work with languages without spaces.
public SuggestedWords getSuggestedWordsForLastWordOfPhraseGesture() { public SuggestedWords getSuggestedWordsForLastWordOfPhraseGesture() {
final ArrayList<SuggestedWordInfo> newSuggestions = CollectionUtils.newArrayList(); final ArrayList<SuggestedWordInfo> newSuggestions = new ArrayList<>();
for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) { for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) {
final SuggestedWordInfo info = mSuggestedWordInfoList.get(i); final SuggestedWordInfo info = mSuggestedWordInfoList.get(i);
final int indexOfLastSpace = info.mWord.lastIndexOf(Constants.CODE_SPACE) + 1; final int indexOfLastSpace = info.mWord.lastIndexOf(Constants.CODE_SPACE) + 1;

View File

@ -18,7 +18,6 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.event.CombinerChain; import com.android.inputmethod.event.CombinerChain;
import com.android.inputmethod.event.Event; import com.android.inputmethod.event.Event;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
@ -79,7 +78,7 @@ public final class WordComposer {
public WordComposer() { public WordComposer() {
mCombinerChain = new CombinerChain(""); mCombinerChain = new CombinerChain("");
mEvents = CollectionUtils.newArrayList(); mEvents = new ArrayList<>();
mAutoCorrection = null; mAutoCorrection = null;
mIsResumed = false; mIsResumed = false;
mIsBatchMode = false; mIsBatchMode = false;

View File

@ -27,7 +27,6 @@ import com.android.inputmethod.latin.BinaryDictionaryFileDumper;
import com.android.inputmethod.latin.BinaryDictionaryGetter; import com.android.inputmethod.latin.BinaryDictionaryGetter;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.makedict.DictionaryHeader; import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DialogUtils; import com.android.inputmethod.latin.utils.DialogUtils;
import com.android.inputmethod.latin.utils.DictionaryInfoUtils; import com.android.inputmethod.latin.utils.DictionaryInfoUtils;
import com.android.inputmethod.latin.utils.LocaleUtils; import com.android.inputmethod.latin.utils.LocaleUtils;
@ -50,7 +49,7 @@ public class ExternalDictionaryGetterForDebug {
private static String[] findDictionariesInTheDownloadedFolder() { private static String[] findDictionariesInTheDownloadedFolder() {
final File[] files = new File(SOURCE_FOLDER).listFiles(); final File[] files = new File(SOURCE_FOLDER).listFiles();
final ArrayList<String> eligibleList = CollectionUtils.newArrayList(); final ArrayList<String> eligibleList = new ArrayList<>();
for (File f : files) { for (File f : files) {
final DictionaryHeader header = DictionaryInfoUtils.getDictionaryFileHeaderOrNull(f); final DictionaryHeader header = DictionaryInfoUtils.getDictionaryFileHeaderOrNull(f);
if (null == header) continue; if (null == header) continue;

View File

@ -49,7 +49,6 @@ import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations; import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor; import com.android.inputmethod.latin.suggestions.SuggestionStripViewAccessor;
import com.android.inputmethod.latin.utils.AsyncResultHolder; import com.android.inputmethod.latin.utils.AsyncResultHolder;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils; import com.android.inputmethod.latin.utils.InputTypeUtils;
import com.android.inputmethod.latin.utils.LatinImeLoggerUtils; import com.android.inputmethod.latin.utils.LatinImeLoggerUtils;
import com.android.inputmethod.latin.utils.RecapitalizeStatus; import com.android.inputmethod.latin.utils.RecapitalizeStatus;
@ -89,7 +88,7 @@ public final class InputLogic {
private int mDeleteCount; private int mDeleteCount;
private long mLastKeyTime; private long mLastKeyTime;
public final TreeSet<Long> mCurrentlyPressedHardwareKeys = CollectionUtils.newTreeSet(); public final TreeSet<Long> mCurrentlyPressedHardwareKeys = new TreeSet<>();
// Keeps track of most recently inserted text (multi-character key) for reverting // Keeps track of most recently inserted text (multi-character key) for reverting
private String mEnteredText; private String mEnteredText;
@ -1270,7 +1269,7 @@ public final class InputLogic {
return; return;
} }
final AsyncResultHolder<SuggestedWords> holder = new AsyncResultHolder<SuggestedWords>(); final AsyncResultHolder<SuggestedWords> holder = new AsyncResultHolder<>();
mInputLogicHandler.getSuggestedWords(Suggest.SESSION_TYPING, mInputLogicHandler.getSuggestedWords(Suggest.SESSION_TYPING,
SuggestedWords.NOT_A_SEQUENCE_NUMBER, new OnGetSuggestedWordsCallback() { SuggestedWords.NOT_A_SEQUENCE_NUMBER, new OnGetSuggestedWordsCallback() {
@Override @Override
@ -1350,7 +1349,7 @@ public final class InputLogic {
// we just do not resume because it's safer. // we just do not resume because it's safer.
final int numberOfCharsInWordBeforeCursor = range.getNumberOfCharsInWordBeforeCursor(); final int numberOfCharsInWordBeforeCursor = range.getNumberOfCharsInWordBeforeCursor();
if (numberOfCharsInWordBeforeCursor > expectedCursorPosition) return; if (numberOfCharsInWordBeforeCursor > expectedCursorPosition) return;
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList(); final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<>();
final String typedWord = range.mWord.toString(); final String typedWord = range.mWord.toString();
if (includeResumedWordInSuggestions) { if (includeResumedWordInSuggestions) {
suggestions.add(new SuggestedWordInfo(typedWord, suggestions.add(new SuggestedWordInfo(typedWord,
@ -1473,7 +1472,7 @@ public final class InputLogic {
committedWord.length(), Object.class); committedWord.length(), Object.class);
final int lastCharIndex = textToCommit.length() - 1; final int lastCharIndex = textToCommit.length() - 1;
// We will collect all suggestions in the following array. // We will collect all suggestions in the following array.
final ArrayList<String> suggestions = CollectionUtils.newArrayList(); final ArrayList<String> suggestions = new ArrayList<>();
// First, add the committed word to the list of suggestions. // First, add the committed word to the list of suggestions.
suggestions.add(committedWordString); suggestions.add(committedWordString);
for (final Object span : spans) { for (final Object span : spans) {

View File

@ -18,7 +18,6 @@ package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.BinaryDictionary; import com.android.inputmethod.latin.BinaryDictionary;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.CombinedFormatUtils; import com.android.inputmethod.latin.utils.CombinedFormatUtils;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
@ -78,8 +77,8 @@ public final class WordProperty implements Comparable<WordProperty> {
final ArrayList<Integer> shortcutProbabilities) { final ArrayList<Integer> shortcutProbabilities) {
mWord = StringUtils.getStringFromNullTerminatedCodePointArray(codePoints); mWord = StringUtils.getStringFromNullTerminatedCodePointArray(codePoints);
mProbabilityInfo = createProbabilityInfoFromArray(probabilityInfo); mProbabilityInfo = createProbabilityInfoFromArray(probabilityInfo);
mShortcutTargets = CollectionUtils.newArrayList(); mShortcutTargets = new ArrayList<>();
mBigrams = CollectionUtils.newArrayList(); mBigrams = new ArrayList<>();
mIsBeginningOfSentence = false; mIsBeginningOfSentence = false;
mIsNotAWord = isNotAWord; mIsNotAWord = isNotAWord;
mIsBlacklistEntry = isBlacklisted; mIsBlacklistEntry = isBlacklisted;

View File

@ -35,7 +35,7 @@ public class AccountUtils {
} }
public static List<String> getDeviceAccountsEmailAddresses(final Context context) { public static List<String> getDeviceAccountsEmailAddresses(final Context context) {
final ArrayList<String> retval = new ArrayList<String>(); final ArrayList<String> retval = new ArrayList<>();
for (final Account account : getAccounts(context)) { for (final Account account : getAccounts(context)) {
final String name = account.name; final String name = account.name;
if (Patterns.EMAIL_ADDRESS.matcher(name).matches()) { if (Patterns.EMAIL_ADDRESS.matcher(name).matches()) {
@ -54,7 +54,7 @@ public class AccountUtils {
*/ */
public static List<String> getDeviceAccountsWithDomain( public static List<String> getDeviceAccountsWithDomain(
final Context context, final String domain) { final Context context, final String domain) {
final ArrayList<String> retval = new ArrayList<String>(); final ArrayList<String> retval = new ArrayList<>();
final String atDomain = "@" + domain.toLowerCase(Locale.ROOT); final String atDomain = "@" + domain.toLowerCase(Locale.ROOT);
for (final Account account : getAccounts(context)) { for (final Account account : getAccounts(context)) {
if (account.name.toLowerCase(Locale.ROOT).endsWith(atDomain)) { if (account.name.toLowerCase(Locale.ROOT).endsWith(atDomain)) {

View File

@ -31,7 +31,6 @@ import java.util.Map;
* model. * model.
*/ */
public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableBinaryDictionary { public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableBinaryDictionary {
private static final String TAG = DecayingExpandableBinaryDictionaryBase.class.getSimpleName();
private static final boolean DBG_DUMP_ON_CLOSE = false; private static final boolean DBG_DUMP_ON_CLOSE = false;
/** Any pair being typed or picked */ /** Any pair being typed or picked */

View File

@ -16,12 +16,11 @@
package com.android.inputmethod.latin.personalization; package com.android.inputmethod.latin.personalization;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.FileUtils;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import com.android.inputmethod.latin.utils.FileUtils;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
@ -33,9 +32,9 @@ public class PersonalizationHelper {
private static final String TAG = PersonalizationHelper.class.getSimpleName(); private static final String TAG = PersonalizationHelper.class.getSimpleName();
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private static final ConcurrentHashMap<String, SoftReference<UserHistoryDictionary>> private static final ConcurrentHashMap<String, SoftReference<UserHistoryDictionary>>
sLangUserHistoryDictCache = CollectionUtils.newConcurrentHashMap(); sLangUserHistoryDictCache = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, SoftReference<PersonalizationDictionary>> private static final ConcurrentHashMap<String, SoftReference<PersonalizationDictionary>>
sLangPersonalizationDictCache = CollectionUtils.newConcurrentHashMap(); sLangPersonalizationDictCache = new ConcurrentHashMap<>();
public static UserHistoryDictionary getUserHistoryDictionary( public static UserHistoryDictionary getUserHistoryDictionary(
final Context context, final Locale locale) { final Context context, final Locale locale) {
@ -54,8 +53,7 @@ public class PersonalizationHelper {
} }
} }
final UserHistoryDictionary dict = new UserHistoryDictionary(context, locale); final UserHistoryDictionary dict = new UserHistoryDictionary(context, locale);
sLangUserHistoryDictCache.put(localeStr, sLangUserHistoryDictCache.put(localeStr, new SoftReference<>(dict));
new SoftReference<UserHistoryDictionary>(dict));
return dict; return dict;
} }
} }
@ -108,8 +106,7 @@ public class PersonalizationHelper {
} }
} }
final PersonalizationDictionary dict = new PersonalizationDictionary(context, locale); final PersonalizationDictionary dict = new PersonalizationDictionary(context, locale);
sLangPersonalizationDictCache.put( sLangPersonalizationDictCache.put(localeStr, new SoftReference<>(dict));
localeStr, new SoftReference<PersonalizationDictionary>(dict));
return dict; return dict;
} }
} }

View File

@ -47,7 +47,6 @@ import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.DialogUtils; import com.android.inputmethod.latin.utils.DialogUtils;
import com.android.inputmethod.latin.utils.IntentUtils; import com.android.inputmethod.latin.utils.IntentUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -101,7 +100,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
super(context, android.R.layout.simple_spinner_item); super(context, android.R.layout.simple_spinner_item);
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
final TreeSet<SubtypeLocaleItem> items = CollectionUtils.newTreeSet(); final TreeSet<SubtypeLocaleItem> items = new TreeSet<>();
final InputMethodInfo imi = RichInputMethodManager.getInstance() final InputMethodInfo imi = RichInputMethodManager.getInstance()
.getInputMethodInfoOfThisIme(); .getInputMethodInfoOfThisIme();
final int count = imi.getSubtypeCount(); final int count = imi.getSubtypeCount();
@ -369,7 +368,6 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
mSubtype = (InputMethodSubtype)source.readParcelable(null); mSubtype = (InputMethodSubtype)source.readParcelable(null);
} }
@SuppressWarnings("hiding")
public static final Parcelable.Creator<SavedState> CREATOR = public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() { new Parcelable.Creator<SavedState>() {
@Override @Override
@ -516,8 +514,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
localeString, keyboardLayoutSetName); localeString, keyboardLayoutSetName);
} }
private AlertDialog createDialog( private AlertDialog createDialog(final SubtypePreference subtypePref) {
@SuppressWarnings("unused") final SubtypePreference subtypePref) {
final AlertDialog.Builder builder = new AlertDialog.Builder( final AlertDialog.Builder builder = new AlertDialog.Builder(
DialogUtils.getPlatformDialogThemeContext(getActivity())); DialogUtils.getPlatformDialogThemeContext(getActivity()));
builder.setTitle(R.string.custom_input_styles_title) builder.setTitle(R.string.custom_input_styles_title)
@ -555,7 +552,7 @@ public final class AdditionalSubtypeSettings extends PreferenceFragment {
private InputMethodSubtype[] getSubtypes() { private InputMethodSubtype[] getSubtypes() {
final PreferenceGroup group = getPreferenceScreen(); final PreferenceGroup group = getPreferenceScreen();
final ArrayList<InputMethodSubtype> subtypes = CollectionUtils.newArrayList(); final ArrayList<InputMethodSubtype> subtypes = new ArrayList<>();
final int count = group.getPreferenceCount(); final int count = group.getPreferenceCount();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
final Preference pref = group.getPreference(i); final Preference pref = group.getPreference(i);

View File

@ -171,7 +171,7 @@ public final class SettingsValues {
ResourceUtils.getFloatFromFraction( ResourceUtils.getFloatFromFraction(
res, R.fraction.config_key_preview_dismiss_end_scale)); res, R.fraction.config_key_preview_dismiss_end_scale));
mDisplayOrientation = res.getConfiguration().orientation; mDisplayOrientation = res.getConfiguration().orientation;
mAppWorkarounds = new AsyncResultHolder<AppWorkaroundsUtils>(); mAppWorkarounds = new AsyncResultHolder<>();
final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo( final PackageInfo packageInfo = TargetPackageInfoGetterTask.getCachedPackageInfo(
mInputAttributes.mTargetApplicationPackageName); mInputAttributes.mTargetApplicationPackageName);
if (null != packageInfo) { if (null != packageInfo) {

View File

@ -37,7 +37,6 @@ import com.android.inputmethod.compat.TextViewCompatUtils;
import com.android.inputmethod.compat.ViewCompatUtils; import com.android.inputmethod.compat.ViewCompatUtils;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.settings.SettingsActivity; import com.android.inputmethod.latin.settings.SettingsActivity;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper; import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper;
import java.util.ArrayList; import java.util.ArrayList;
@ -482,7 +481,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
static final class SetupStepGroup { static final class SetupStepGroup {
private final SetupStepIndicatorView mIndicatorView; private final SetupStepIndicatorView mIndicatorView;
private final ArrayList<SetupStep> mGroup = CollectionUtils.newArrayList(); private final ArrayList<SetupStep> mGroup = new ArrayList<>();
public SetupStepGroup(final SetupStepIndicatorView indicatorView) { public SetupStepGroup(final SetupStepIndicatorView indicatorView) {
mIndicatorView = indicatorView; mIndicatorView = indicatorView;

View File

@ -27,7 +27,6 @@ import android.view.inputmethod.InputMethodSubtype;
import android.view.textservice.SuggestionsInfo; import android.view.textservice.SuggestionsInfo;
import com.android.inputmethod.keyboard.KeyboardLayoutSet; import com.android.inputmethod.keyboard.KeyboardLayoutSet;
import com.android.inputmethod.latin.BinaryDictionary;
import com.android.inputmethod.latin.ContactsBinaryDictionary; import com.android.inputmethod.latin.ContactsBinaryDictionary;
import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.DictionaryCollection; import com.android.inputmethod.latin.DictionaryCollection;
@ -77,7 +76,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
private final Object mUseContactsLock = new Object(); private final Object mUseContactsLock = new Object();
private final HashSet<WeakReference<DictionaryCollection>> mDictionaryCollectionsList = private final HashSet<WeakReference<DictionaryCollection>> mDictionaryCollectionsList =
CollectionUtils.newHashSet(); new HashSet<>();
public static final int SCRIPT_LATIN = 0; public static final int SCRIPT_LATIN = 0;
public static final int SCRIPT_CYRILLIC = 1; public static final int SCRIPT_CYRILLIC = 1;
@ -94,7 +93,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
// proximity to pass to the dictionary descent algorithm. // proximity to pass to the dictionary descent algorithm.
// IMPORTANT: this only contains languages - do not write countries in there. // IMPORTANT: this only contains languages - do not write countries in there.
// Only the language is searched from the map. // Only the language is searched from the map.
mLanguageToScript = CollectionUtils.newTreeMap(); mLanguageToScript = new TreeMap<>();
mLanguageToScript.put("cs", SCRIPT_LATIN); mLanguageToScript.put("cs", SCRIPT_LATIN);
mLanguageToScript.put("da", SCRIPT_LATIN); mLanguageToScript.put("da", SCRIPT_LATIN);
mLanguageToScript.put("de", SCRIPT_LATIN); mLanguageToScript.put("de", SCRIPT_LATIN);
@ -255,7 +254,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
mOriginalText = originalText; mOriginalText = originalText;
mRecommendedThreshold = recommendedThreshold; mRecommendedThreshold = recommendedThreshold;
mMaxLength = maxLength; mMaxLength = maxLength;
mSuggestions = CollectionUtils.newArrayList(maxLength + 1); mSuggestions = new ArrayList<>(maxLength + 1);
mScores = new int[mMaxLength]; mScores = new int[mMaxLength];
} }
@ -441,8 +440,7 @@ public final class AndroidSpellCheckerService extends SpellCheckerService
} }
} }
dictionaryCollection.addDictionary(mContactsDictionary); dictionaryCollection.addDictionary(mContactsDictionary);
mDictionaryCollectionsList.add( mDictionaryCollectionsList.add(new WeakReference<>(dictionaryCollection));
new WeakReference<DictionaryCollection>(dictionaryCollection));
} }
return new DictAndKeyboard(dictionaryCollection, keyboardLayoutSet); return new DictAndKeyboard(dictionaryCollection, keyboardLayoutSet);
} }

View File

@ -24,7 +24,6 @@ import android.view.textservice.SuggestionsInfo;
import android.view.textservice.TextInfo; import android.view.textservice.TextInfo;
import com.android.inputmethod.latin.PrevWordsInfo; import com.android.inputmethod.latin.PrevWordsInfo;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -44,10 +43,9 @@ public final class AndroidSpellCheckerSession extends AndroidWordLevelSpellCheck
return null; return null;
} }
final int N = ssi.getSuggestionsCount(); final int N = ssi.getSuggestionsCount();
final ArrayList<Integer> additionalOffsets = CollectionUtils.newArrayList(); final ArrayList<Integer> additionalOffsets = new ArrayList<>();
final ArrayList<Integer> additionalLengths = CollectionUtils.newArrayList(); final ArrayList<Integer> additionalLengths = new ArrayList<>();
final ArrayList<SuggestionsInfo> additionalSuggestionsInfos = final ArrayList<SuggestionsInfo> additionalSuggestionsInfos = new ArrayList<>();
CollectionUtils.newArrayList();
String currentWord = null; String currentWord = null;
for (int i = 0; i < N; ++i) { for (int i = 0; i < N; ++i) {
final SuggestionsInfo si = ssi.getSuggestionsInfoAt(i); final SuggestionsInfo si = ssi.getSuggestionsInfoAt(i);

View File

@ -28,7 +28,6 @@ import android.view.textservice.SuggestionsInfo;
import android.view.textservice.TextInfo; import android.view.textservice.TextInfo;
import com.android.inputmethod.compat.SuggestionsInfoCompatUtils; import com.android.inputmethod.compat.SuggestionsInfoCompatUtils;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.PrevWordsInfo; import com.android.inputmethod.latin.PrevWordsInfo;
@ -69,7 +68,7 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
private static final char CHAR_DELIMITER = '\uFFFC'; private static final char CHAR_DELIMITER = '\uFFFC';
private static final int MAX_CACHE_SIZE = 50; private static final int MAX_CACHE_SIZE = 50;
private final LruCache<String, SuggestionsParams> mUnigramSuggestionsInfoCache = private final LruCache<String, SuggestionsParams> mUnigramSuggestionsInfoCache =
new LruCache<String, SuggestionsParams>(MAX_CACHE_SIZE); new LruCache<>(MAX_CACHE_SIZE);
// TODO: Support n-gram input // TODO: Support n-gram input
private static String generateKey(final String query, final PrevWordsInfo prevWordsInfo) { private static String generateKey(final String query, final PrevWordsInfo prevWordsInfo) {

View File

@ -16,11 +16,11 @@
package com.android.inputmethod.latin.spellcheck; package com.android.inputmethod.latin.spellcheck;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.KeyboardLayoutSet; import com.android.inputmethod.keyboard.KeyboardLayoutSet;
import com.android.inputmethod.keyboard.ProximityInfo; import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.Dictionary;
/** /**
* A container for a Dictionary and a Keyboard. * A container for a Dictionary and a Keyboard.
@ -28,19 +28,15 @@ import com.android.inputmethod.keyboard.ProximityInfo;
public final class DictAndKeyboard { public final class DictAndKeyboard {
public final Dictionary mDictionary; public final Dictionary mDictionary;
public final Keyboard mKeyboard; public final Keyboard mKeyboard;
private final Keyboard mManualShiftedKeyboard;
public DictAndKeyboard( public DictAndKeyboard(
final Dictionary dictionary, final KeyboardLayoutSet keyboardLayoutSet) { final Dictionary dictionary, final KeyboardLayoutSet keyboardLayoutSet) {
mDictionary = dictionary; mDictionary = dictionary;
if (keyboardLayoutSet == null) { if (keyboardLayoutSet == null) {
mKeyboard = null; mKeyboard = null;
mManualShiftedKeyboard = null;
return; return;
} }
mKeyboard = keyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET); mKeyboard = keyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET);
mManualShiftedKeyboard =
keyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED);
} }
public ProximityInfo getProximityInfo() { public ProximityInfo getProximityInfo() {

View File

@ -23,7 +23,6 @@ import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.PrevWordsInfo; import com.android.inputmethod.latin.PrevWordsInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.WordComposer; import com.android.inputmethod.latin.WordComposer;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale; import java.util.Locale;
@ -47,7 +46,7 @@ public final class DictionaryPool extends LinkedBlockingQueue<DictAndKeyboard> {
private final Locale mLocale; private final Locale mLocale;
private int mSize; private int mSize;
private volatile boolean mClosed; private volatile boolean mClosed;
final static ArrayList<SuggestedWordInfo> noSuggestions = CollectionUtils.newArrayList(); final static ArrayList<SuggestedWordInfo> noSuggestions = new ArrayList<>();
private final static DictAndKeyboard dummyDict = new DictAndKeyboard( private final static DictAndKeyboard dummyDict = new DictAndKeyboard(
new Dictionary(Dictionary.TYPE_MAIN) { new Dictionary(Dictionary.TYPE_MAIN) {
// TODO: this dummy dictionary should be a singleton in the Dictionary class. // TODO: this dummy dictionary should be a singleton in the Dictionary class.

View File

@ -50,7 +50,6 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener; import com.android.inputmethod.latin.suggestions.MoreSuggestions.MoreSuggestionsListener;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.ImportantNoticeUtils; import com.android.inputmethod.latin.utils.ImportantNoticeUtils;
import com.android.inputmethod.research.ResearchLogger; import com.android.inputmethod.research.ResearchLogger;
@ -78,9 +77,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
private final MoreSuggestionsView mMoreSuggestionsView; private final MoreSuggestionsView mMoreSuggestionsView;
private final MoreSuggestions.Builder mMoreSuggestionsBuilder; private final MoreSuggestions.Builder mMoreSuggestionsBuilder;
private final ArrayList<TextView> mWordViews = CollectionUtils.newArrayList(); private final ArrayList<TextView> mWordViews = new ArrayList<>();
private final ArrayList<TextView> mDebugInfoViews = CollectionUtils.newArrayList(); private final ArrayList<TextView> mDebugInfoViews = new ArrayList<>();
private final ArrayList<View> mDividerViews = CollectionUtils.newArrayList(); private final ArrayList<View> mDividerViews = new ArrayList<>();
Listener mListener; Listener mListener;
private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY; private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;

View File

@ -256,7 +256,7 @@ public class UserDictionaryAddWordContents {
// The system locale should be inside. We want it at the 2nd spot. // The system locale should be inside. We want it at the 2nd spot.
locales.remove(systemLocale); // system locale may not be null locales.remove(systemLocale); // system locale may not be null
locales.remove(""); // Remove the empty string if it's there locales.remove(""); // Remove the empty string if it's there
final ArrayList<LocaleRenderer> localesList = new ArrayList<LocaleRenderer>(); final ArrayList<LocaleRenderer> localesList = new ArrayList<>();
// Add the passed locale, then the system locale at the top of the list. Add an // Add the passed locale, then the system locale at the top of the list. Add an
// "all languages" entry at the bottom of the list. // "all languages" entry at the bottom of the list.
addLocaleDisplayNameToList(activity, localesList, mLocale); addLocaleDisplayNameToList(activity, localesList, mLocale);

View File

@ -134,8 +134,8 @@ public class UserDictionaryAddWordFragment extends Fragment
final Spinner localeSpinner = final Spinner localeSpinner =
(Spinner)mRootView.findViewById(R.id.user_dictionary_add_locale); (Spinner)mRootView.findViewById(R.id.user_dictionary_add_locale);
final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<LocaleRenderer>(getActivity(), final ArrayAdapter<LocaleRenderer> adapter = new ArrayAdapter<>(
android.R.layout.simple_spinner_item, localesList); getActivity(), android.R.layout.simple_spinner_item, localesList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
localeSpinner.setAdapter(adapter); localeSpinner.setAdapter(adapter);
localeSpinner.setOnItemSelectedListener(this); localeSpinner.setOnItemSelectedListener(this);

View File

@ -56,7 +56,7 @@ public class UserDictionaryList extends PreferenceFragment {
final Cursor cursor = activity.getContentResolver().query(UserDictionary.Words.CONTENT_URI, final Cursor cursor = activity.getContentResolver().query(UserDictionary.Words.CONTENT_URI,
new String[] { UserDictionary.Words.LOCALE }, new String[] { UserDictionary.Words.LOCALE },
null, null, null); null, null, null);
final TreeSet<String> localeSet = new TreeSet<String>(); final TreeSet<String> localeSet = new TreeSet<>();
if (null == cursor) { if (null == cursor) {
// The user dictionary service is not present or disabled. Return null. // The user dictionary service is not present or disabled. Return null.
return null; return null;

View File

@ -95,8 +95,7 @@ public final class AdditionalSubtypeUtils {
return EMPTY_SUBTYPE_ARRAY; return EMPTY_SUBTYPE_ARRAY;
} }
final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR); final String[] prefSubtypeArray = prefSubtypes.split(PREF_SUBTYPE_SEPARATOR);
final ArrayList<InputMethodSubtype> subtypesList = final ArrayList<InputMethodSubtype> subtypesList = new ArrayList<>(prefSubtypeArray.length);
CollectionUtils.newArrayList(prefSubtypeArray.length);
for (final String prefSubtype : prefSubtypeArray) { for (final String prefSubtype : prefSubtypeArray) {
final String elems[] = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR); final String elems[] = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
if (elems.length != LENGTH_WITHOUT_EXTRA_VALUE if (elems.length != LENGTH_WITHOUT_EXTRA_VALUE

View File

@ -16,12 +16,11 @@
package com.android.inputmethod.latin.utils; package com.android.inputmethod.latin.utils;
import com.android.inputmethod.latin.BinaryDictionary; import android.util.Log;
import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import android.util.Log;
public final class AutoCorrectionUtils { public final class AutoCorrectionUtils {
private static final boolean DBG = LatinImeLogger.sDBG; private static final boolean DBG = LatinImeLogger.sDBG;
private static final String TAG = AutoCorrectionUtils.class.getSimpleName(); private static final String TAG = AutoCorrectionUtils.class.getSimpleName();

View File

@ -16,93 +16,21 @@
package com.android.inputmethod.latin.utils; package com.android.inputmethod.latin.utils;
import android.util.SparseArray;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
public final class CollectionUtils { public final class CollectionUtils {
private CollectionUtils() { private CollectionUtils() {
// This utility class is not publicly instantiable. // This utility class is not publicly instantiable.
} }
public static <K,V> HashMap<K,V> newHashMap() {
return new HashMap<K,V>();
}
public static <K, V> WeakHashMap<K, V> newWeakHashMap() {
return new WeakHashMap<K, V>();
}
public static <K,V> TreeMap<K,V> newTreeMap() {
return new TreeMap<K,V>();
}
public static <K, V> Map<K,V> newSynchronizedTreeMap() { public static <K, V> Map<K,V> newSynchronizedTreeMap() {
final TreeMap<K,V> treeMap = newTreeMap(); final TreeMap<K,V> treeMap = new TreeMap<>();
return Collections.synchronizedMap(treeMap); return Collections.synchronizedMap(treeMap);
} }
public static <K,V> ConcurrentHashMap<K,V> newConcurrentHashMap() {
return new ConcurrentHashMap<K,V>();
}
public static <E> HashSet<E> newHashSet() {
return new HashSet<E>();
}
public static <E> TreeSet<E> newTreeSet() {
return new TreeSet<E>();
}
public static <E> ArrayList<E> newArrayList() {
return new ArrayList<E>();
}
public static <E> ArrayList<E> newArrayList(final int initialCapacity) {
return new ArrayList<E>(initialCapacity);
}
public static <E> ArrayList<E> newArrayList(final Collection<E> collection) {
return new ArrayList<E>(collection);
}
public static <E> LinkedList<E> newLinkedList() {
return new LinkedList<E>();
}
public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList() {
return new CopyOnWriteArrayList<E>();
}
public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(
final Collection<E> collection) {
return new CopyOnWriteArrayList<E>(collection);
}
public static <E> CopyOnWriteArrayList<E> newCopyOnWriteArrayList(final E[] array) {
return new CopyOnWriteArrayList<E>(array);
}
public static <E> ArrayDeque<E> newArrayDeque() {
return new ArrayDeque<E>();
}
public static <E> SparseArray<E> newSparseArray() {
return new SparseArray<E>();
}
public static <E> ArrayList<E> arrayAsList(final E[] array, final int start, final int end) { public static <E> ArrayList<E> arrayAsList(final E[] array, final int start, final int end) {
if (array == null) { if (array == null) {
throw new NullPointerException(); throw new NullPointerException();
@ -111,7 +39,7 @@ public final class CollectionUtils {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
final ArrayList<E> list = newArrayList(end - start); final ArrayList<E> list = new ArrayList<>(end - start);
for (int i = start; i < end; i++) { for (int i = start; i < end; i++) {
list.add(array[i]); list.add(array[i]);
} }

View File

@ -209,7 +209,7 @@ public final class CsvUtils {
@UsedForTesting @UsedForTesting
public static String[] split(final int splitFlags, final String line) throws CsvParseException { public static String[] split(final int splitFlags, final String line) throws CsvParseException {
final boolean trimSpaces = (splitFlags & SPLIT_FLAGS_TRIM_SPACES) != 0; final boolean trimSpaces = (splitFlags & SPLIT_FLAGS_TRIM_SPACES) != 0;
final ArrayList<String> fields = CollectionUtils.newArrayList(); final ArrayList<String> fields = new ArrayList<>();
final int length = line.length(); final int length = line.length();
int start = 0; int start = 0;
do { do {

View File

@ -336,7 +336,7 @@ public class DictionaryInfoUtils {
public static ArrayList<DictionaryInfo> getCurrentDictionaryFileNameAndVersionInfo( public static ArrayList<DictionaryInfo> getCurrentDictionaryFileNameAndVersionInfo(
final Context context) { final Context context) {
final ArrayList<DictionaryInfo> dictList = CollectionUtils.newArrayList(); final ArrayList<DictionaryInfo> dictList = new ArrayList<>();
// Retrieve downloaded dictionaries // Retrieve downloaded dictionaries
final File[] directoryList = getCachedDirectoryList(context); final File[] directoryList = getCachedDirectoryList(context);

View File

@ -203,7 +203,7 @@ public class DistracterFilterUsingSuggestion implements DistracterFilter {
final String consideredWord = trailingSingleQuotesCount > 0 ? final String consideredWord = trailingSingleQuotesCount > 0 ?
testedWord.substring(0, testedWord.length() - trailingSingleQuotesCount) : testedWord.substring(0, testedWord.length() - trailingSingleQuotesCount) :
testedWord; testedWord;
final AsyncResultHolder<Boolean> holder = new AsyncResultHolder<Boolean>(); final AsyncResultHolder<Boolean> holder = new AsyncResultHolder<>();
final OnGetSuggestedWordsCallback callback = new OnGetSuggestedWordsCallback() { final OnGetSuggestedWordsCallback callback = new OnGetSuggestedWordsCallback() {
@Override @Override
public void onGetSuggestedWords(final SuggestedWords suggestedWords) { public void onGetSuggestedWords(final SuggestedWords suggestedWords) {

View File

@ -24,8 +24,9 @@ import java.util.concurrent.ConcurrentHashMap;
* Utilities to manage executors. * Utilities to manage executors.
*/ */
public class ExecutorUtils { public class ExecutorUtils {
private static final ConcurrentHashMap<String, PrioritizedSerialExecutor> private static final ConcurrentHashMap<String, PrioritizedSerialExecutor> sExecutorMap =
sExecutorMap = CollectionUtils.newConcurrentHashMap(); new ConcurrentHashMap<>();
/** /**
* Gets the executor for the given dictionary name. * Gets the executor for the given dictionary name.
*/ */

View File

@ -31,7 +31,7 @@ import com.android.inputmethod.research.FeedbackFragment;
import java.util.HashSet; import java.util.HashSet;
public class FragmentUtils { public class FragmentUtils {
private static final HashSet<String> sLatinImeFragments = new HashSet<String>(); private static final HashSet<String> sLatinImeFragments = new HashSet<>();
static { static {
sLatinImeFragments.add(DictionarySettingsFragment.class.getName()); sLatinImeFragments.add(DictionarySettingsFragment.class.getName());
sLatinImeFragments.add(AboutPreferences.class.getName()); sLatinImeFragments.add(AboutPreferences.class.getName());

View File

@ -37,7 +37,7 @@ public final class JsonUtils {
private static final String EMPTY_STRING = ""; private static final String EMPTY_STRING = "";
public static List<Object> jsonStrToList(final String s) { public static List<Object> jsonStrToList(final String s) {
final ArrayList<Object> list = CollectionUtils.newArrayList(); final ArrayList<Object> list = new ArrayList<>();
final JsonReader reader = new JsonReader(new StringReader(s)); final JsonReader reader = new JsonReader(new StringReader(s));
try { try {
reader.beginArray(); reader.beginArray();

View File

@ -84,8 +84,7 @@ public final class LanguageModelParam {
final DictionaryFacilitator dictionaryFacilitator, final DictionaryFacilitator dictionaryFacilitator,
final SpacingAndPunctuations spacingAndPunctuations, final SpacingAndPunctuations spacingAndPunctuations,
final DistracterFilter distracterFilter) { final DistracterFilter distracterFilter) {
final ArrayList<LanguageModelParam> languageModelParams = final ArrayList<LanguageModelParam> languageModelParams = new ArrayList<>();
CollectionUtils.newArrayList();
final int N = tokens.size(); final int N = tokens.size();
PrevWordsInfo prevWordsInfo = PrevWordsInfo.EMPTY_PREV_WORDS_INFO; PrevWordsInfo prevWordsInfo = PrevWordsInfo.EMPTY_PREV_WORDS_INFO;
for (int i = 0; i < N; ++i) { for (int i = 0; i < N; ++i) {

View File

@ -33,7 +33,7 @@ public class LeakGuardHandlerWrapper<T> extends Handler {
if (ownerInstance == null) { if (ownerInstance == null) {
throw new NullPointerException("ownerInstance is null"); throw new NullPointerException("ownerInstance is null");
} }
mOwnerInstanceRef = new WeakReference<T>(ownerInstance); mOwnerInstanceRef = new WeakReference<>(ownerInstance);
} }
public T getOwnerInstance() { public T getOwnerInstance() {

View File

@ -159,7 +159,7 @@ public final class LocaleUtils {
return LOCALE_MATCH <= level; return LOCALE_MATCH <= level;
} }
private static final HashMap<String, Locale> sLocaleCache = CollectionUtils.newHashMap(); private static final HashMap<String, Locale> sLocaleCache = new HashMap<>();
/** /**
* Creates a locale from a string specification. * Creates a locale from a string specification.

View File

@ -41,8 +41,8 @@ public class PrioritizedSerialExecutor {
private Runnable mActive; private Runnable mActive;
public PrioritizedSerialExecutor() { public PrioritizedSerialExecutor() {
mTasks = new ConcurrentLinkedQueue<Runnable>(); mTasks = new ConcurrentLinkedQueue<>();
mPrioritizedTasks = new ConcurrentLinkedQueue<Runnable>(); mPrioritizedTasks = new ConcurrentLinkedQueue<>();
mIsShutdown = false; mIsShutdown = false;
mThreadPoolExecutor = new ThreadPoolExecutor(1 /* corePoolSize */, 1 /* maximumPoolSize */, mThreadPoolExecutor = new ThreadPoolExecutor(1 /* corePoolSize */, 1 /* maximumPoolSize */,
0 /* keepAliveTime */, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1)); 0 /* keepAliveTime */, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));

View File

@ -41,8 +41,7 @@ public final class ResourceUtils {
// This utility class is not publicly instantiable. // This utility class is not publicly instantiable.
} }
private static final HashMap<String, String> sDeviceOverrideValueMap = private static final HashMap<String, String> sDeviceOverrideValueMap = new HashMap<>();
CollectionUtils.newHashMap();
private static final String[] BUILD_KEYS_AND_VALUES = { private static final String[] BUILD_KEYS_AND_VALUES = {
"HARDWARE", Build.HARDWARE, "HARDWARE", Build.HARDWARE,
@ -54,8 +53,8 @@ public final class ResourceUtils {
private static final String sBuildKeyValuesDebugString; private static final String sBuildKeyValuesDebugString;
static { static {
sBuildKeyValues = CollectionUtils.newHashMap(); sBuildKeyValues = new HashMap<>();
final ArrayList<String> keyValuePairs = CollectionUtils.newArrayList(); final ArrayList<String> keyValuePairs = new ArrayList<>();
final int keyCount = BUILD_KEYS_AND_VALUES.length / 2; final int keyCount = BUILD_KEYS_AND_VALUES.length / 2;
for (int i = 0; i < keyCount; i++) { for (int i = 0; i < keyCount; i++) {
final int index = i * 2; final int index = i * 2;

View File

@ -28,7 +28,6 @@ import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
public final class StringUtils { public final class StringUtils {
private static final String TAG = StringUtils.class.getSimpleName();
public static final int CAPITALIZE_NONE = 0; // No caps, or mixed case public static final int CAPITALIZE_NONE = 0; // No caps, or mixed case
public static final int CAPITALIZE_FIRST = 1; // First only public static final int CAPITALIZE_FIRST = 1; // First only
public static final int CAPITALIZE_ALL = 2; // All caps public static final int CAPITALIZE_ALL = 2; // All caps
@ -110,7 +109,7 @@ public final class StringUtils {
if (!containsInArray(text, elements)) { if (!containsInArray(text, elements)) {
return extraValues; return extraValues;
} }
final ArrayList<String> result = CollectionUtils.newArrayList(elements.length - 1); final ArrayList<String> result = new ArrayList<>(elements.length - 1);
for (final String element : elements) { for (final String element : elements) {
if (!text.equals(element)) { if (!text.equals(element)) {
result.add(element); result.add(element);

View File

@ -49,17 +49,14 @@ public final class SubtypeLocaleUtils {
private static Resources sResources; private static Resources sResources;
private static String[] sPredefinedKeyboardLayoutSet; private static String[] sPredefinedKeyboardLayoutSet;
// Keyboard layout to its display name map. // Keyboard layout to its display name map.
private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap = private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap = new HashMap<>();
CollectionUtils.newHashMap();
// Keyboard layout to subtype name resource id map. // Keyboard layout to subtype name resource id map.
private static final HashMap<String, Integer> sKeyboardLayoutToNameIdsMap = private static final HashMap<String, Integer> sKeyboardLayoutToNameIdsMap = new HashMap<>();
CollectionUtils.newHashMap();
// Exceptional locale to subtype name resource id map. // Exceptional locale to subtype name resource id map.
private static final HashMap<String, Integer> sExceptionalLocaleToNameIdsMap = private static final HashMap<String, Integer> sExceptionalLocaleToNameIdsMap = new HashMap<>();
CollectionUtils.newHashMap();
// Exceptional locale to subtype name with layout resource id map. // Exceptional locale to subtype name with layout resource id map.
private static final HashMap<String, Integer> sExceptionalLocaleToWithLayoutNameIdsMap = private static final HashMap<String, Integer> sExceptionalLocaleToWithLayoutNameIdsMap =
CollectionUtils.newHashMap(); new HashMap<>();
private static final String SUBTYPE_NAME_RESOURCE_PREFIX = private static final String SUBTYPE_NAME_RESOURCE_PREFIX =
"string/subtype_"; "string/subtype_";
private static final String SUBTYPE_NAME_RESOURCE_GENERIC_PREFIX = private static final String SUBTYPE_NAME_RESOURCE_GENERIC_PREFIX =
@ -71,7 +68,7 @@ public final class SubtypeLocaleUtils {
// Keyboard layout set name for the subtypes that don't have a keyboardLayoutSet extra value. // Keyboard layout set name for the subtypes that don't have a keyboardLayoutSet extra value.
// This is for compatibility to keep the same subtype ids as pre-JellyBean. // This is for compatibility to keep the same subtype ids as pre-JellyBean.
private static final HashMap<String, String> sLocaleAndExtraValueToKeyboardLayoutSetMap = private static final HashMap<String, String> sLocaleAndExtraValueToKeyboardLayoutSetMap =
CollectionUtils.newHashMap(); new HashMap<>();
private SubtypeLocaleUtils() { private SubtypeLocaleUtils() {
// Intentional empty constructor for utility class. // Intentional empty constructor for utility class.

View File

@ -27,8 +27,7 @@ import com.android.inputmethod.compat.AppWorkaroundsUtils;
public final class TargetPackageInfoGetterTask extends public final class TargetPackageInfoGetterTask extends
AsyncTask<String, Void, PackageInfo> { AsyncTask<String, Void, PackageInfo> {
private static final int MAX_CACHE_ENTRIES = 64; // arbitrary private static final int MAX_CACHE_ENTRIES = 64; // arbitrary
private static final LruCache<String, PackageInfo> sCache = private static final LruCache<String, PackageInfo> sCache = new LruCache<>(MAX_CACHE_ENTRIES);
new LruCache<String, PackageInfo>(MAX_CACHE_ENTRIES);
public static PackageInfo getCachedPackageInfo(final String packageName) { public static PackageInfo getCachedPackageInfo(final String packageName) {
if (null == packageName) return null; if (null == packageName) return null;

View File

@ -30,7 +30,7 @@ public final class TypefaceUtils {
} }
// This sparse array caches key label text height in pixel indexed by key label text size. // This sparse array caches key label text height in pixel indexed by key label text size.
private static final SparseArray<Float> sTextHeightCache = CollectionUtils.newSparseArray(); private static final SparseArray<Float> sTextHeightCache = new SparseArray<>();
// Working variable for the following method. // Working variable for the following method.
private static final Rect sTextHeightBounds = new Rect(); private static final Rect sTextHeightBounds = new Rect();
@ -50,7 +50,7 @@ public final class TypefaceUtils {
} }
// This sparse array caches key label text width in pixel indexed by key label text size. // This sparse array caches key label text width in pixel indexed by key label text size.
private static final SparseArray<Float> sTextWidthCache = CollectionUtils.newSparseArray(); private static final SparseArray<Float> sTextWidthCache = new SparseArray<>();
// Working variable for the following method. // Working variable for the following method.
private static final Rect sTextWidthBounds = new Rect(); private static final Rect sTextWidthBounds = new Rect();

View File

@ -66,7 +66,7 @@ public final class UserLogRingCharBuffer {
return; return;
} }
if (LatinImeLogger.sUsabilityStudy) { if (LatinImeLogger.sUsabilityStudy) {
UsabilityStudyLogUtils.getInstance().writeChar(c, x, y); UsabilityStudyLogUtils.writeChar(c, x, y);
} }
mCharBuf[mEnd] = c; mCharBuf[mEnd] = c;
mXBuf[mEnd] = x; mXBuf[mEnd] = x;

View File

@ -163,7 +163,7 @@ public class FixedLogBuffer extends LogBuffer {
// Allocate space for n*2 logUnits. There will be at least n, one for each word, and // Allocate space for n*2 logUnits. There will be at least n, one for each word, and
// there may be additional for punctuation, between-word commands, etc. This should be // there may be additional for punctuation, between-word commands, etc. This should be
// enough that reallocation won't be necessary. // enough that reallocation won't be necessary.
final ArrayList<LogUnit> resultList = new ArrayList<LogUnit>(n * 2); final ArrayList<LogUnit> resultList = new ArrayList<>(n * 2);
for (final LogUnit logUnit : logUnits) { for (final LogUnit logUnit : logUnits) {
n -= logUnit.getNumWords(); n -= logUnit.getNumWords();
if (n < 0) break; if (n < 0) break;

View File

@ -31,7 +31,7 @@ public class LogBuffer {
private final LinkedList<LogUnit> mLogUnits; private final LinkedList<LogUnit> mLogUnits;
public LogBuffer() { public LogBuffer() {
mLogUnits = new LinkedList<LogUnit>(); mLogUnits = new LinkedList<>();
} }
protected LinkedList<LogUnit> getLogUnits() { protected LinkedList<LogUnit> getLogUnits() {

View File

@ -93,9 +93,9 @@ public class LogUnit {
private SuggestedWords mSuggestedWords; private SuggestedWords mSuggestedWords;
public LogUnit() { public LogUnit() {
mLogStatementList = new ArrayList<LogStatement>(); mLogStatementList = new ArrayList<>();
mValuesList = new ArrayList<Object[]>(); mValuesList = new ArrayList<>();
mTimeList = new ArrayList<Long>(); mTimeList = new ArrayList<>();
mIsPartOfMegaword = false; mIsPartOfMegaword = false;
mCorrectionType = CORRECTIONTYPE_NO_CORRECTION; mCorrectionType = CORRECTIONTYPE_NO_CORRECTION;
mSuggestedWords = null; mSuggestedWords = null;
@ -311,9 +311,9 @@ public class LogUnit {
// Create the LogUnit containing the later logStatements and associated data. // Create the LogUnit containing the later logStatements and associated data.
final LogUnit newLogUnit = new LogUnit( final LogUnit newLogUnit = new LogUnit(
new ArrayList<LogStatement>(laterLogStatements), new ArrayList<>(laterLogStatements),
new ArrayList<Object[]>(laterValues), new ArrayList<>(laterValues),
new ArrayList<Long>(laterTimes), new ArrayList<>(laterTimes),
true /* isPartOfMegaword */); true /* isPartOfMegaword */);
newLogUnit.mWords = null; newLogUnit.mWords = null;
newLogUnit.mMayContainDigit = mMayContainDigit; newLogUnit.mMayContainDigit = mMayContainDigit;

View File

@ -67,11 +67,10 @@ public class MotionEventReader {
@UsedForTesting @UsedForTesting
static class ReplayData { static class ReplayData {
final ArrayList<Integer> mActions = new ArrayList<Integer>(); final ArrayList<Integer> mActions = new ArrayList<>();
final ArrayList<PointerProperties[]> mPointerPropertiesArrays final ArrayList<PointerProperties[]> mPointerPropertiesArrays = new ArrayList<>();
= new ArrayList<PointerProperties[]>(); final ArrayList<PointerCoords[]> mPointerCoordsArrays = new ArrayList<>();
final ArrayList<PointerCoords[]> mPointerCoordsArrays = new ArrayList<PointerCoords[]>(); final ArrayList<Long> mTimes = new ArrayList<>();
final ArrayList<Long> mTimes = new ArrayList<Long>();
} }
/** /**
@ -228,8 +227,7 @@ public class MotionEventReader {
private PointerProperties[] readPointerProperties(final JsonReader jsonReader) private PointerProperties[] readPointerProperties(final JsonReader jsonReader)
throws IOException { throws IOException {
final ArrayList<PointerProperties> pointerPropertiesArrayList = final ArrayList<PointerProperties> pointerPropertiesArrayList = new ArrayList<>();
new ArrayList<PointerProperties>();
jsonReader.beginArray(); jsonReader.beginArray();
while (jsonReader.hasNext()) { while (jsonReader.hasNext()) {
final PointerProperties pointerProperties = new PointerProperties(); final PointerProperties pointerProperties = new PointerProperties();
@ -254,7 +252,7 @@ public class MotionEventReader {
jsonReader.beginArray(); jsonReader.beginArray();
while (jsonReader.hasNext()) { // Array of historical data while (jsonReader.hasNext()) { // Array of historical data
jsonReader.beginObject(); jsonReader.beginObject();
final ArrayList<PointerCoords> pointerCoordsArrayList = new ArrayList<PointerCoords>(); final ArrayList<PointerCoords> pointerCoordsArrayList = new ArrayList<>();
while (jsonReader.hasNext()) { // Time/data object while (jsonReader.hasNext()) { // Time/data object
final String name = jsonReader.nextName(); final String name = jsonReader.nextName();
if (name.equals("t")) { if (name.equals("t")) {

View File

@ -32,7 +32,6 @@ import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@ -42,11 +41,9 @@ import java.util.Locale;
@SmallTest @SmallTest
public class KeyboardLayoutSetTestsBase extends AndroidTestCase { public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
// All input method subtypes of LatinIME. // All input method subtypes of LatinIME.
private final ArrayList<InputMethodSubtype> mAllSubtypesList = CollectionUtils.newArrayList(); private final ArrayList<InputMethodSubtype> mAllSubtypesList = new ArrayList<>();
private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList = private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList = new ArrayList<>();
CollectionUtils.newArrayList(); private final ArrayList<InputMethodSubtype> mAdditionalSubtypesList = new ArrayList<>();
private final ArrayList<InputMethodSubtype> mAdditionalSubtypesList =
CollectionUtils.newArrayList();
private Context mThemeContext; private Context mThemeContext;
private int mScreenMetrics; private int mScreenMetrics;

View File

@ -23,7 +23,6 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,7 +41,7 @@ public final class KeyboardTextsSetTests extends AndroidTestCase {
RichInputMethodManager.init(getContext()); RichInputMethodManager.init(getContext());
final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
final ArrayList<InputMethodSubtype> allSubtypesList = CollectionUtils.newArrayList(); final ArrayList<InputMethodSubtype> allSubtypesList = new ArrayList<>();
final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme(); final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme();
final int subtypeCount = imi.getSubtypeCount(); final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) { for (int index = 0; index < subtypeCount; index++) {

View File

@ -22,8 +22,6 @@ import android.content.res.Resources;
import android.test.InstrumentationTestCase; import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -53,7 +51,7 @@ public class MoreKeySpecSplitTests extends InstrumentationTestCase {
} }
private static String[] getAllResourceIdNames(final Class<?> resourceIdClass) { private static String[] getAllResourceIdNames(final Class<?> resourceIdClass) {
final ArrayList<String> names = CollectionUtils.newArrayList(); final ArrayList<String> names = new ArrayList<>();
for (final Field field : resourceIdClass.getFields()) { for (final Field field : resourceIdClass.getFields()) {
if (field.getType() == Integer.TYPE) { if (field.getType() == Integer.TYPE) {
names.add(field.getName()); names.add(field.getName());

View File

@ -20,7 +20,6 @@ import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.internal.MoreKeySpec; import com.android.inputmethod.keyboard.internal.MoreKeySpec;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.StringUtils; import com.android.inputmethod.latin.utils.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -34,7 +33,7 @@ import java.util.List;
*/ */
public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> { public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
private static ArrayList<Key> filterOutSpacer(final List<Key> keys) { private static ArrayList<Key> filterOutSpacer(final List<Key> keys) {
final ArrayList<Key> filteredKeys = CollectionUtils.newArrayList(); final ArrayList<Key> filteredKeys = new ArrayList<>();
for (final Key key : keys) { for (final Key key : keys) {
if (key.isSpacer()) { if (key.isSpacer()) {
continue; continue;
@ -55,15 +54,15 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> {
final ArrayList<Key> filteredSortedKeys = filterOutSpacer(sortedKeys); final ArrayList<Key> filteredSortedKeys = filterOutSpacer(sortedKeys);
// Grouping keys into rows. // Grouping keys into rows.
final ArrayList<ArrayList<Key>> rows = CollectionUtils.newArrayList(); final ArrayList<ArrayList<Key>> rows = new ArrayList<>();
ArrayList<Key> elements = CollectionUtils.newArrayList(); ArrayList<Key> elements = new ArrayList<>();
int lastY = filteredSortedKeys.get(0).getY(); int lastY = filteredSortedKeys.get(0).getY();
for (final Key key : filteredSortedKeys) { for (final Key key : filteredSortedKeys) {
if (lastY != key.getY()) { if (lastY != key.getY()) {
// A new row is starting. // A new row is starting.
lastY = key.getY(); lastY = key.getY();
rows.add(elements); rows.add(elements);
elements = CollectionUtils.newArrayList(); elements = new ArrayList<>();
} }
elements.add(key); elements.add(key);
} }

View File

@ -18,7 +18,6 @@ package com.android.inputmethod.keyboard.layout.expected;
import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.internal.MoreKeySpec; import com.android.inputmethod.keyboard.internal.MoreKeySpec;
import com.android.inputmethod.latin.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -73,9 +72,8 @@ public class ExpectedKey {
// The additional more keys can be defined independently from other more keys. // The additional more keys can be defined independently from other more keys.
// The position of the additional more keys in the long press popup keyboard can be // The position of the additional more keys in the long press popup keyboard can be
// controlled by specifying special marker "%" in the usual more keys definitions. // controlled by specifying special marker "%" in the usual more keys definitions.
final ArrayList<ExpectedKey> moreKeysList = CollectionUtils.newArrayList(); final ArrayList<ExpectedKey> moreKeysList = new ArrayList<>();
final ArrayList<ExpectedAdditionalMoreKey> additionalMoreKeys = final ArrayList<ExpectedAdditionalMoreKey> additionalMoreKeys = new ArrayList<>();
CollectionUtils.newArrayList();
int firstAdditionalMoreKeyIndex = -1; int firstAdditionalMoreKeyIndex = -1;
for (int index = 0; index < moreKeys.length; index++) { for (int index = 0; index < moreKeys.length; index++) {
final ExpectedKey moreKey = moreKeys[index]; final ExpectedKey moreKey = moreKeys[index];

Some files were not shown because too many files have changed in this diff Show More