Add outputText and icon to the Key constructor

This is a follow up change for I737bacb1.

Bug: 5023981
Change-Id: I980e3e993c81afe4fbdb95c9c263d7aa52aff66c
This commit is contained in:
Tadashi G. Takaoka 2011-08-30 21:41:52 +09:00
parent 39cc806605
commit 241f1cfdf6
2 changed files with 19 additions and 10 deletions

View file

@ -192,21 +192,30 @@ public class Key {
} }
} }
private static int getCode(Resources res, KeyboardParams params, String popupSpec) {
return getRtlParenthesisCode(
PopupCharactersParser.getCode(res, popupSpec), params.mIsRtlKeyboard);
}
private static Drawable getIcon(KeyboardParams params, String popupSpec) {
return params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpec));
}
/** /**
* This constructor is being used only for key in popup mini keyboard. * This constructor is being used only for key in popup mini keyboard.
*/ */
public Key(Resources res, KeyboardParams params, String popupSpec, public Key(Resources res, KeyboardParams params, String popupSpec,
int x, int y, int width, int height, int edgeFlags) { int x, int y, int width, int height, int edgeFlags) {
this(params, getRtlParenthesisCode(PopupCharactersParser.getCode(res, popupSpec), this(params, PopupCharactersParser.getLabel(popupSpec), null, getIcon(params, popupSpec),
params.mIsRtlKeyboard), getCode(res, params, popupSpec), PopupCharactersParser.getOutputText(popupSpec),
popupSpec, null, x, y, width, height, edgeFlags); x, y, width, height, edgeFlags);
} }
/** /**
* This constructor is being used only for key in popup suggestions pane. * This constructor is being used only for key in popup suggestions pane.
*/ */
public Key(KeyboardParams params, int code, String popupSpec, String hintLabel, public Key(KeyboardParams params, CharSequence label, CharSequence hintLabel, Drawable icon,
int x, int y, int width, int height, int edgeFlags) { int code, CharSequence outputText, int x, int y, int width, int height, int edgeFlags) {
mHeight = height - params.mVerticalGap; mHeight = height - params.mVerticalGap;
mHorizontalGap = params.mHorizontalGap; mHorizontalGap = params.mHorizontalGap;
mVerticalGap = params.mVerticalGap; mVerticalGap = params.mVerticalGap;
@ -220,10 +229,10 @@ public class Key {
mRepeatable = false; mRepeatable = false;
mPopupCharacters = null; mPopupCharacters = null;
mMaxPopupColumn = 0; mMaxPopupColumn = 0;
mLabel = PopupCharactersParser.getLabel(popupSpec); mLabel = label;
mOutputText = PopupCharactersParser.getOutputText(popupSpec); mOutputText = outputText;
mCode = code; mCode = code;
mIcon = params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpec)); mIcon = icon;
// Horizontal gap is divided equally to both sides of the key. // Horizontal gap is divided equally to both sides of the key.
mX = x + mHorizontalGap / 2; mX = x + mHorizontalGap / 2;
mY = y; mY = y;

View file

@ -260,9 +260,9 @@ public class MiniKeyboard extends Keyboard {
public MiniKeyboard build() { public MiniKeyboard build() {
final MiniKeyboardParams params = mParams; final MiniKeyboardParams params = mParams;
for (int n = 0; n < mPopupCharacters.length; n++) { for (int n = 0; n < mPopupCharacters.length; n++) {
final CharSequence label = mPopupCharacters[n]; final String popupSpec = mPopupCharacters[n].toString();
final int row = n / params.mNumColumns; final int row = n / params.mNumColumns;
final Key key = new Key(mResources, params, label.toString(), params.getX(n, row), final Key key = new Key(mResources, params, popupSpec, params.getX(n, row),
params.getY(row), params.mDefaultKeyWidth, params.mDefaultRowHeight, params.getY(row), params.mDefaultKeyWidth, params.mDefaultRowHeight,
params.getRowFlags(row)); params.getRowFlags(row));
params.onAddKey(key); params.onAddKey(key);