diff options
| author | Tadashi G. Takaoka <takaoka@google.com> | 2012-02-02 21:24:09 +0900 |
|---|---|---|
| committer | Tadashi G. Takaoka <takaoka@google.com> | 2012-02-02 21:33:50 +0900 |
| commit | 44e0e4f99e70b84176ff5c985e456b821a8f0b14 (patch) | |
| tree | ffe8b4f86d3ed8415f4af24d1b8b03c3562b99ac /java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java | |
| parent | c373585f089917a41f4d77f6d09264b964636694 (diff) | |
Fix Key.equals(Key)
Bug: 5956068
Change-Id: I2901ae28bd9121ec4f4429a53b83aae128b75e0c
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java')
| -rw-r--r-- | java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java index bec6ae1cc..31a7e8b8e 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java @@ -36,8 +36,9 @@ public class KeyboardIconsSet { private final Map<Integer, Drawable> mIcons = new HashMap<Integer, Drawable>(); // The key value should be aligned with the enum value of Keyboard.icon*. - private static final Map<Integer, Integer> ICONS_TO_ATTRS_MAP = new HashMap<Integer, Integer>(); - private static final Map<String, Integer> NAME_TO_ATTRS_MAP = new HashMap<String, Integer>(); + private static final Map<Integer, Integer> ID_TO_ATTR_MAP = new HashMap<Integer, Integer>(); + private static final Map<String, Integer> NAME_TO_ATTR_MAP = new HashMap<String, Integer>(); + private static final Map<Integer, String> ATTR_TO_NAME_MAP = new HashMap<Integer, String>(); private static final Collection<Integer> VALID_ATTRS; static { @@ -55,12 +56,13 @@ public class KeyboardIconsSet { addIconIdMap(11, "shiftKeyShifted", R.styleable.Keyboard_iconShiftKeyShifted); addIconIdMap(12, "disabledShortcurKey", R.styleable.Keyboard_iconDisabledShortcutKey); addIconIdMap(13, "previewTabKey", R.styleable.Keyboard_iconPreviewTabKey); - VALID_ATTRS = ICONS_TO_ATTRS_MAP.values(); + VALID_ATTRS = ID_TO_ATTR_MAP.values(); } private static void addIconIdMap(int iconId, String name, Integer attrId) { - ICONS_TO_ATTRS_MAP.put(iconId, attrId); - NAME_TO_ATTRS_MAP.put(name, attrId); + ID_TO_ATTR_MAP.put(iconId, attrId); + NAME_TO_ATTR_MAP.put(name, attrId); + ATTR_TO_NAME_MAP.put(attrId, name); } public void loadIcons(final TypedArray keyboardAttrs) { @@ -82,7 +84,7 @@ public class KeyboardIconsSet { if (iconId == ICON_UNDEFINED) { return ATTR_UNDEFINED; } - final Integer attrId = ICONS_TO_ATTRS_MAP.get(iconId); + final Integer attrId = ID_TO_ATTR_MAP.get(iconId); if (attrId == null) { throw new IllegalArgumentException("icon id is out of range: " + iconId); } @@ -90,13 +92,23 @@ public class KeyboardIconsSet { } public static int getIconAttrId(final String iconName) { - final Integer attrId = NAME_TO_ATTRS_MAP.get(iconName); + final Integer attrId = NAME_TO_ATTR_MAP.get(iconName); if (attrId == null) { throw new IllegalArgumentException("unknown icon name: " + iconName); } return attrId; } + public static String getIconName(final int attrId) { + if (attrId == ATTR_UNDEFINED) { + return "null"; + } + if (ATTR_TO_NAME_MAP.containsKey(attrId)) { + return ATTR_TO_NAME_MAP.get(attrId); + } + return String.format("unknown<0x%08x>", attrId); + } + public Drawable getIconByAttrId(final Integer attrId) { if (attrId == ATTR_UNDEFINED) { return null; |
