From be34d973349909196dc3427a5653f4e119092ea7 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 30 Aug 2011 16:48:38 +0900 Subject: [PATCH] Add hintLabel to Key constructor This change also partialy reverts I5832421c, because of incorrect popup mini key width calculation. Bug: 5023981 Change-Id: I1acde090c01d3d861fcc5559cad81e638de2c2bb --- java/src/com/android/inputmethod/keyboard/Key.java | 6 +++--- .../android/inputmethod/keyboard/MiniKeyboard.java | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index f56b52388..e64f14d9b 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -195,15 +195,15 @@ public class Key { /** * This constructor is being used only for key in popup mini keyboard. */ - public Key(Resources res, KeyboardParams params, CharSequence popupCharacter, int x, int y, - int width, int height, int edgeFlags) { + public Key(Resources res, KeyboardParams params, CharSequence popupCharacter, + CharSequence hintLabel, int x, int y, int width, int height, int edgeFlags) { mHeight = height - params.mVerticalGap; mHorizontalGap = params.mHorizontalGap; mVerticalGap = params.mVerticalGap; mVisualInsetsLeft = mVisualInsetsRight = 0; mWidth = width - mHorizontalGap; mEdgeFlags = edgeFlags; - mHintLabel = null; + mHintLabel = hintLabel; mLabelOption = 0; mFunctional = false; mSticky = false; diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java index 8f4791630..4a7655e34 100644 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java @@ -17,7 +17,6 @@ package com.android.inputmethod.keyboard; import android.graphics.Paint; -import android.graphics.Rect; import com.android.inputmethod.keyboard.internal.KeyboardBuilder; import com.android.inputmethod.keyboard.internal.KeyboardParams; @@ -235,6 +234,8 @@ public class MiniKeyboard extends Keyboard { private static int getMaxKeyWidth(KeyboardView view, CharSequence[] popupCharacters, int minKeyWidth) { + final int padding = (int) view.getContext().getResources() + .getDimension(R.dimen.mini_keyboard_key_horizontal_padding); Paint paint = null; int maxWidth = minKeyWidth; for (CharSequence popupSpec : popupCharacters) { @@ -246,15 +247,13 @@ public class MiniKeyboard extends Keyboard { paint = new Paint(); paint.setAntiAlias(true); } - final int width = (int)view.getDefaultLabelWidth(label, paint); + final int width = (int)view.getDefaultLabelWidth(label, paint) + padding; if (maxWidth < width) { maxWidth = width; } } } - final int horizontalPadding = (int) view.getContext().getResources() - .getDimension(R.dimen.mini_keyboard_key_horizontal_padding); - return maxWidth + horizontalPadding; + return maxWidth; } @Override @@ -263,7 +262,7 @@ public class MiniKeyboard extends Keyboard { for (int n = 0; n < mPopupCharacters.length; n++) { final CharSequence label = mPopupCharacters[n]; final int row = n / params.mNumColumns; - final Key key = new Key(mResources, params, label, params.getX(n, row), + final Key key = new Key(mResources, params, label, null, params.getX(n, row), params.getY(row), params.mDefaultKeyWidth, params.mDefaultRowHeight, params.getRowFlags(row)); params.onAddKey(key);