aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java9
-rw-r--r--java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java21
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java10
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java25
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java6
6 files changed, 31 insertions, 42 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
index dc7c12ba6..dd43166af 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
@@ -36,7 +36,6 @@ import com.android.inputmethod.keyboard.KeyboardView;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import java.util.Set;
/**
* Exposes a virtual view sub-tree for {@link KeyboardView} and generates
@@ -135,9 +134,9 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat
ViewCompat.onInitializeAccessibilityNodeInfo(mKeyboardView, info);
// Add the virtual children of the root View.
- // TODO(alanv): Need to assign a unique ID to each key.
+ // TODO: Need to assign a unique ID to each key.
final Keyboard keyboard = mKeyboardView.getKeyboard();
- final Set<Key> keys = keyboard.mKeys;
+ final Key[] keys = keyboard.mKeys;
for (Key key : keys) {
final int childVirtualViewId = generateVirtualViewIdForKey(key);
info.addChild(mKeyboardView, childVirtualViewId);
@@ -342,8 +341,8 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat
mVirtualViewIdToKey.clear();
- final Set<Key> keySet = keyboard.mKeys;
- for (Key key : keySet) {
+ final Key[] keys = keyboard.mKeys;
+ for (Key key : keys) {
final int virtualViewId = generateVirtualViewIdForKey(key);
mVirtualViewIdToKey.put(virtualViewId, key);
}
diff --git a/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java b/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java
index eca922e68..9a523011a 100644
--- a/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java
@@ -17,7 +17,7 @@
package com.android.inputmethod.compat;
public class MotionEventCompatUtils {
- // TODO(alanv): Remove after these are added to MotionEventCompat.
+ // TODO: Remove after these are added to MotionEventCompat.
public static final int ACTION_HOVER_ENTER = 0x9;
public static final int ACTION_HOVER_EXIT = 0xA;
}
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index b7f1ddde6..a726878c2 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -40,12 +40,9 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard
@@ -125,16 +122,16 @@ public class Keyboard {
/** Maximum column for more keys keyboard */
public final int mMaxMoreKeysKeyboardColumn;
- /** List of keys and icons in this keyboard */
- public final Set<Key> mKeys;
- public final Set<Key> mShiftKeys;
+ /** Array of keys and icons in this keyboard */
+ public final Key[] mKeys;
+ public final Key[] mShiftKeys;
public final KeyboardIconsSet mIconsSet;
- private final Map<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
+ private final HashMap<Integer, Key> mKeyCache = new HashMap<Integer, Key>();
private final ProximityInfo mProximityInfo;
- public final Map<Integer, List<Integer>> mAdditionalProximityChars;
+ private final Map<Integer, List<Integer>> mAdditionalProximityChars;
public Keyboard(Params params) {
mId = params.mId;
@@ -149,8 +146,8 @@ public class Keyboard {
mTopPadding = params.mTopPadding;
mVerticalGap = params.mVerticalGap;
- mKeys = Collections.unmodifiableSet(params.mKeys);
- mShiftKeys = Collections.unmodifiableSet(params.mShiftKeys);
+ mKeys = params.mKeys.toArray(new Key[params.mKeys.size()]);
+ mShiftKeys = params.mShiftKeys.toArray(new Key[params.mShiftKeys.size()]);
mIconsSet = params.mIconsSet;
mAdditionalProximityChars = params.mAdditionalProximityChars;
@@ -225,8 +222,8 @@ public class Keyboard {
public int GRID_WIDTH;
public int GRID_HEIGHT;
- public final Set<Key> mKeys = new HashSet<Key>();
- public final Set<Key> mShiftKeys = new HashSet<Key>();
+ public final ArrayList<Key> mKeys = new ArrayList<Key>();
+ public final ArrayList<Key> mShiftKeys = new ArrayList<Key>();
public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet();
// TODO: Should be in Key instead of Keyboard.Params?
public final Map<Integer, List<Integer>> mAdditionalProximityChars =
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index 7a9915be0..316177fbb 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -25,8 +25,6 @@ import com.android.inputmethod.keyboard.internal.PointerTrackerQueue;
import com.android.inputmethod.latin.LatinImeLogger;
import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
public class PointerTracker {
private static final String TAG = PointerTracker.class.getSimpleName();
@@ -109,7 +107,7 @@ public class PointerTracker {
private static LatinKeyboardView.PointerTrackerParams sParams;
private static int sTouchNoiseThresholdDistanceSquared;
- private static final List<PointerTracker> sTrackers = new ArrayList<PointerTracker>();
+ private static final ArrayList<PointerTracker> sTrackers = new ArrayList<PointerTracker>();
private static PointerTrackerQueue sPointerTrackerQueue;
public final int mPointerId;
@@ -120,7 +118,6 @@ public class PointerTracker {
private KeyboardActionListener mListener = EMPTY_LISTENER;
private Keyboard mKeyboard;
- private Set<Key> mKeys;
private int mKeyQuarterWidthSquared;
private final TextView mKeyPreviewText;
@@ -180,7 +177,7 @@ public class PointerTracker {
}
public static PointerTracker getPointerTracker(final int id, KeyEventHandler handler) {
- final List<PointerTracker> trackers = sTrackers;
+ final ArrayList<PointerTracker> trackers = sTrackers;
// Create pointer trackers until we can get 'id+1'-th tracker, if needed.
for (int i = trackers.size(); i <= id; i++) {
@@ -303,7 +300,6 @@ public class PointerTracker {
private void setKeyDetectorInner(KeyDetector keyDetector) {
mKeyDetector = keyDetector;
mKeyboard = keyDetector.getKeyboard();
- mKeys = mKeyboard.mKeys;
final int keyQuarterWidth = mKeyboard.mMostCommonKeyWidth / 4;
mKeyQuarterWidthSquared = keyQuarterWidth * keyQuarterWidth;
}
@@ -691,7 +687,7 @@ public class PointerTracker {
}
private boolean isMajorEnoughMoveToBeOnNewKey(int x, int y, Key newKey) {
- if (mKeys == null || mKeyDetector == null)
+ if (mKeyDetector == null)
throw new NullPointerException("keyboard and/or key detector not set");
Key curKey = mCurrentKey;
if (newKey == curKey) {
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index 8a65a5fc6..e2a48306a 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -28,7 +28,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
public class ProximityInfo {
public static final int MAX_PROXIMITY_CHARS_SIZE = 16;
@@ -50,8 +49,8 @@ public class ProximityInfo {
private final String mLocaleStr;
ProximityInfo(String localeStr, int gridWidth, int gridHeight, int minWidth, int height,
- int mostCommonKeyWidth,
- int mostCommonKeyHeight, Set<Key> keys, TouchPositionCorrection touchPositionCorrection,
+ int mostCommonKeyWidth, int mostCommonKeyHeight, final Key[] keys,
+ TouchPositionCorrection touchPositionCorrection,
Map<Integer, List<Integer>> additionalProximityChars) {
if (TextUtils.isEmpty(localeStr)) {
mLocaleStr = "";
@@ -77,8 +76,8 @@ public class ProximityInfo {
}
public static ProximityInfo createDummyProximityInfo() {
- return new ProximityInfo("", 1, 1, 1, 1, 1, 1, Collections.<Key> emptySet(),
- null, Collections.<Integer, List<Integer>> emptyMap());
+ return new ProximityInfo("", 1, 1, 1, 1, 1, 1, EMPTY_KEY_ARRAY, null,
+ Collections.<Integer, List<Integer>> emptyMap());
}
public static ProximityInfo createSpellCheckerProximityInfo(final int[] proximity) {
@@ -106,8 +105,7 @@ public class ProximityInfo {
private native void releaseProximityInfoNative(long nativeProximityInfo);
private final void setProximityInfo(Key[][] gridNeighborKeys, int keyboardWidth,
- int keyboardHeight, Set<Key> keys,
- TouchPositionCorrection touchPositionCorrection) {
+ int keyboardHeight, final Key[] keys, TouchPositionCorrection touchPositionCorrection) {
final int[] proximityCharsArray = new int[mGridSize * MAX_PROXIMITY_CHARS_SIZE];
Arrays.fill(proximityCharsArray, KeyDetector.NOT_A_CODE);
for (int i = 0; i < mGridSize; ++i) {
@@ -117,7 +115,7 @@ public class ProximityInfo {
gridNeighborKeys[i][j].mCode;
}
}
- final int keyCount = keys.size();
+ final int keyCount = keys.length;
final int[] keyXCoordinates = new int[keyCount];
final int[] keyYCoordinates = new int[keyCount];
final int[] keyWidths = new int[keyCount];
@@ -132,8 +130,8 @@ public class ProximityInfo {
sweetSpotCenterYs = new float[keyCount];
sweetSpotRadii = new float[keyCount];
calculateSweetSpotParams = true;
- int i = 0;
- for (final Key key : keys) {
+ for (int i = 0; i < keyCount; i++) {
+ final Key key = keys[i];
keyXCoordinates[i] = key.mX;
keyYCoordinates[i] = key.mY;
keyWidths[i] = key.mWidth;
@@ -156,7 +154,6 @@ public class ProximityInfo {
hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight);
}
}
- i++;
}
} else {
sweetSpotCenterXs = sweetSpotCenterYs = sweetSpotRadii = null;
@@ -186,17 +183,17 @@ public class ProximityInfo {
}
}
- private void computeNearestNeighbors(int defaultWidth, Set<Key> keys,
+ private void computeNearestNeighbors(int defaultWidth, final Key[] keys,
TouchPositionCorrection touchPositionCorrection,
Map<Integer, List<Integer>> additionalProximityChars) {
- final Map<Integer, Key> keyCodeMap = new HashMap<Integer, Key>();
+ final HashMap<Integer, Key> keyCodeMap = new HashMap<Integer, Key>();
for (final Key key : keys) {
keyCodeMap.put(key.mCode, key);
}
final int thresholdBase = (int) (defaultWidth * SEARCH_DISTANCE);
final int threshold = thresholdBase * thresholdBase;
// Round-up so we don't have any pixels outside the grid
- final Key[] neighborKeys = new Key[keys.size()];
+ final Key[] neighborKeys = new Key[keys.length];
final int gridWidth = mGridWidth * mCellWidth;
final int gridHeight = mGridHeight * mCellHeight;
for (int x = 0; x < gridWidth; x += mCellWidth) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
index ca711ec7d..9b9c86179 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
@@ -24,7 +24,6 @@ import android.util.Log;
import com.android.inputmethod.latin.R;
import java.util.HashMap;
-import java.util.Map;
public class KeyboardIconsSet {
private static final String TAG = KeyboardIconsSet.class.getSimpleName();
@@ -35,8 +34,9 @@ public class KeyboardIconsSet {
private final Drawable[] mIcons = new Drawable[NUM_ICONS + 1];
- private static final Map<Integer, Integer> ATTR_ID_TO_ICON_ID = new HashMap<Integer, Integer>();
- private static final Map<String, Integer> NAME_TO_ICON_ID = new HashMap<String, Integer>();
+ private static final HashMap<Integer, Integer> ATTR_ID_TO_ICON_ID
+ = new HashMap<Integer, Integer>();
+ private static final HashMap<String, Integer> NAME_TO_ICON_ID = new HashMap<String, Integer>();
private static final String[] ICON_NAMES = new String[NUM_ICONS + 1];
private static final int ATTR_UNDEFINED = 0;