diff options
author | 2010-11-05 18:41:12 +0900 | |
---|---|---|
committer | 2010-11-06 01:10:55 +0900 | |
commit | 59b7bd07301196ac333dabafb5dd80750fcd2987 (patch) | |
tree | e8fe26f8e99a57a29c7124719a6146ef86b428f2 /java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java | |
parent | 68864723cf8d8e48385bfcaf30237fba25a8895a (diff) | |
download | latinime-59b7bd07301196ac333dabafb5dd80750fcd2987.tar.gz latinime-59b7bd07301196ac333dabafb5dd80750fcd2987.tar.xz latinime-59b7bd07301196ac333dabafb5dd80750fcd2987.zip |
Using distance to the edge of key as proximity detection
Because there may be very long key, such as space bar on tablet, we
should not use the distance between the touch point and the center of
key as proximity detection. Instead of that, this change uses the
distance between the point and the nearest edge of key as proximity
detection.
Also this change fixes the bug that space key (code 32) was not
counted in proximity detection.
Bug: 3164020
Bug: 3168138
Change-Id: I687f1ce94a8e944c3f6eea0fe00e18ed6e68e278
Diffstat (limited to 'java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java b/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java index 0e0c2e7fc..3cc43b99c 100644 --- a/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java +++ b/java/src/com/android/inputmethod/latin/MiniKeyboardKeyDetector.java @@ -41,17 +41,18 @@ class MiniKeyboardKeyDetector extends KeyDetector { final Key[] keys = getKeys(); final int touchX = getTouchX(x); final int touchY = getTouchY(y); + int closestKeyIndex = BaseKeyboardView.NOT_A_KEY; int closestKeyDist = (y < 0) ? mSlideAllowanceSquareTop : mSlideAllowanceSquare; final int keyCount = keys.length; - for (int i = 0; i < keyCount; i++) { - final Key key = keys[i]; - int dist = key.squaredDistanceFrom(touchX, touchY); + for (int index = 0; index < keyCount; index++) { + final int dist = keys[index].squaredDistanceToEdge(touchX, touchY); if (dist < closestKeyDist) { - closestKeyIndex = i; + closestKeyIndex = index; closestKeyDist = dist; } } + if (allKeys != null && closestKeyIndex != BaseKeyboardView.NOT_A_KEY) allKeys[0] = keys[closestKeyIndex].codes[0]; return closestKeyIndex; |