Merge "Remove colorScheme attribute from KeyboardView"
diff --git a/java/res/drawable/btn_keyboard_key_stone.xml b/java/res/drawable/btn_keyboard_key_stone.xml
index a6040a0..27932e8 100644
--- a/java/res/drawable/btn_keyboard_key_stone.xml
+++ b/java/res/drawable/btn_keyboard_key_stone.xml
@@ -16,6 +16,13 @@
 
 <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_fulltrans_pressed" />
+    <item android:state_single="true"
+          android:drawable="@drawable/btn_keyboard_key_normal_stone" />
+
     <!-- Toggle keys. Use checkable/checked state. -->
 
     <item android:state_checkable="true" android:state_checked="true"
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index c88049e..d8d31e3 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -90,13 +90,6 @@
             <enum name="italic" value="2" />
             <enum name="boldItalic" value="3" />
         </attr>
-
-        <attr name="colorScheme" format="enum">
-            <!-- This should be aligned with KeyboardView.COLOR_SCHEME_* -->
-            <enum name="white" value="0" />
-            <enum name="black" value="1" />
-        </attr>
-
     </declare-styleable>
 
     <declare-styleable name="CandidateView">
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index 3780fe3..1363f64 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -59,7 +59,6 @@
         <item name="shadowColor">#BB000000</item>
         <item name="shadowRadius">2.75</item>
         <item name="backgroundDimAmount">0.5</item>
-        <item name="colorScheme">white</item>
     </style>
     <style name="KeyPreviewStyle">
         <item name="android:background">@drawable/keyboard_key_feedback</item>
@@ -107,7 +106,6 @@
         <item name="keyTextColor">@color/latinkeyboard_key_color_black</item>
         <item name="keyTextInactivatedColor">#FF808080</item>
         <item name="shadowColor">@color/latinkeyboard_key_color_white</item>
-        <item name="colorScheme">black</item>
     </style>
     <style name="PopupMiniKeyboardView.Stone" parent="PopupMiniKeyboardView">
         <item name="keyBackground">@drawable/btn_keyboard_key_stone</item>
diff --git a/java/res/xml-sw600dp/kbd_key_styles.xml b/java/res/xml-sw600dp/kbd_key_styles.xml
index 988f5c4..dbff293 100644
--- a/java/res/xml-sw600dp/kbd_key_styles.xml
+++ b/java/res/xml-sw600dp/kbd_key_styles.xml
@@ -22,21 +22,9 @@
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
     <!-- Base key style for the functional key -->
-    <switch>
-        <case
-            latin:colorScheme="white"
-        >
-            <key-style
-                latin:styleName="functionalKeyStyle"
-                latin:isFunctional="true" />
-        </case>
-        <case
-            latin:colorScheme="black"
-        >
-            <key-style
-                latin:styleName="functionalKeyStyle" />
-        </case>
-    </switch>
+    <key-style
+        latin:styleName="functionalKeyStyle"
+        latin:isFunctional="true" />
     <!-- Functional key styles -->
     <key-style
         latin:styleName="shiftKeyStyle"
diff --git a/java/res/xml-sw768dp/kbd_key_styles.xml b/java/res/xml-sw768dp/kbd_key_styles.xml
index ecfacc2..5d8c081 100644
--- a/java/res/xml-sw768dp/kbd_key_styles.xml
+++ b/java/res/xml-sw768dp/kbd_key_styles.xml
@@ -22,21 +22,9 @@
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
     <!-- Functional key styles -->
-    <switch>
-        <case
-            latin:colorScheme="white"
-        >
-            <key-style
-                latin:styleName="functionalKeyStyle"
-                latin:isFunctional="true" />
-        </case>
-        <case
-            latin:colorScheme="black"
-        >
-            <key-style
-                latin:styleName="functionalKeyStyle" />
-        </case>
-    </switch>
+    <key-style
+        latin:styleName="functionalKeyStyle"
+        latin:isFunctional="true" />
     <key-style
         latin:styleName="shiftKeyStyle"
         latin:code="@integer/key_shift"
diff --git a/java/res/xml/kbd_key_styles.xml b/java/res/xml/kbd_key_styles.xml
index fbc4c92..0c59fd8 100644
--- a/java/res/xml/kbd_key_styles.xml
+++ b/java/res/xml/kbd_key_styles.xml
@@ -22,21 +22,9 @@
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
     <!-- Base key style for the functional key -->
-    <switch>
-        <case
-            latin:colorScheme="white"
-        >
-            <key-style
-                latin:styleName="functionalKeyStyle"
-                latin:isFunctional="true" />
-        </case>
-        <case
-            latin:colorScheme="black"
-        >
-            <key-style
-                latin:styleName="functionalKeyStyle" />
-        </case>
-    </switch>
+    <key-style
+        latin:styleName="functionalKeyStyle"
+        latin:isFunctional="true" />
     <!-- Base key style for the key which may have settings key as popup key -->
     <switch>
         <case
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index d97bb67..2497eeb 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -42,7 +42,6 @@
     public final int mWidth;
     public final int mMode;
     public final int mXmlId;
-    public final int mColorScheme;
     public final boolean mNavigateAction;
     public final boolean mPasswordInput;
     public final boolean mHasSettingsKey;
@@ -56,9 +55,9 @@
 
     private final int mHashCode;
 
-    public KeyboardId(String xmlName, int xmlId, int colorScheme, Locale locale, int orientation,
-            int width, int mode, EditorInfo attribute, boolean hasSettingsKey,
-            boolean voiceKeyEnabled, boolean hasVoiceKey, boolean enableShiftLock) {
+    public KeyboardId(String xmlName, int xmlId, Locale locale, int orientation, int width,
+            int mode, EditorInfo attribute, boolean hasSettingsKey, boolean voiceKeyEnabled,
+            boolean hasVoiceKey, boolean enableShiftLock) {
         final int inputType = (attribute != null) ? attribute.inputType : 0;
         final int imeOptions = (attribute != null) ? attribute.imeOptions : 0;
         this.mLocale = locale;
@@ -66,7 +65,6 @@
         this.mWidth = width;
         this.mMode = mode;
         this.mXmlId = xmlId;
-        this.mColorScheme = colorScheme;
         // Note: Turn off checking navigation flag to show TAB key for now.
         this.mNavigateAction = InputTypeCompatUtils.isWebInputType(inputType);
 //                || EditorInfoCompatUtils.hasFlagNavigateNext(imeOptions)
@@ -91,7 +89,6 @@
                 width,
                 mode,
                 xmlId,
-                colorScheme,
                 mNavigateAction,
                 mPasswordInput,
                 hasSettingsKey,
@@ -103,15 +100,15 @@
     }
 
     public KeyboardId cloneWithNewLayout(String xmlName, int xmlId) {
-        return new KeyboardId(xmlName, xmlId, mColorScheme, mLocale, mOrientation, mWidth, mMode,
-                mAttribute, mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
+        return new KeyboardId(xmlName, xmlId, mLocale, mOrientation, mWidth, mMode, mAttribute,
+                mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
     }
 
     public KeyboardId cloneWithNewGeometry(int width) {
         if (mWidth == width)
             return this;
-        return new KeyboardId(mXmlName, mXmlId, mColorScheme, mLocale, mOrientation, width, mMode,
-                mAttribute, mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
+        return new KeyboardId(mXmlName, mXmlId, mLocale, mOrientation, width, mMode, mAttribute,
+                mHasSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, mEnableShiftLock);
     }
 
     public int getXmlId() {
@@ -145,7 +142,6 @@
             && other.mWidth == this.mWidth
             && other.mMode == this.mMode
             && other.mXmlId == this.mXmlId
-            && other.mColorScheme == this.mColorScheme
             && other.mNavigateAction == this.mNavigateAction
             && other.mPasswordInput == this.mPasswordInput
             && other.mHasSettingsKey == this.mHasSettingsKey
@@ -162,13 +158,12 @@
 
     @Override
     public String toString() {
-        return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s%s]",
+        return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s]",
                 mXmlName,
                 mLocale,
                 (mOrientation == 1 ? "port" : "land"), mWidth,
                 modeName(mMode),
                 EditorInfoCompatUtils.imeOptionsName(mImeAction),
-                colorSchemeName(mColorScheme),
                 (mNavigateAction ? " navigateAction" : ""),
                 (mPasswordInput ? " passwordInput" : ""),
                 (mHasSettingsKey ? " hasSettingsKey" : ""),
@@ -189,12 +184,4 @@
         }
         return null;
     }
-
-    public static String colorSchemeName(int colorScheme) {
-        switch (colorScheme) {
-        case KeyboardView.COLOR_SCHEME_WHITE: return "white";
-        case KeyboardView.COLOR_SCHEME_BLACK: return "black";
-        }
-        return null;
-    }
 }
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 157337c..7c70168 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -258,7 +258,6 @@
     private KeyboardId getKeyboardId(EditorInfo attribute, boolean isSymbols) {
         final int mode = Utils.getKeyboardMode(attribute);
         final boolean hasVoiceKey = hasVoiceKey(isSymbols);
-        final int charColorId = getColorScheme();
         final int xmlId;
         final boolean enableShiftLock;
 
@@ -291,9 +290,8 @@
             mKeyboardWidth = res.getDisplayMetrics().widthPixels;
         final Locale locale = mSubtypeSwitcher.getInputLocale();
         return new KeyboardId(
-                res.getResourceEntryName(xmlId), xmlId, charColorId, locale, orientation,
-                mKeyboardWidth, mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey,
-                enableShiftLock);
+                res.getResourceEntryName(xmlId), xmlId, locale, orientation, mKeyboardWidth,
+                mode, attribute, hasSettingsKey, mVoiceKeyEnabled, hasVoiceKey, enableShiftLock);
     }
 
     private KeyboardId makeSiblingKeyboardId(KeyboardId base, int alphabet, int phone) {
@@ -788,11 +786,6 @@
         }
     }
 
-    private int getColorScheme() {
-        return (mKeyboardView != null)
-                ? mKeyboardView.getColorScheme() : KeyboardView.COLOR_SCHEME_WHITE;
-    }
-
     public void onAutoCorrectionStateChanged(boolean isAutoCorrection) {
         if (mIsAutoCorrectionActive != isAutoCorrection) {
             mIsAutoCorrectionActive = isAutoCorrection;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index c372281..4b16214 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -62,7 +62,6 @@
  * presses and touch movements.
  *
  * @attr ref R.styleable#KeyboardView_backgroundDimAmount
- * @attr ref R.styleable#KeyboardView_colorScheme
  * @attr ref R.styleable#KeyboardView_keyBackground
  * @attr ref R.styleable#KeyboardView_keyHysteresisDistance
  * @attr ref R.styleable#KeyboardView_keyLetterRatio
@@ -91,9 +90,6 @@
     private static final boolean ENABLE_CAPSLOCK_BY_LONGPRESS = true;
     private static final boolean ENABLE_CAPSLOCK_BY_DOUBLETAP = true;
 
-    public static final int COLOR_SCHEME_WHITE = 0;
-    public static final int COLOR_SCHEME_BLACK = 1;
-
     // Timing constants
     private final int mKeyRepeatInterval;
 
@@ -109,7 +105,6 @@
     private final float mKeyLabelRatio;
     private final float mKeyHintLetterRatio;
     private final float mKeyUppercaseLetterRatio;
-    private final int mColorScheme;
     private final int mShadowColor;
     private final float mShadowRadius;
     private final Drawable mKeyBackground;
@@ -356,7 +351,6 @@
         mShadowRadius = a.getFloat(R.styleable.KeyboardView_shadowRadius, 0f);
         // TODO: Use Theme (android.R.styleable.Theme_backgroundDimAmount)
         mBackgroundDimAmount = a.getFloat(R.styleable.KeyboardView_backgroundDimAmount, 0.5f);
-        mColorScheme = a.getInt(R.styleable.KeyboardView_colorScheme, COLOR_SCHEME_WHITE);
         a.recycle();
 
         final Resources res = getResources();
@@ -565,10 +559,6 @@
         return mShowKeyPreviewPopup;
     }
 
-    public int getColorScheme() {
-        return mColorScheme;
-    }
-
     /**
      * When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key
      * codes for adjacent keys.  When disabled, only the primary key code will be
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
index 7be738c..9916af5 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java
@@ -16,13 +16,17 @@
 
 package com.android.inputmethod.keyboard.internal;
 
+import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
+import android.util.Log;
 
 import com.android.inputmethod.keyboard.Keyboard;
 import com.android.inputmethod.latin.R;
 
 public class KeyboardIconsSet {
+    private static final String TAG = KeyboardIconsSet.class.getSimpleName();
+
     public static final int ICON_UNDEFINED = 0;
 
     // This should be aligned with Keyboard.keyIcon enum.
@@ -130,9 +134,13 @@
             final int attrIndex = keyboardAttrs.getIndex(i);
             final int iconId = getIconId(attrIndex);
             if (iconId != ICON_UNDEFINED) {
-                final Drawable icon = keyboardAttrs.getDrawable(attrIndex);
-                Keyboard.setDefaultBounds(icon);
-                mIcons[iconId] = icon;
+                try {
+                    final Drawable icon = keyboardAttrs.getDrawable(attrIndex);
+                    Keyboard.setDefaultBounds(icon);
+                    mIcons[iconId] = icon;
+                } catch (Resources.NotFoundException e) {
+                    Log.w(TAG, "Drawable resource for icon #" + iconId + " not found");
+                }
             }
         }
     }
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
index 9525b0e..78546f8 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java
@@ -90,14 +90,14 @@
  * You can declare Key style and specify styles within Key tags.
  * <pre>
  *     &gt;switch&lt;
- *       &gt;case colorScheme="white"&lt;
- *         &gt;key-style styleName="shift-key" parentStyle="modifier-key"
- *           keyIcon="@drawable/sym_keyboard_shift"
+ *       &gt;case mode="email"&lt;
+ *         &gt;key-style styleName="f1-key" parentStyle="modifier-key"
+ *           keyLabel=".com"
  *         /&lt;
  *       &gt;/case&lt;
- *       &gt;case colorScheme="black"&lt;
- *         &gt;key-style styleName="shift-key" parentStyle="modifier-key"
- *           keyIcon="@drawable/sym_bkeyboard_shift"
+ *       &gt;case mode="url"&lt;
+ *         &gt;key-style styleName="f1-key" parentStyle="modifier-key"
+ *           keyLabel="http://"
  *         /&lt;
  *       &gt;/case&lt;
  *     &gt;/switch&lt;
@@ -487,8 +487,6 @@
                     R.styleable.Keyboard_Case_voiceKeyEnabled, id.mVoiceKeyEnabled);
             final boolean voiceKeyMatched = matchBoolean(a,
                     R.styleable.Keyboard_Case_hasVoiceKey, id.mHasVoiceKey);
-            final boolean colorSchemeMatched = matchInteger(viewAttr,
-                    R.styleable.KeyboardView_colorScheme, id.mColorScheme);
             // As noted at {@link KeyboardId} class, we are interested only in enum value masked by
             // {@link android.view.inputmethod.EditorInfo#IME_MASK_ACTION} and
             // {@link android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION}. So matching
@@ -503,14 +501,11 @@
                     R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
             final boolean selected = modeMatched && navigateActionMatched && passwordInputMatched
                     && settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched
-                    && colorSchemeMatched && imeActionMatched && localeCodeMatched
-                    && languageCodeMatched && countryCodeMatched;
+                    && imeActionMatched && localeCodeMatched && languageCodeMatched
+                    && countryCodeMatched;
 
-            if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE,
+            if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE,
                     textAttr(a.getString(R.styleable.Keyboard_Case_mode), "mode"),
-                    textAttr(KeyboardId.colorSchemeName(
-                            viewAttr.getInt(
-                                    R.styleable.KeyboardView_colorScheme, -1)), "colorScheme"),
                     booleanAttr(a, R.styleable.Keyboard_Case_navigateAction, "navigateAction"),
                     booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"),
                     booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"),
diff --git a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java
index 28766c2..bb2a6fe 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java
@@ -16,15 +16,14 @@
 
 package com.android.inputmethod.latin;
 
-import com.android.inputmethod.keyboard.KeyboardId;
-import com.android.inputmethod.keyboard.KeyboardView;
-
 import android.content.res.AssetFileDescriptor;
 import android.content.res.Configuration;
 import android.test.AndroidTestCase;
 import android.text.TextUtils;
 import android.view.inputmethod.EditorInfo;
 
+import com.android.inputmethod.keyboard.KeyboardId;
+
 import java.io.File;
 import java.io.InputStream;
 import java.util.Locale;
@@ -41,8 +40,8 @@
     protected KeyboardId createKeyboardId(Locale locale) {
         final int displayWidth = getContext().getResources().getDisplayMetrics().widthPixels;
         return new KeyboardId(locale.toString() + " keyboard",
-                com.android.inputmethod.latin.R.xml.kbd_qwerty, KeyboardView.COLOR_SCHEME_WHITE,
-                locale, Configuration.ORIENTATION_LANDSCAPE, displayWidth, KeyboardId.MODE_TEXT,
+                com.android.inputmethod.latin.R.xml.kbd_qwerty, locale,
+                Configuration.ORIENTATION_LANDSCAPE, displayWidth, KeyboardId.MODE_TEXT,
                 new EditorInfo(), false, false, false, false);
     }