Add outputText and icon to the Key constructor

This is a follow up change for I737bacb1.

Bug: 5023981
Change-Id: I980e3e993c81afe4fbdb95c9c263d7aa52aff66c
main
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.
*/
public Key(Resources res, KeyboardParams params, String popupSpec,
int x, int y, int width, int height, int edgeFlags) {
this(params, getRtlParenthesisCode(PopupCharactersParser.getCode(res, popupSpec),
params.mIsRtlKeyboard),
popupSpec, null, x, y, width, height, edgeFlags);
this(params, PopupCharactersParser.getLabel(popupSpec), null, getIcon(params, popupSpec),
getCode(res, params, popupSpec), PopupCharactersParser.getOutputText(popupSpec),
x, y, width, height, edgeFlags);
}
/**
* This constructor is being used only for key in popup suggestions pane.
*/
public Key(KeyboardParams params, int code, String popupSpec, String hintLabel,
int x, int y, int width, int height, int edgeFlags) {
public Key(KeyboardParams params, CharSequence label, CharSequence hintLabel, Drawable icon,
int code, CharSequence outputText, int x, int y, int width, int height, int edgeFlags) {
mHeight = height - params.mVerticalGap;
mHorizontalGap = params.mHorizontalGap;
mVerticalGap = params.mVerticalGap;
@ -220,10 +229,10 @@ public class Key {
mRepeatable = false;
mPopupCharacters = null;
mMaxPopupColumn = 0;
mLabel = PopupCharactersParser.getLabel(popupSpec);
mOutputText = PopupCharactersParser.getOutputText(popupSpec);
mLabel = label;
mOutputText = outputText;
mCode = code;
mIcon = params.mIconsSet.getIcon(PopupCharactersParser.getIconId(popupSpec));
mIcon = icon;
// Horizontal gap is divided equally to both sides of the key.
mX = x + mHorizontalGap / 2;
mY = y;

View File

@ -260,9 +260,9 @@ public class MiniKeyboard extends Keyboard {
public MiniKeyboard build() {
final MiniKeyboardParams params = mParams;
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 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.getRowFlags(row));
params.onAddKey(key);