Do not pick up closest key if the point is out of any key
Bug: 3286308
Change-Id: I62771fb209027ddec4595d099d5d397ae4e200fd
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityKeyDetector.java b/java/src/com/android/inputmethod/keyboard/ProximityKeyDetector.java
index 43596ae..bd4bbcd 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityKeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityKeyDetector.java
@@ -36,8 +36,6 @@
final int touchY = getTouchY(y);
int primaryIndex = NOT_A_KEY;
- int closestKeyIndex = NOT_A_KEY;
- int closestKeyDist = mProximityThresholdSquare + 1;
final int[] distances = mDistances;
Arrays.fill(distances, Integer.MAX_VALUE);
for (final int index : mKeyboard.getNearestKeys(touchX, touchY)) {
@@ -47,11 +45,6 @@
primaryIndex = index;
final int dist = key.squaredDistanceToEdge(touchX, touchY);
if (isInside || (mProximityCorrectOn && dist < mProximityThresholdSquare)) {
- if (dist < closestKeyDist) {
- closestKeyDist = dist;
- closestKeyIndex = index;
- }
-
if (allKeys == null) continue;
final int nCodes = key.mCodes.length;
// Find insertion point
@@ -70,6 +63,6 @@
}
}
- return primaryIndex == NOT_A_KEY ? closestKeyIndex : primaryIndex;
+ return primaryIndex;
}
}