Merge "Cleanup keyboard related code a bit"
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 5fa9b8f..69cbcb1 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -463,7 +463,7 @@
         mPopupPanelPointerTrackerId = tracker.mPointerId;
 
         final Keyboard keyboard = getKeyboard();
-        mPopupPanel.setShifted(keyboard.isShiftedOrShiftLocked());
+        popupPanel.setShifted(keyboard.isShiftedOrShiftLocked());
         final int pointX = (mConfigShowMiniKeyboardAtTouchedPoint) ? tracker.getLastX()
                 : parentKey.mX + parentKey.mWidth / 2;
         final int pointY = parentKey.mY - keyboard.mVerticalGap;
diff --git a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
index c4428dc..7ace46c 100644
--- a/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/PopupMiniKeyboardView.java
@@ -197,8 +197,8 @@
 
     @Override
     public void setShifted(boolean shifted) {
-        final MiniKeyboard miniKeyboard = (MiniKeyboard)getKeyboard();
-        if (miniKeyboard.setShifted(shifted)) {
+        final Keyboard keyboard = getKeyboard();
+        if (keyboard.setShifted(shifted)) {
             invalidateAllKeys();
         }
     }
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
index 4ccaa72..9801152 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
@@ -64,6 +64,15 @@
 
     public int mMostCommonKeyWidth = 0;
 
+    protected void clearKeys() {
+        mKeys.clear();
+        mShiftKeys.clear();
+        mShiftLockKeys.clear();
+        mShiftedIcons.clear();
+        mUnshiftedIcons.clear();
+        clearHistogram();
+    }
+
     public void onAddKey(Key key) {
         mKeys.add(key);
         updateHistogram(key);
@@ -83,6 +92,12 @@
     private int mMaxCount = 0;
     private final Map<Integer, Integer> mHistogram = new HashMap<Integer, Integer>();
 
+    private void clearHistogram() {
+        mMostCommonKeyWidth = 0;
+        mMaxCount = 0;
+        mHistogram.clear();
+    }
+
     private void updateHistogram(Key key) {
         final Integer width = key.mWidth + key.mHorizontalGap;
         final int count = (mHistogram.containsKey(width) ? mHistogram.get(width) : 0) + 1;