Separate functional key background from normal one

This CL also moves spacebarBackground attribute from MainKeyboardView
to KeyboardView.

This CL must be checked in together with I48c383ca97.

Bug: 14419121
Change-Id: Id356d0086a8fb21375fb5c66076873258fb3d63e
diff --git a/java/res/drawable/btn_keyboard_key_ics.xml b/java/res/drawable/btn_keyboard_key_ics.xml
index 9db0eee..af14cd5 100644
--- a/java/res/drawable/btn_keyboard_key_ics.xml
+++ b/java/res/drawable/btn_keyboard_key_ics.xml
@@ -15,12 +15,6 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <!-- Functional keys. -->
-    <item android:state_single="true" android:state_pressed="true"
-          android:drawable="@drawable/btn_keyboard_key_dark_pressed_ics" />
-    <item android:state_single="true"
-          android:drawable="@drawable/btn_keyboard_key_dark_normal_holo" />
-
     <!-- Action keys. -->
     <item android:state_active="true" android:state_pressed="true"
           android:drawable="@drawable/btn_keyboard_key_dark_pressed_ics" />
diff --git a/java/res/drawable/btn_keyboard_key_klp.xml b/java/res/drawable/btn_keyboard_key_klp.xml
index 500e3ea..56c295f 100644
--- a/java/res/drawable/btn_keyboard_key_klp.xml
+++ b/java/res/drawable/btn_keyboard_key_klp.xml
@@ -15,12 +15,6 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <!-- Functional keys. -->
-    <item android:state_single="true" android:state_pressed="true"
-          android:drawable="@drawable/btn_keyboard_key_dark_pressed_klp" />
-    <item android:state_single="true"
-          android:drawable="@drawable/btn_keyboard_key_dark_normal_holo" />
-
     <!-- Action keys. -->
     <item android:state_active="true" android:state_pressed="true"
           android:drawable="@drawable/btn_keyboard_key_dark_pressed_klp" />
diff --git a/java/res/drawable/btn_keyboard_key_lmp.xml b/java/res/drawable/btn_keyboard_key_lmp.xml
index 4aaafb5..636b637 100644
--- a/java/res/drawable/btn_keyboard_key_lmp.xml
+++ b/java/res/drawable/btn_keyboard_key_lmp.xml
@@ -15,12 +15,6 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <!-- Functional keys. -->
-    <item android:state_single="true" android:state_pressed="true"
-          android:drawable="@color/key_background_pressed_lmp" />
-    <item android:state_single="true"
-          android:drawable="@color/key_background_lmp" />
-
     <!-- Action keys. -->
     <item android:state_active="true" android:state_pressed="true"
           android:drawable="@color/key_background_pressed_lmp" />
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 769a1d9..79cc139 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -41,13 +41,16 @@
     </declare-styleable>
 
     <declare-styleable name="KeyboardView">
-        <!-- Image for the key. This image needs to be a {@link StateListDrawable}, with the
-             following possible states: normal, pressed, checkable, checkable+pressed,
+        <!-- Background image for the key. This image needs to be a {@link StateListDrawable},
+             with the following possible states: normal, pressed, checkable, checkable+pressed,
              checkable+checked, checkable+checked+pressed. -->
         <attr name="keyBackground" format="reference" />
-        <!-- Image for the functional key used in Emoji layout. -->
-        <attr name="keyBackgroundEmojiFunctional" format="reference" />
-
+        <!-- Background image for the functional key. This image needs to be a
+             {@link StateListDrawable}, with the following possible states: normal, pressed. -->
+        <attr name="functionalKeyBackground" format="reference" />
+        <!-- Background image for the spacebar.  This image needs to be a
+             {@link StateListDrawable}, with the following possible states: normal, pressed. -->
+        <attr name="spacebarBackground" format="reference" />
         <!-- Horizontal padding of left/right aligned key label to the edge of the key. -->
         <attr name="keyLabelHorizontalPadding" format="dimension" />
         <!-- Right padding of hint letter to the edge of the key.-->
@@ -76,8 +79,6 @@
         <attr name="languageOnSpacebarTextColor" format="color" />
         <attr name="languageOnSpacebarTextShadowRadius" format="float" />
         <attr name="languageOnSpacebarTextShadowColor" format="color" />
-        <!-- Background image for the spacebar. -->
-        <attr name="spacebarBackground" format="reference" />
         <!-- Fadeout animator for spacebar language label. -->
         <attr name="languageOnSpacebarFinalAlpha" format="integer" />
         <attr name="languageOnSpacebarFadeoutAnimator" format="reference" />
diff --git a/java/res/values/themes-common.xml b/java/res/values/themes-common.xml
index 76abb10..df26fb3 100644
--- a/java/res/values/themes-common.xml
+++ b/java/res/values/themes-common.xml
@@ -109,12 +109,7 @@
     <style name="KeyPreviewTextView" />
     <!-- Though {@link EmojiPalettesView} doesn't extend {@link KeyboardView}, some views inside it,
          for instance delete button, need themed {@link KeyboardView} attributes. -->
-    <style
-        name="EmojiPalettesView"
-        parent="KeyboardView"
-    >
-        <item name="emojiTabLabelColor">@color/emoji_tab_label_color_holo</item>
-    </style>
+    <style name="EmojiPalettesView" />
     <style name="MoreKeysKeyboard" />
     <style
         name="MoreKeysKeyboardView"
diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml
index d7943ee..560cfc5 100644
--- a/java/res/values/themes-ics.xml
+++ b/java/res/values/themes-ics.xml
@@ -48,6 +48,8 @@
     >
         <item name="android:background">@drawable/keyboard_background_holo</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_ics</item>
+        <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_ics</item>
+        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_ics</item>
         <item name="keyTypeface">bold</item>
         <item name="keyTextColor">@color/key_text_color_holo</item>
         <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_holo</item>
@@ -73,7 +75,6 @@
         <item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
         <item name="languageOnSpacebarTextShadowRadius">1.0</item>
         <item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
-        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_ics</item>
     </style>
     <style
         name="KeyPreviewTextView.ICS"
@@ -85,9 +86,8 @@
          for instance delete button, need themed {@link KeyboardView} attributes. -->
     <style
         name="EmojiPalettesView.ICS"
-        parent="KeyboardView.ICS"
+        parent="MainKeyboardView.ICS"
     >
-        <item name="keyBackgroundEmojiFunctional">@drawable/btn_keyboard_key_functional_ics</item>
         <item name="emojiTabLabelColor">@color/emoji_tab_label_color_holo</item>
     </style>
     <style
diff --git a/java/res/values/themes-klp.xml b/java/res/values/themes-klp.xml
index 13500fe..453e5cb 100644
--- a/java/res/values/themes-klp.xml
+++ b/java/res/values/themes-klp.xml
@@ -48,6 +48,8 @@
     >
         <item name="android:background">@drawable/keyboard_background_holo</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_klp</item>
+        <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_klp</item>
+        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_klp</item>
         <item name="keyTypeface">bold</item>
         <item name="keyTextColor">@color/key_text_color_holo</item>
         <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_holo</item>
@@ -73,7 +75,6 @@
         <item name="languageOnSpacebarTextColor">@color/spacebar_text_color_holo</item>
         <item name="languageOnSpacebarTextShadowRadius">1.0</item>
         <item name="languageOnSpacebarTextShadowColor">@color/spacebar_text_shadow_color_holo</item>
-        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_klp</item>
     </style>
     <style
         name="KeyPreviewTextView.KLP"
@@ -85,9 +86,8 @@
          for instance delete button, need themed {@link KeyboardView} attributes. -->
     <style
         name="EmojiPalettesView.KLP"
-        parent="KeyboardView.KLP"
+        parent="MainKeyboardView.KLP"
     >
-        <item name="keyBackgroundEmojiFunctional">@drawable/btn_keyboard_key_functional_klp</item>
         <item name="emojiTabLabelColor">@color/emoji_tab_label_color_holo</item>
     </style>
     <style
diff --git a/java/res/values/themes-lmp.xml b/java/res/values/themes-lmp.xml
index c05190b..a9b8a93 100644
--- a/java/res/values/themes-lmp.xml
+++ b/java/res/values/themes-lmp.xml
@@ -48,6 +48,8 @@
     >
         <item name="android:background">@color/keyboard_background_lmp</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_lmp</item>
+        <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_lmp</item>
+        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_lmp</item>
         <item name="keyTypeface">bold</item>
         <item name="keyTextColor">@color/key_text_color_holo</item>
         <item name="keyTextInactivatedColor">@color/key_text_inactive_color_lmp</item>
@@ -73,7 +75,6 @@
         <item name="languageOnSpacebarTextColor">@color/key_text_inactive_color_lmp</item>
         <!-- A negative value to disable text shadow layer. -->
         <item name="languageOnSpacebarTextShadowRadius">-1.0</item>
-        <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_lmp</item>
     </style>
     <style
         name="KeyPreviewTextView.LMP"
@@ -85,9 +86,8 @@
          for instance delete button, need themed {@link KeyboardView} attributes. -->
     <style
         name="EmojiPalettesView.LMP"
-        parent="KeyboardView.LMP"
+        parent="MainKeyboardView.LMP"
     >
-        <item name="keyBackgroundEmojiFunctional">@drawable/btn_keyboard_key_functional_lmp</item>
         <item name="emojiTabLabelColor">@color/emoji_tab_label_color_holo</item>
     </style>
     <style
diff --git a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
index d5f166c..2012d34 100644
--- a/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
+++ b/java/src/com/android/inputmethod/keyboard/EmojiPalettesView.java
@@ -23,6 +23,7 @@
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.Color;
+import android.graphics.Typeface;
 import android.os.CountDownTimer;
 import android.preference.PreferenceManager;
 import android.support.v4.view.ViewPager;
@@ -66,8 +67,8 @@
 public final class EmojiPalettesView extends LinearLayout implements OnTabChangeListener,
         ViewPager.OnPageChangeListener, View.OnClickListener, View.OnTouchListener,
         EmojiPageKeyboardView.OnKeyEventListener {
-    private final int mKeyBackgroundId;
-    private final int mEmojiFunctionalKeyBackgroundId;
+    private final int mFunctionalKeyBackgroundId;
+    private final int mSpacebarBackgroundId;
     private final ColorStateList mTabLabelColor;
     private final DeleteKeyOnTouchListener mDeleteKeyOnTouchListener;
     private EmojiPalettesAdapter mEmojiPalettesAdapter;
@@ -92,10 +93,12 @@
         super(context, attrs, defStyle);
         final TypedArray keyboardViewAttr = context.obtainStyledAttributes(attrs,
                 R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
-        mKeyBackgroundId = keyboardViewAttr.getResourceId(
+        final int keyBackgroundId = keyboardViewAttr.getResourceId(
                 R.styleable.KeyboardView_keyBackground, 0);
-        mEmojiFunctionalKeyBackgroundId = keyboardViewAttr.getResourceId(
-                R.styleable.KeyboardView_keyBackgroundEmojiFunctional, 0);
+        mFunctionalKeyBackgroundId = keyboardViewAttr.getResourceId(
+                R.styleable.KeyboardView_functionalKeyBackground, keyBackgroundId);
+        mSpacebarBackgroundId = keyboardViewAttr.getResourceId(
+                R.styleable.KeyboardView_spacebarBackground, keyBackgroundId);
         keyboardViewAttr.recycle();
         final TypedArray emojiPalettesViewAttr = context.obtainStyledAttributes(attrs,
                 R.styleable.EmojiPalettesView, defStyle, R.style.EmojiPalettesView);
@@ -182,6 +185,7 @@
 
         // deleteKey depends only on OnTouchListener.
         final ImageView deleteKey = (ImageView)findViewById(R.id.emoji_keyboard_delete);
+        deleteKey.setBackgroundResource(mFunctionalKeyBackgroundId);
         deleteKey.setTag(Constants.CODE_DELETE);
         deleteKey.setOnTouchListener(mDeleteKeyOnTouchListener);
 
@@ -193,17 +197,17 @@
         // The text on alphabet keys are set at
         // {@link #startEmojiPalettes(String,int,float,Typeface)}.
         mAlphabetKeyLeft = (TextView)findViewById(R.id.emoji_keyboard_alphabet_left);
-        mAlphabetKeyLeft.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
+        mAlphabetKeyLeft.setBackgroundResource(mFunctionalKeyBackgroundId);
         mAlphabetKeyLeft.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
         mAlphabetKeyLeft.setOnTouchListener(this);
         mAlphabetKeyLeft.setOnClickListener(this);
         mAlphabetKeyRight = (TextView)findViewById(R.id.emoji_keyboard_alphabet_right);
-        mAlphabetKeyRight.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
+        mAlphabetKeyRight.setBackgroundResource(mFunctionalKeyBackgroundId);
         mAlphabetKeyRight.setTag(Constants.CODE_ALPHA_FROM_EMOJI);
         mAlphabetKeyRight.setOnTouchListener(this);
         mAlphabetKeyRight.setOnClickListener(this);
         final ImageView spaceKey = (ImageView)findViewById(R.id.emoji_keyboard_space);
-        spaceKey.setBackgroundResource(mKeyBackgroundId);
+        spaceKey.setBackgroundResource(mSpacebarBackgroundId);
         spaceKey.setTag(Constants.CODE_SPACE);
         spaceKey.setOnTouchListener(this);
         spaceKey.setOnClickListener(this);
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 816a943..4c22507 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -218,7 +218,7 @@
      *
      * @param keySpec the key specification.
      * @param keyAttr the Key XML attributes array.
-     * @param keyStyle the {@link KeyStyle} of this key.
+     * @param style the {@link KeyStyle} of this key.
      * @param params the keyboard building parameters.
      * @param row the row that this key belongs to. row's x-coordinate will be the right edge of
      *        this key.
@@ -857,17 +857,6 @@
         android.R.attr.state_empty
     };
 
-    // functional normal state (with properties)
-    private static final int[] KEY_STATE_FUNCTIONAL_NORMAL = {
-            android.R.attr.state_single
-    };
-
-    // functional pressed state (with properties)
-    private static final int[] KEY_STATE_FUNCTIONAL_PRESSED = {
-            android.R.attr.state_single,
-            android.R.attr.state_pressed
-    };
-
     // action normal state (with properties)
     private static final int[] KEY_STATE_ACTIVE_NORMAL = {
             android.R.attr.state_active
@@ -880,25 +869,43 @@
     };
 
     /**
-     * Returns the drawable state for the key, based on the current state and type of the key.
-     * @return the drawable state of the key.
+     * Returns the background drawable for the key, based on the current state and type of the key.
+     * @return the background drawable of the key.
      * @see android.graphics.drawable.StateListDrawable#setState(int[])
      */
-    public final int[] getCurrentDrawableState() {
-        switch (mBackgroundType) {
-        case BACKGROUND_TYPE_FUNCTIONAL:
-            return mPressed ? KEY_STATE_FUNCTIONAL_PRESSED : KEY_STATE_FUNCTIONAL_NORMAL;
-        case BACKGROUND_TYPE_ACTION:
-            return mPressed ? KEY_STATE_ACTIVE_PRESSED : KEY_STATE_ACTIVE_NORMAL;
-        case BACKGROUND_TYPE_STICKY_OFF:
-            return mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_OFF : KEY_STATE_NORMAL_HIGHLIGHT_OFF;
-        case BACKGROUND_TYPE_STICKY_ON:
-            return mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_ON : KEY_STATE_NORMAL_HIGHLIGHT_ON;
-        case BACKGROUND_TYPE_EMPTY:
-            return mPressed ? KEY_STATE_PRESSED : KEY_STATE_EMPTY;
-        default: /* BACKGROUND_TYPE_NORMAL */
-            return mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
+    public final Drawable selectBackgroundDrawable(final Drawable keyBackground,
+            final Drawable functionalKeyBackground, final Drawable spacebarBackground) {
+        final Drawable background;
+        if (mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) {
+            background = functionalKeyBackground;
+        } else if (getCode() == Constants.CODE_SPACE) {
+            background = spacebarBackground;
+        } else {
+            background = keyBackground;
         }
+        final int[] stateSet;
+        switch (mBackgroundType) {
+        case BACKGROUND_TYPE_ACTION:
+            stateSet = mPressed ? KEY_STATE_ACTIVE_PRESSED : KEY_STATE_ACTIVE_NORMAL;
+            break;
+        case BACKGROUND_TYPE_STICKY_OFF:
+            stateSet = mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_OFF : KEY_STATE_NORMAL_HIGHLIGHT_OFF;
+            break;
+        case BACKGROUND_TYPE_STICKY_ON:
+            stateSet = mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_ON : KEY_STATE_NORMAL_HIGHLIGHT_ON;
+            break;
+        case BACKGROUND_TYPE_EMPTY:
+            stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_EMPTY;
+            break;
+        case BACKGROUND_TYPE_FUNCTIONAL:
+            stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
+            break;
+        default: /* BACKGROUND_TYPE_NORMAL */
+            stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
+            break;
+        }
+        background.setState(stateSet);
+        return background;
     }
 
     public static class Spacer extends Key {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 4450a44..a6eac4c 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -47,6 +47,8 @@
  * A view that renders a virtual {@link Keyboard}.
  *
  * @attr ref R.styleable#KeyboardView_keyBackground
+ * @attr ref R.styleable#KeyboardView_functionalKeyBackground
+ * @attr ref R.styleable#KeyboardView_spacebarBackground
  * @attr ref R.styleable#KeyboardView_keyLabelHorizontalPadding
  * @attr ref R.styleable#KeyboardView_keyHintLetterPadding
  * @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
@@ -81,6 +83,8 @@
     private final float mKeyTextShadowRadius;
     private final float mVerticalCorrection;
     private final Drawable mKeyBackground;
+    private final Drawable mFunctionalKeyBackground;
+    private final Drawable mSpacebarBackground;
     private final Rect mKeyBackgroundPadding = new Rect();
     private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f;
 
@@ -125,6 +129,14 @@
                 R.styleable.KeyboardView, defStyle, R.style.KeyboardView);
         mKeyBackground = keyboardViewAttr.getDrawable(R.styleable.KeyboardView_keyBackground);
         mKeyBackground.getPadding(mKeyBackgroundPadding);
+        final Drawable functionalKeyBackground = keyboardViewAttr.getDrawable(
+                R.styleable.KeyboardView_functionalKeyBackground);
+        mFunctionalKeyBackground = (functionalKeyBackground != null) ? functionalKeyBackground
+                : mKeyBackground;
+        final Drawable spacebarBackground = keyboardViewAttr.getDrawable(
+                R.styleable.KeyboardView_spacebarBackground);
+        mSpacebarBackground = (spacebarBackground != null) ? spacebarBackground
+                : mKeyBackground;
         mKeyLabelHorizontalPadding = keyboardViewAttr.getDimensionPixelOffset(
                 R.styleable.KeyboardView_keyLabelHorizontalPadding, 0);
         mKeyHintLetterPadding = keyboardViewAttr.getDimension(
@@ -324,7 +336,9 @@
         params.mAnimAlpha = Constants.Color.ALPHA_OPAQUE;
 
         if (!key.isSpacer()) {
-            onDrawKeyBackground(key, canvas, mKeyBackground);
+            final Drawable background = key.selectBackgroundDrawable(
+                    mKeyBackground, mFunctionalKeyBackground, mSpacebarBackground);
+            onDrawKeyBackground(key, canvas, background);
         }
         onDrawKeyTopVisuals(key, canvas, paint, params);
 
@@ -339,8 +353,6 @@
         final int bgHeight = key.getHeight() + padding.top + padding.bottom;
         final int bgX = -padding.left;
         final int bgY = -padding.top;
-        final int[] drawableState = key.getCurrentDrawableState();
-        background.setState(drawableState);
         final Rect bounds = background.getBounds();
         if (bgWidth != bounds.right || bgHeight != bounds.bottom) {
             background.setBounds(0, 0, bgWidth, bgHeight);
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 1a8e4b7..4a09768 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -76,7 +76,6 @@
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextColor
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextShadowRadius
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarTextShadowColor
- * @attr ref R.styleable#MainKeyboardView_spacebarBackground
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFinalAlpha
  * @attr ref R.styleable#MainKeyboardView_languageOnSpacebarFadeoutAnimator
  * @attr ref R.styleable#MainKeyboardView_altCodeKeyWhileTypingFadeoutAnimator
@@ -120,7 +119,6 @@
     /* Space key and its icon and background. */
     private Key mSpaceKey;
     private Drawable mSpacebarIcon;
-    private final Drawable mSpacebarBackground;
     // Stuff to draw language name on spacebar.
     private final int mLanguageOnSpacebarFinalAlpha;
     private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
@@ -154,7 +152,6 @@
     private final SlidingKeyInputDrawingPreview mSlidingKeyInputDrawingPreview;
 
     // Key preview
-    private static final boolean FADE_OUT_KEY_TOP_LETTER_WHEN_KEY_IS_PRESSED = false;
     private final KeyPreviewDrawParams mKeyPreviewDrawParams;
     private final KeyPreviewChoreographer mKeyPreviewChoreographer;
 
@@ -224,8 +221,6 @@
                 R.styleable.MainKeyboardView_backgroundDimAlpha, 0);
         mBackgroundDimAlphaPaint.setColor(Color.BLACK);
         mBackgroundDimAlphaPaint.setAlpha(backgroundDimAlpha);
-        mSpacebarBackground = mainKeyboardViewAttr.getDrawable(
-                R.styleable.MainKeyboardView_spacebarBackground);
         mAutoCorrectionSpacebarLedEnabled = mainKeyboardViewAttr.getBoolean(
                 R.styleable.MainKeyboardView_autoCorrectionSpacebarLedEnabled, false);
         mAutoCorrectionSpacebarLedIcon = mainKeyboardViewAttr.getDrawable(
@@ -557,6 +552,7 @@
     }
 
     // Note that this method is called from a non-UI thread.
+    @SuppressWarnings("static-method")
     public void setMainDictionaryAvailability(final boolean mainDictionaryAvailable) {
         PointerTracker.setMainDictionaryAvailability(mainDictionaryAvailable);
     }
@@ -864,30 +860,12 @@
         }
     }
 
-    // Draw key background.
-    @Override
-    protected void onDrawKeyBackground(final Key key, final Canvas canvas,
-            final Drawable background) {
-        if (key.getCode() == Constants.CODE_SPACE) {
-            super.onDrawKeyBackground(key, canvas, mSpacebarBackground);
-            return;
-        }
-        super.onDrawKeyBackground(key, canvas, background);
-    }
-
     @Override
     protected void onDrawKeyTopVisuals(final Key key, final Canvas canvas, final Paint paint,
             final KeyDrawParams params) {
         if (key.altCodeWhileTyping() && key.isEnabled()) {
             params.mAnimAlpha = mAltCodeKeyWhileTypingAnimAlpha;
         }
-        // Don't draw key top letter when key preview is showing.
-        if (FADE_OUT_KEY_TOP_LETTER_WHEN_KEY_IS_PRESSED
-                && mKeyPreviewChoreographer.isShowingKeyPreview(key)) {
-            // TODO: Fade out animation for the key top letter, and fade in animation for the key
-            // background color when the user presses the key.
-            return;
-        }
         final int code = key.getCode();
         if (code == Constants.CODE_SPACE) {
             drawSpacebar(key, canvas, paint);