aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
index 742ee98d7..6c8d02016 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysDetector.java
@@ -39,7 +39,7 @@ public class MoreKeysDetector extends KeyDetector {
}
@Override
- public Key getKeyAndNearbyCodes(int x, int y, final int[] allCodes) {
+ public void getNearbyCodes(int x, int y, final int[] allCodes) {
final int touchX = getTouchX(x);
final int touchY = getTouchY(y);
@@ -53,8 +53,26 @@ public class MoreKeysDetector extends KeyDetector {
}
}
- if (allCodes != null && nearestKey != null) {
+ if (nearestKey != null) {
allCodes[0] = nearestKey.mCode;
+ } else {
+ allCodes[0] = NOT_A_CODE;
+ }
+ }
+
+ @Override
+ public Key detectHitKey(int x, int y) {
+ final int touchX = getTouchX(x);
+ final int touchY = getTouchY(y);
+
+ Key nearestKey = null;
+ int nearestDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare;
+ for (final Key key : getKeyboard().mKeys) {
+ final int dist = key.squaredDistanceToEdge(touchX, touchY);
+ if (dist < nearestDist) {
+ nearestKey = key;
+ nearestDist = dist;
+ }
}
return nearestKey;
}