From deb5cedf811e6d605a4a2a934f4d0c75b880cede Mon Sep 17 00:00:00 2001
From: "Tadashi G. Takaoka" <takaoka@google.com>
Date: Mon, 17 Feb 2014 15:37:43 +0900
Subject: [PATCH] Add Key.getIconId for testability

Bug: 13017434
Change-Id: I94ff45da3f58b74cc9dd4d38179670fbcf619d92
---
 java/src/com/android/inputmethod/keyboard/Key.java        | 8 ++++++--
 .../inputmethod/keyboard/internal/KeyboardIconsSet.java   | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index afaf2cc574..816a943001 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -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() {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
index da8bf7d69b..79d088f2e0 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
@@ -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;
-- 
GitLab