Merge "Do not pick up closest key if the point is out of any key"

main
Tadashi G. Takaoka 2010-12-19 04:07:41 -08:00 committed by Android (Google) Code Review
commit cc0e41222d
1 changed files with 1 additions and 8 deletions

View File

@ -36,8 +36,6 @@ public class ProximityKeyDetector extends KeyDetector {
final int touchY = getTouchY(y); final int touchY = getTouchY(y);
int primaryIndex = NOT_A_KEY; int primaryIndex = NOT_A_KEY;
int closestKeyIndex = NOT_A_KEY;
int closestKeyDist = mProximityThresholdSquare + 1;
final int[] distances = mDistances; final int[] distances = mDistances;
Arrays.fill(distances, Integer.MAX_VALUE); Arrays.fill(distances, Integer.MAX_VALUE);
for (final int index : mKeyboard.getNearestKeys(touchX, touchY)) { for (final int index : mKeyboard.getNearestKeys(touchX, touchY)) {
@ -47,11 +45,6 @@ public class ProximityKeyDetector extends KeyDetector {
primaryIndex = index; primaryIndex = index;
final int dist = key.squaredDistanceToEdge(touchX, touchY); final int dist = key.squaredDistanceToEdge(touchX, touchY);
if (isInside || (mProximityCorrectOn && dist < mProximityThresholdSquare)) { if (isInside || (mProximityCorrectOn && dist < mProximityThresholdSquare)) {
if (dist < closestKeyDist) {
closestKeyDist = dist;
closestKeyIndex = index;
}
if (allKeys == null) continue; if (allKeys == null) continue;
final int nCodes = key.mCodes.length; final int nCodes = key.mCodes.length;
// Find insertion point // Find insertion point
@ -70,6 +63,6 @@ public class ProximityKeyDetector extends KeyDetector {
} }
} }
return primaryIndex == NOT_A_KEY ? closestKeyIndex : primaryIndex; return primaryIndex;
} }
} }