diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:23 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-09 17:51:23 -0800 |
commit | b798689749c64baba81f02e10cf2157c747d6b46 (patch) | |
tree | da394a395ddb1a6cf69193314846b03fe47a397e /core/java/android/inputmethodservice/Keyboard.java | |
parent | f013e1afd1e68af5e3b868c26a653bbfb39538f8 (diff) | |
download | frameworks_base-b798689749c64baba81f02e10cf2157c747d6b46.zip frameworks_base-b798689749c64baba81f02e10cf2157c747d6b46.tar.gz frameworks_base-b798689749c64baba81f02e10cf2157c747d6b46.tar.bz2 |
auto import from //branches/cupcake/...@125939
Diffstat (limited to 'core/java/android/inputmethodservice/Keyboard.java')
-rwxr-xr-x | core/java/android/inputmethodservice/Keyboard.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/java/android/inputmethodservice/Keyboard.java b/core/java/android/inputmethodservice/Keyboard.java index 75a2911..cfd3188 100755 --- a/core/java/android/inputmethodservice/Keyboard.java +++ b/core/java/android/inputmethodservice/Keyboard.java @@ -438,7 +438,6 @@ public class Keyboard { } } - /** * Returns the square of the distance between the center of the key and the given point. * @param x the x-coordinate of the point @@ -446,9 +445,9 @@ public class Keyboard { * @return the square of the distance of the point from the center of the key */ public int squaredDistanceFrom(int x, int y) { - float xDist = Math.abs((this.x + this.x + width) / 2f - x); - float yDist = Math.abs((this.y + this.y + height) / 2f - y); - return (int) (xDist * xDist + yDist * yDist); + int xDist = this.x + width / 2 - x; + int yDist = this.y + height / 2 - y; + return xDist * xDist + yDist * yDist; } /** @@ -749,7 +748,8 @@ public class Keyboard { if (value.type == TypedValue.TYPE_DIMENSION) { return a.getDimensionPixelOffset(index, defValue); } else if (value.type == TypedValue.TYPE_FRACTION) { - return (int) a.getFraction(index, base, base, defValue); + // Round it to avoid values like 47.9999 from getting truncated + return Math.round(a.getFraction(index, base, base, defValue)); } return defValue; } |