diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index c37285c..1e5ca9b 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -38,12 +38,13 @@
 import android.view.ViewGroup;
 import android.widget.TextView;
 
+import com.android.inputmethod.keyboard.internal.KeyDrawParams;
+import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
 import com.android.inputmethod.keyboard.internal.PreviewPlacerView;
 import com.android.inputmethod.latin.CollectionUtils;
 import com.android.inputmethod.latin.Constants;
 import com.android.inputmethod.latin.LatinImeLogger;
 import com.android.inputmethod.latin.R;
-import com.android.inputmethod.latin.ResourceUtils;
 import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
 import com.android.inputmethod.latin.StringUtils;
 import com.android.inputmethod.latin.define.ProductionFlag;
@@ -179,224 +180,6 @@
         }
     }
 
-    // Move this class to internal package
-    protected static class KeyDrawParams {
-        // XML attributes
-        public final int mKeyTextColor;
-        public final int mKeyTextInactivatedColor;
-        public final float mKeyLabelHorizontalPadding;
-        public final float mKeyHintLetterPadding;
-        public final float mKeyPopupHintLetterPadding;
-        public final float mKeyShiftedLetterHintPadding;
-        public final int mKeyTextShadowColor;
-        public final float mKeyTextShadowRadius;
-        public final Drawable mKeyBackground;
-        public final int mKeyHintLetterColor;
-        public final int mKeyHintLabelColor;
-        public final int mKeyShiftedLetterHintInactivatedColor;
-        public final int mKeyShiftedLetterHintActivatedColor;
-
-        private final Typeface mKeyTypefaceFromKeyboardView;
-        private final float mKeyLetterRatio;
-        private final int mKeyLetterSizeFromKeyboardView;
-        private final float mKeyLargeLetterRatio;
-        private final float mKeyLabelRatio;
-        private final float mKeyLargeLabelRatio;
-        private final float mKeyHintLetterRatio;
-        private final float mKeyShiftedLetterHintRatio;
-        private final float mKeyHintLabelRatio;
-
-        public final Rect mPadding = new Rect();
-        public Typeface mKeyTypeface;
-        public int mKeyLetterSize;
-        public int mKeyLargeLetterSize;
-        public int mKeyLabelSize;
-        public int mKeyLargeLabelSize;
-        public int mKeyHintLetterSize;
-        public int mKeyShiftedLetterHintSize;
-        public int mKeyHintLabelSize;
-        public int mAnimAlpha;
-
-        public KeyDrawParams(final TypedArray keyboardViewAttr, final TypedArray keyAttr) {
-            mKeyBackground = keyboardViewAttr.getDrawable(R.styleable.KeyboardView_keyBackground);
-            mKeyBackground.getPadding(mPadding);
-
-            mKeyLetterRatio = ResourceUtils.getFraction(keyAttr,
-                    R.styleable.Keyboard_Key_keyLetterSize);
-            mKeyLetterSizeFromKeyboardView = ResourceUtils.getDimensionPixelSize(keyAttr,
-                    R.styleable.Keyboard_Key_keyLetterSize);
-            mKeyLabelRatio = ResourceUtils.getFraction(keyAttr,
-                    R.styleable.Keyboard_Key_keyLabelSize);
-            mKeyLabelSize = ResourceUtils.getDimensionPixelSize(keyAttr,
-                    R.styleable.Keyboard_Key_keyLabelSize);
-            mKeyLargeLabelRatio = ResourceUtils.getFraction(keyAttr,
-                    R.styleable.Keyboard_Key_keyLargeLabelRatio);
-            mKeyLargeLetterRatio = ResourceUtils.getFraction(keyAttr,
-                    R.styleable.Keyboard_Key_keyLargeLetterRatio);
-            mKeyHintLetterRatio = ResourceUtils.getFraction(keyAttr,
-                    R.styleable.Keyboard_Key_keyHintLetterRatio);
-            mKeyShiftedLetterHintRatio = ResourceUtils.getFraction(keyAttr,
-                    R.styleable.Keyboard_Key_keyShiftedLetterHintRatio);
-            mKeyHintLabelRatio = ResourceUtils.getFraction(keyAttr,
-                    R.styleable.Keyboard_Key_keyHintLabelRatio);
-            mKeyLabelHorizontalPadding = keyAttr.getDimension(
-                    R.styleable.Keyboard_Key_keyLabelHorizontalPadding, 0);
-            mKeyHintLetterPadding = keyAttr.getDimension(
-                    R.styleable.Keyboard_Key_keyHintLetterPadding, 0);
-            mKeyPopupHintLetterPadding = keyAttr.getDimension(
-                    R.styleable.Keyboard_Key_keyPopupHintLetterPadding, 0);
-            mKeyShiftedLetterHintPadding = keyAttr.getDimension(
-                    R.styleable.Keyboard_Key_keyShiftedLetterHintPadding, 0);
-            mKeyTextColor = keyAttr.getColor(
-                    R.styleable.Keyboard_Key_keyTextColor, Color.WHITE);
-            mKeyTextInactivatedColor = keyAttr.getColor(
-                    R.styleable.Keyboard_Key_keyTextInactivatedColor, Color.WHITE);
-            mKeyHintLetterColor = keyAttr.getColor(
-                    R.styleable.Keyboard_Key_keyHintLetterColor, Color.TRANSPARENT);
-            mKeyHintLabelColor = keyAttr.getColor(
-                    R.styleable.Keyboard_Key_keyHintLabelColor, Color.TRANSPARENT);
-            mKeyShiftedLetterHintInactivatedColor = keyAttr.getColor(
-                    R.styleable.Keyboard_Key_keyShiftedLetterHintInactivatedColor,
-                    Color.TRANSPARENT);
-            mKeyShiftedLetterHintActivatedColor = keyAttr.getColor(
-                    R.styleable.Keyboard_Key_keyShiftedLetterHintActivatedColor, Color.TRANSPARENT);
-            mKeyTypefaceFromKeyboardView = Typeface.defaultFromStyle(
-                    keyAttr.getInt(R.styleable.Keyboard_Key_keyTypeface, Typeface.NORMAL));
-            mKeyTextShadowColor = keyAttr.getColor(
-                    R.styleable.Keyboard_Key_keyTextShadowColor, Color.TRANSPARENT);
-            mKeyTextShadowRadius = keyAttr.getFloat(
-                    R.styleable.Keyboard_Key_keyTextShadowRadius, 0f);
-        }
-
-        public void updateParams(final Keyboard keyboard) {
-            mKeyTypeface = (keyboard.mKeyTypeface != null)
-                    ? keyboard.mKeyTypeface : mKeyTypefaceFromKeyboardView;
-            final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
-            mKeyLetterSize = selectTextSizeFromDimensionOrRatio(keyHeight,
-                    mKeyLetterSizeFromKeyboardView, mKeyLetterRatio,
-                    mKeyLetterSizeFromKeyboardView);
-            // Override if size/ratio is specified in Keyboard.
-            mKeyLetterSize = selectTextSizeFromDimensionOrRatio(keyHeight, keyboard.mKeyLetterSize,
-                    keyboard.mKeyLetterRatio, mKeyLetterSize);
-            if (ResourceUtils.isValidFraction(mKeyLabelRatio)) {
-                mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio);
-            }
-            mKeyLargeLabelSize = (int)(keyHeight * mKeyLargeLabelRatio);
-            mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio);
-            mKeyHintLetterSize = selectTextSizeFromKeyboardOrView(keyHeight,
-                    keyboard.mKeyHintLetterRatio, mKeyHintLetterRatio);
-            mKeyShiftedLetterHintSize = selectTextSizeFromKeyboardOrView(keyHeight,
-                    keyboard.mKeyShiftedLetterHintRatio, mKeyShiftedLetterHintRatio);
-            mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio);
-        }
-
-        private static final int selectTextSizeFromDimensionOrRatio(final int keyHeight,
-                final int dimens, final float ratio, final int defaultDimens) {
-            if (ResourceUtils.isValidDimensionPixelSize(dimens)) {
-                return dimens;
-            }
-            if (ResourceUtils.isValidFraction(ratio)) {
-                return (int)(keyHeight * ratio);
-            }
-            return defaultDimens;
-        }
-
-        private static final int selectTextSizeFromKeyboardOrView(final int keyHeight,
-                final float ratioFromKeyboard, final float ratioFromView) {
-            final float ratio = ResourceUtils.isValidFraction(ratioFromKeyboard)
-                    ? ratioFromKeyboard : ratioFromView;
-            return (int)(keyHeight * ratio);
-        }
-
-        public void blendAlpha(final Paint paint) {
-            final int color = paint.getColor();
-            paint.setARGB((paint.getAlpha() * mAnimAlpha) / Constants.Color.ALPHA_OPAQUE,
-                    Color.red(color), Color.green(color), Color.blue(color));
-        }
-    }
-
-    // TODO: Move this class to internal package.
-    /* package */ static class KeyPreviewDrawParams {
-        // XML attributes.
-        public final Drawable mPreviewBackground;
-        public final Drawable mPreviewLeftBackground;
-        public final Drawable mPreviewRightBackground;
-        public final int mPreviewTextColor;
-        public final int mPreviewOffset;
-        public final int mPreviewHeight;
-        public final int mLingerTimeout;
-
-        private final float mPreviewTextRatio;
-
-        // The graphical geometry of the key preview.
-        // <-width->
-        // +-------+   ^
-        // |       |   |
-        // |preview| height (visible)
-        // |       |   |
-        // +       + ^ v
-        //  \     /  |offset
-        // +-\   /-+ v
-        // |  +-+  |
-        // |parent |
-        // |    key|
-        // +-------+
-        // The background of a {@link TextView} being used for a key preview may have invisible
-        // paddings. To align the more keys keyboard panel's visible part with the visible part of
-        // the background, we need to record the width and height of key preview that don't include
-        // invisible paddings.
-        public int mPreviewVisibleWidth;
-        public int mPreviewVisibleHeight;
-        // The key preview may have an arbitrary offset and its background that may have a bottom
-        // padding. To align the more keys keyboard and the key preview we also need to record the
-        // offset between the top edge of parent key and the bottom of the visible part of key
-        // preview background.
-        public int mPreviewVisibleOffset;
-
-        public Typeface mKeyTypeface;
-        public int mPreviewTextSize;
-        public int mKeyLetterSize;
-        public final int[] mCoordinates = new int[2];
-
-        private static final int PREVIEW_ALPHA = 240;
-
-        public KeyPreviewDrawParams(final TypedArray keyboardViewAttr, final TypedArray keyAttr) {
-            mPreviewBackground = keyboardViewAttr.getDrawable(
-                    R.styleable.KeyboardView_keyPreviewBackground);
-            mPreviewLeftBackground = keyboardViewAttr.getDrawable(
-                    R.styleable.KeyboardView_keyPreviewLeftBackground);
-            mPreviewRightBackground = keyboardViewAttr.getDrawable(
-                    R.styleable.KeyboardView_keyPreviewRightBackground);
-            setAlpha(mPreviewBackground, PREVIEW_ALPHA);
-            setAlpha(mPreviewLeftBackground, PREVIEW_ALPHA);
-            setAlpha(mPreviewRightBackground, PREVIEW_ALPHA);
-            mPreviewOffset = keyboardViewAttr.getDimensionPixelOffset(
-                    R.styleable.KeyboardView_keyPreviewOffset, 0);
-            mPreviewHeight = keyboardViewAttr.getDimensionPixelSize(
-                    R.styleable.KeyboardView_keyPreviewHeight, 80);
-            mLingerTimeout = keyboardViewAttr.getInt(
-                    R.styleable.KeyboardView_keyPreviewLingerTimeout, 0);
-
-            mPreviewTextRatio = ResourceUtils.getFraction(keyAttr,
-                    R.styleable.Keyboard_Key_keyPreviewTextRatio);
-            mPreviewTextColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyPreviewTextColor, 0);
-        }
-
-        public void updateParams(final Keyboard keyboard, final KeyDrawParams keyDrawParams) {
-            final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
-            if (ResourceUtils.isValidFraction(mPreviewTextRatio)) {
-                mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio);
-            }
-            mKeyLetterSize = keyDrawParams.mKeyLetterSize;
-            mKeyTypeface = keyDrawParams.mKeyTypeface;
-        }
-
-        private static void setAlpha(final Drawable drawable, final int alpha) {
-            if (drawable == null) return;
-            drawable.setAlpha(alpha);
-        }
-    }
-
     public KeyboardView(Context context, AttributeSet attrs) {
         this(context, attrs, R.attr.keyboardViewStyle);
     }
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index e8e6c15..2da2f6d 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -43,6 +43,7 @@
 import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
 import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
 import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
+import com.android.inputmethod.keyboard.internal.KeyDrawParams;
 import com.android.inputmethod.keyboard.internal.SuddenJumpingTouchEventHandler;
 import com.android.inputmethod.latin.Constants;
 import com.android.inputmethod.latin.LatinIME;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java
new file mode 100644
index 0000000..971020b
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import android.content.res.TypedArray;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
+
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.latin.Constants;
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.ResourceUtils;
+
+public class KeyDrawParams {
+    // XML attributes
+    public final int mKeyTextColor;
+    public final int mKeyTextInactivatedColor;
+    public final float mKeyLabelHorizontalPadding;
+    public final float mKeyHintLetterPadding;
+    public final float mKeyPopupHintLetterPadding;
+    public final float mKeyShiftedLetterHintPadding;
+    public final int mKeyTextShadowColor;
+    public final float mKeyTextShadowRadius;
+    public final Drawable mKeyBackground;
+    public final int mKeyHintLetterColor;
+    public final int mKeyHintLabelColor;
+    public final int mKeyShiftedLetterHintInactivatedColor;
+    public final int mKeyShiftedLetterHintActivatedColor;
+
+    private final Typeface mKeyTypefaceFromKeyboardView;
+    private final float mKeyLetterRatio;
+    private final int mKeyLetterSizeFromKeyboardView;
+    private final float mKeyLargeLetterRatio;
+    private final float mKeyLabelRatio;
+    private final float mKeyLargeLabelRatio;
+    private final float mKeyHintLetterRatio;
+    private final float mKeyShiftedLetterHintRatio;
+    private final float mKeyHintLabelRatio;
+
+    public final Rect mPadding = new Rect();
+    public Typeface mKeyTypeface;
+    public int mKeyLetterSize;
+    public int mKeyLargeLetterSize;
+    public int mKeyLabelSize;
+    public int mKeyLargeLabelSize;
+    public int mKeyHintLetterSize;
+    public int mKeyShiftedLetterHintSize;
+    public int mKeyHintLabelSize;
+    public int mAnimAlpha;
+
+    public KeyDrawParams(final TypedArray keyboardViewAttr, final TypedArray keyAttr) {
+        mKeyBackground = keyboardViewAttr.getDrawable(R.styleable.KeyboardView_keyBackground);
+        mKeyBackground.getPadding(mPadding);
+
+        mKeyLetterRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyLetterSize);
+        mKeyLetterSizeFromKeyboardView = ResourceUtils.getDimensionPixelSize(keyAttr,
+                R.styleable.Keyboard_Key_keyLetterSize);
+        mKeyLabelRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyLabelSize);
+        mKeyLabelSize = ResourceUtils.getDimensionPixelSize(keyAttr,
+                R.styleable.Keyboard_Key_keyLabelSize);
+        mKeyLargeLabelRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyLargeLabelRatio);
+        mKeyLargeLetterRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyLargeLetterRatio);
+        mKeyHintLetterRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyHintLetterRatio);
+        mKeyShiftedLetterHintRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyShiftedLetterHintRatio);
+        mKeyHintLabelRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyHintLabelRatio);
+        mKeyLabelHorizontalPadding = keyAttr.getDimension(
+                R.styleable.Keyboard_Key_keyLabelHorizontalPadding, 0);
+        mKeyHintLetterPadding = keyAttr.getDimension(
+                R.styleable.Keyboard_Key_keyHintLetterPadding, 0);
+        mKeyPopupHintLetterPadding = keyAttr.getDimension(
+                R.styleable.Keyboard_Key_keyPopupHintLetterPadding, 0);
+        mKeyShiftedLetterHintPadding = keyAttr.getDimension(
+                R.styleable.Keyboard_Key_keyShiftedLetterHintPadding, 0);
+        mKeyTextColor = keyAttr.getColor(
+                R.styleable.Keyboard_Key_keyTextColor, Color.WHITE);
+        mKeyTextInactivatedColor = keyAttr.getColor(
+                R.styleable.Keyboard_Key_keyTextInactivatedColor, Color.WHITE);
+        mKeyHintLetterColor = keyAttr.getColor(
+                R.styleable.Keyboard_Key_keyHintLetterColor, Color.TRANSPARENT);
+        mKeyHintLabelColor = keyAttr.getColor(
+                R.styleable.Keyboard_Key_keyHintLabelColor, Color.TRANSPARENT);
+        mKeyShiftedLetterHintInactivatedColor = keyAttr.getColor(
+                R.styleable.Keyboard_Key_keyShiftedLetterHintInactivatedColor, Color.TRANSPARENT);
+        mKeyShiftedLetterHintActivatedColor = keyAttr.getColor(
+                R.styleable.Keyboard_Key_keyShiftedLetterHintActivatedColor, Color.TRANSPARENT);
+        mKeyTypefaceFromKeyboardView = Typeface.defaultFromStyle(
+                keyAttr.getInt(R.styleable.Keyboard_Key_keyTypeface, Typeface.NORMAL));
+        mKeyTextShadowColor = keyAttr.getColor(
+                R.styleable.Keyboard_Key_keyTextShadowColor, Color.TRANSPARENT);
+        mKeyTextShadowRadius = keyAttr.getFloat(
+                R.styleable.Keyboard_Key_keyTextShadowRadius, 0f);
+    }
+
+    public void updateParams(final Keyboard keyboard) {
+        mKeyTypeface = (keyboard.mKeyTypeface != null)
+                ? keyboard.mKeyTypeface : mKeyTypefaceFromKeyboardView;
+        final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
+        mKeyLetterSize = selectTextSizeFromDimensionOrRatio(keyHeight,
+                mKeyLetterSizeFromKeyboardView, mKeyLetterRatio,
+                mKeyLetterSizeFromKeyboardView);
+        // Override if size/ratio is specified in Keyboard.
+        mKeyLetterSize = selectTextSizeFromDimensionOrRatio(keyHeight, keyboard.mKeyLetterSize,
+                keyboard.mKeyLetterRatio, mKeyLetterSize);
+        if (ResourceUtils.isValidFraction(mKeyLabelRatio)) {
+            mKeyLabelSize = (int)(keyHeight * mKeyLabelRatio);
+        }
+        mKeyLargeLabelSize = (int)(keyHeight * mKeyLargeLabelRatio);
+        mKeyLargeLetterSize = (int)(keyHeight * mKeyLargeLetterRatio);
+        mKeyHintLetterSize = selectTextSizeFromKeyboardOrView(keyHeight,
+                keyboard.mKeyHintLetterRatio, mKeyHintLetterRatio);
+        mKeyShiftedLetterHintSize = selectTextSizeFromKeyboardOrView(keyHeight,
+                keyboard.mKeyShiftedLetterHintRatio, mKeyShiftedLetterHintRatio);
+        mKeyHintLabelSize = (int)(keyHeight * mKeyHintLabelRatio);
+    }
+
+    private static final int selectTextSizeFromDimensionOrRatio(final int keyHeight,
+            final int dimens, final float ratio, final int defaultDimens) {
+        if (ResourceUtils.isValidDimensionPixelSize(dimens)) {
+            return dimens;
+        }
+        if (ResourceUtils.isValidFraction(ratio)) {
+            return (int)(keyHeight * ratio);
+        }
+        return defaultDimens;
+    }
+
+    private static final int selectTextSizeFromKeyboardOrView(final int keyHeight,
+            final float ratioFromKeyboard, final float ratioFromView) {
+        final float ratio = ResourceUtils.isValidFraction(ratioFromKeyboard)
+                ? ratioFromKeyboard : ratioFromView;
+        return (int)(keyHeight * ratio);
+    }
+
+    public void blendAlpha(final Paint paint) {
+        final int color = paint.getColor();
+        paint.setARGB((paint.getAlpha() * mAnimAlpha) / Constants.Color.ALPHA_OPAQUE,
+                Color.red(color), Color.green(color), Color.blue(color));
+    }
+}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyPreviewDrawParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyPreviewDrawParams.java
new file mode 100644
index 0000000..a3a3850
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyPreviewDrawParams.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import android.content.res.TypedArray;
+import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
+
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.ResourceUtils;
+
+public class KeyPreviewDrawParams {
+    // XML attributes.
+    public final Drawable mPreviewBackground;
+    public final Drawable mPreviewLeftBackground;
+    public final Drawable mPreviewRightBackground;
+    public final int mPreviewTextColor;
+    public final int mPreviewOffset;
+    public final int mPreviewHeight;
+    public final int mLingerTimeout;
+
+    private final float mPreviewTextRatio;
+
+    // The graphical geometry of the key preview.
+    // <-width->
+    // +-------+   ^
+    // |       |   |
+    // |preview| height (visible)
+    // |       |   |
+    // +       + ^ v
+    //  \     /  |offset
+    // +-\   /-+ v
+    // |  +-+  |
+    // |parent |
+    // |    key|
+    // +-------+
+    // The background of a {@link TextView} being used for a key preview may have invisible
+    // paddings. To align the more keys keyboard panel's visible part with the visible part of
+    // the background, we need to record the width and height of key preview that don't include
+    // invisible paddings.
+    public int mPreviewVisibleWidth;
+    public int mPreviewVisibleHeight;
+    // The key preview may have an arbitrary offset and its background that may have a bottom
+    // padding. To align the more keys keyboard and the key preview we also need to record the
+    // offset between the top edge of parent key and the bottom of the visible part of key
+    // preview background.
+    public int mPreviewVisibleOffset;
+
+    public Typeface mKeyTypeface;
+    public int mPreviewTextSize;
+    public int mKeyLetterSize;
+    public final int[] mCoordinates = new int[2];
+
+    private static final int PREVIEW_ALPHA = 240;
+
+    public KeyPreviewDrawParams(final TypedArray keyboardViewAttr, final TypedArray keyAttr) {
+        mPreviewBackground = keyboardViewAttr.getDrawable(
+                R.styleable.KeyboardView_keyPreviewBackground);
+        mPreviewLeftBackground = keyboardViewAttr.getDrawable(
+                R.styleable.KeyboardView_keyPreviewLeftBackground);
+        mPreviewRightBackground = keyboardViewAttr.getDrawable(
+                R.styleable.KeyboardView_keyPreviewRightBackground);
+        setAlpha(mPreviewBackground, PREVIEW_ALPHA);
+        setAlpha(mPreviewLeftBackground, PREVIEW_ALPHA);
+        setAlpha(mPreviewRightBackground, PREVIEW_ALPHA);
+        mPreviewOffset = keyboardViewAttr.getDimensionPixelOffset(
+                R.styleable.KeyboardView_keyPreviewOffset, 0);
+        mPreviewHeight = keyboardViewAttr.getDimensionPixelSize(
+                R.styleable.KeyboardView_keyPreviewHeight, 80);
+        mLingerTimeout = keyboardViewAttr.getInt(
+                R.styleable.KeyboardView_keyPreviewLingerTimeout, 0);
+
+        mPreviewTextRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyPreviewTextRatio);
+        mPreviewTextColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyPreviewTextColor, 0);
+    }
+
+    public void updateParams(final Keyboard keyboard, final KeyDrawParams keyDrawParams) {
+        final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap;
+        if (ResourceUtils.isValidFraction(mPreviewTextRatio)) {
+            mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio);
+        }
+        mKeyLetterSize = keyDrawParams.mKeyLetterSize;
+        mKeyTypeface = keyDrawParams.mKeyTypeface;
+    }
+
+    private static void setAlpha(final Drawable drawable, final int alpha) {
+        if (drawable == null) return;
+        drawable.setAlpha(alpha);
+    }
+}
