Add hintLabel to Key constructor

This change also partialy reverts I5832421c, because of incorrect
popup mini key width calculation.

Bug: 5023981
Change-Id: I1acde090c01d3d861fcc5559cad81e638de2c2bb
main
Tadashi G. Takaoka 2011-08-30 16:48:38 +09:00
parent 619f707c95
commit be34d97334
2 changed files with 8 additions and 9 deletions

View File

@ -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;

View File

@ -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);