Cleanup icon drawable related code

Bug: 5023981
Change-Id: I729354f32797eef354ec9af8e05f17839f0a361c
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 5b34dd5..62a9c63 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -324,16 +324,13 @@
             mPreviewIcon = iconsSet.getIcon(style.getInt(
                     keyAttr, R.styleable.Keyboard_Key_keyIconPreview,
                     KeyboardIconsSet.ICON_UNDEFINED));
-            Keyboard.setDefaultBounds(mPreviewIcon);
             mIcon = iconsSet.getIcon(style.getInt(
                     keyAttr, R.styleable.Keyboard_Key_keyIcon,
                     KeyboardIconsSet.ICON_UNDEFINED));
-            Keyboard.setDefaultBounds(mIcon);
             final int shiftedIconId = style.getInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted,
                     KeyboardIconsSet.ICON_UNDEFINED);
             if (shiftedIconId != KeyboardIconsSet.ICON_UNDEFINED) {
                 final Drawable shiftedIcon = iconsSet.getIcon(shiftedIconId);
-                Keyboard.setDefaultBounds(shiftedIcon);
                 mKeyboard.addShiftedIcon(this, shiftedIcon);
             }
             mHintLabel = style.getText(keyAttr, R.styleable.Keyboard_Key_keyHintLabel);
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 8840c79..69b040d 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -431,10 +431,4 @@
             throw new RuntimeException(e);
         }
     }
-
-    public static void setDefaultBounds(Drawable drawable)  {
-        if (drawable != null)
-            drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
-                    drawable.getIntrinsicHeight());
-    }
 }
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
index 02c261b..ed4608b 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
@@ -21,7 +21,6 @@
 import android.graphics.drawable.Drawable;
 import android.util.Log;
 
-import com.android.inputmethod.keyboard.Keyboard;
 import com.android.inputmethod.latin.R;
 
 public class KeyboardIconsSet {
@@ -51,7 +50,7 @@
 
     private final Drawable mIcons[] = new Drawable[ICON_LAST + 1];
 
-    private static final int getIconId(int attrIndex) {
+    private static final int getIconId(final int attrIndex) {
         switch (attrIndex) {
         case R.styleable.Keyboard_iconShiftKey:
             return ICON_SHIFT_KEY;
@@ -86,16 +85,14 @@
         }
     }
 
-    public void loadIcons(TypedArray keyboardAttrs) {
+    public void loadIcons(final TypedArray keyboardAttrs) {
         final int count = keyboardAttrs.getIndexCount();
         for (int i = 0; i < count; i++) {
             final int attrIndex = keyboardAttrs.getIndex(i);
             final int iconId = getIconId(attrIndex);
             if (iconId != ICON_UNDEFINED) {
                 try {
-                    final Drawable icon = keyboardAttrs.getDrawable(attrIndex);
-                    Keyboard.setDefaultBounds(icon);
-                    mIcons[iconId] = icon;
+                    mIcons[iconId] = setDefaultBounds(keyboardAttrs.getDrawable(attrIndex));
                 } catch (Resources.NotFoundException e) {
                     Log.w(TAG, "Drawable resource for icon #" + iconId + " not found");
                 }
@@ -103,11 +100,18 @@
         }
     }
 
-    public Drawable getIcon(int iconId) {
+    public Drawable getIcon(final int iconId) {
         if (iconId == ICON_UNDEFINED)
             return null;
         if (iconId < 0 || iconId >= mIcons.length)
             throw new IllegalArgumentException("icon id is out of range: " + iconId);
         return mIcons[iconId];
     }
+
+    private static Drawable setDefaultBounds(final Drawable icon)  {
+        if (icon != null) {
+            icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
+        }
+        return icon;
+    }
 }