aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/KeyDetector.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/KeyDetector.java')
-rw-r--r--java/src/com/android/inputmethod/latin/KeyDetector.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/KeyDetector.java b/java/src/com/android/inputmethod/latin/KeyDetector.java
index 5583e3275..e443f272b 100644
--- a/java/src/com/android/inputmethod/latin/KeyDetector.java
+++ b/java/src/com/android/inputmethod/latin/KeyDetector.java
@@ -19,11 +19,12 @@ package com.android.inputmethod.latin;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.Keyboard.Key;
+import java.util.Arrays;
import java.util.List;
abstract class KeyDetector {
protected Keyboard mKeyboard;
- protected Key[] mKeys;
+ private Key[] mKeys;
protected int mCorrectionX;
protected int mCorrectionY;
@@ -50,6 +51,13 @@ abstract class KeyDetector {
return y + mCorrectionY;
}
+ protected Key[] getKeys() {
+ if (mKeys == null)
+ throw new IllegalStateException("keyboard isn't set");
+ // mKeyboard is guaranteed not null at setKeybaord() method
+ return mKeys;
+ }
+
public void setProximityCorrectionEnabled(boolean enabled) {
mProximityCorrectOn = enabled;
}
@@ -62,7 +70,13 @@ abstract class KeyDetector {
mProximityThresholdSquare = threshold * threshold;
}
- abstract public int[] newCodeArray();
+ public int[] newCodeArray() {
+ int[] codes = new int[getMaxNearbyKeys()];
+ Arrays.fill(codes, LatinKeyboardBaseView.NOT_A_KEY);
+ return codes;
+ }
+
+ abstract protected int getMaxNearbyKeys();
abstract public int getKeyIndexAndNearbyCodes(int x, int y, int[] allKeys);
} \ No newline at end of file