Add Key.getIconId for testability

Bug: 13017434
Change-Id: I94ff45da3f58b74cc9dd4d38179670fbcf619d92
main
Tadashi G. Takaoka 2014-02-17 15:37:43 +09:00
parent 6e224a236a
commit deb5cedf81
2 changed files with 7 additions and 3 deletions

View File

@ -716,10 +716,14 @@ public class Key implements Comparable<Key> {
return (attrs != null) ? attrs.mAltCode : CODE_UNSPECIFIED;
}
public int getIconId() {
return mIconId;
}
public Drawable getIcon(final KeyboardIconsSet iconSet, final int alpha) {
final OptionalAttributes attrs = mOptionalAttributes;
final int disabledIconId = (attrs != null) ? attrs.mDisabledIconId : ICON_UNDEFINED;
final int iconId = mEnabled ? mIconId : disabledIconId;
final int iconId = mEnabled ? getIconId() : disabledIconId;
final Drawable icon = iconSet.getIconDrawable(iconId);
if (icon != null) {
icon.setAlpha(alpha);
@ -731,7 +735,7 @@ public class Key implements Comparable<Key> {
final OptionalAttributes attrs = mOptionalAttributes;
final int previewIconId = (attrs != null) ? attrs.mPreviewIconId : ICON_UNDEFINED;
return previewIconId != ICON_UNDEFINED
? iconSet.getIconDrawable(previewIconId) : iconSet.getIconDrawable(mIconId);
? iconSet.getIconDrawable(previewIconId) : iconSet.getIconDrawable(getIconId());
}
public int getWidth() {

View File

@ -102,7 +102,7 @@ public final class KeyboardIconsSet {
return isValidIconId(iconId) ? ICON_NAMES[iconId] : "unknown<" + iconId + ">";
}
static int getIconId(final String name) {
public static int getIconId(final String name) {
Integer iconId = sNameToIdsMap.get(name);
if (iconId != null) {
return iconId;