Add Key.getIconId for testability
Bug: 13017434 Change-Id: I94ff45da3f58b74cc9dd4d38179670fbcf619d92
This commit is contained in:
parent
6e224a236a
commit
deb5cedf81
2 changed files with 7 additions and 3 deletions
|
@ -716,10 +716,14 @@ public class Key implements Comparable<Key> {
|
||||||
return (attrs != null) ? attrs.mAltCode : CODE_UNSPECIFIED;
|
return (attrs != null) ? attrs.mAltCode : CODE_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIconId() {
|
||||||
|
return mIconId;
|
||||||
|
}
|
||||||
|
|
||||||
public Drawable getIcon(final KeyboardIconsSet iconSet, final int alpha) {
|
public Drawable getIcon(final KeyboardIconsSet iconSet, final int alpha) {
|
||||||
final OptionalAttributes attrs = mOptionalAttributes;
|
final OptionalAttributes attrs = mOptionalAttributes;
|
||||||
final int disabledIconId = (attrs != null) ? attrs.mDisabledIconId : ICON_UNDEFINED;
|
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);
|
final Drawable icon = iconSet.getIconDrawable(iconId);
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
icon.setAlpha(alpha);
|
icon.setAlpha(alpha);
|
||||||
|
@ -731,7 +735,7 @@ public class Key implements Comparable<Key> {
|
||||||
final OptionalAttributes attrs = mOptionalAttributes;
|
final OptionalAttributes attrs = mOptionalAttributes;
|
||||||
final int previewIconId = (attrs != null) ? attrs.mPreviewIconId : ICON_UNDEFINED;
|
final int previewIconId = (attrs != null) ? attrs.mPreviewIconId : ICON_UNDEFINED;
|
||||||
return previewIconId != ICON_UNDEFINED
|
return previewIconId != ICON_UNDEFINED
|
||||||
? iconSet.getIconDrawable(previewIconId) : iconSet.getIconDrawable(mIconId);
|
? iconSet.getIconDrawable(previewIconId) : iconSet.getIconDrawable(getIconId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
|
|
|
@ -102,7 +102,7 @@ public final class KeyboardIconsSet {
|
||||||
return isValidIconId(iconId) ? ICON_NAMES[iconId] : "unknown<" + iconId + ">";
|
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);
|
Integer iconId = sNameToIdsMap.get(name);
|
||||||
if (iconId != null) {
|
if (iconId != null) {
|
||||||
return iconId;
|
return iconId;
|
||||||
|
|
Loading…
Reference in a new issue