From 8f590c77e8a435d8e35020f1b7e66fdf53ab7953 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 28 May 2012 16:13:11 +0900 Subject: [PATCH] Use Math.round instead of (int) to convert Key coordinates from float to int Bug: 6566563 Change-Id: I97d1e9727077cb4d9abbf1ad5bd5d3f061c7bce7 --- .../com/android/inputmethod/keyboard/Key.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 91e81f347..ed873a70d 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -217,21 +217,22 @@ public class Key { final int keyYPos = row.getKeyY(); // Horizontal gap is divided equally to both sides of the key. - mX = (int) (keyXPos + horizontalGap / 2); + mX = Math.round(keyXPos + horizontalGap / 2); mY = keyYPos; - mWidth = (int) (keyWidth - horizontalGap); - mHorizontalGap = (int) horizontalGap; - mHitBox.set((int)keyXPos, keyYPos, (int)(keyXPos + keyWidth) + 1, keyYPos + keyHeight); + mWidth = Math.round(keyWidth - horizontalGap); + mHorizontalGap = Math.round(horizontalGap); + mHitBox.set(Math.round(keyXPos), keyYPos, Math.round(keyXPos + keyWidth) + 1, + keyYPos + keyHeight); // Update row to have current x coordinate. row.setXPos(keyXPos + keyWidth); mBackgroundType = style.getInt(keyAttr, R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL); - mVisualInsetsLeft = (int) Keyboard.Builder.getDimensionOrFraction(keyAttr, - R.styleable.Keyboard_Key_visualInsetsLeft, params.mBaseWidth, 0); - mVisualInsetsRight = (int) Keyboard.Builder.getDimensionOrFraction(keyAttr, - R.styleable.Keyboard_Key_visualInsetsRight, params.mBaseWidth, 0); + mVisualInsetsLeft = Math.round(Keyboard.Builder.getDimensionOrFraction(keyAttr, + R.styleable.Keyboard_Key_visualInsetsLeft, params.mBaseWidth, 0)); + mVisualInsetsRight = Math.round(Keyboard.Builder.getDimensionOrFraction(keyAttr, + R.styleable.Keyboard_Key_visualInsetsRight, params.mBaseWidth, 0)); mIconId = KeySpecParser.getIconId(style.getString(keyAttr, R.styleable.Keyboard_Key_keyIcon)); mDisabledIconId = KeySpecParser.getIconId(style.getString(keyAttr,