Support colorScheme <case/> condition in Keyboard XML

Change-Id: Ibbfb99e0e2b15df301f83af6739b7bca01ebf490
diff --git a/java/res/xml/kbd_functional_key_style.xml b/java/res/xml/kbd_functional_key_style.xml
deleted file mode 100644
index eabaa4a..0000000
--- a/java/res/xml/kbd_functional_key_style.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<merge
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
-    <key-style
-        latin:styleName="functionalKeyStyle"
-        latin:isModifier="true" />
-    <key-style
-        latin:styleName="shiftKeyStyle"
-        latin:codes="@integer/key_shift"
-        latin:keyIcon="@drawable/sym_keyboard_shift"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
-        latin:parentStyle="functionalKeyStyle"
-        latin:isSticky="true" />
-    <key-style
-        latin:styleName="deleteKeyStyle"
-        latin:codes="@integer/key_delete"
-        latin:keyIcon="@drawable/sym_keyboard_delete"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
-        latin:parentStyle="functionalKeyStyle"
-        latin:isRepeatable="true" />
-    <switch>
-        <!-- When this qwerty keyboard has no voice key but voice key is enabled, then symbol
-             keyboard will have mic key. That means we should use "?123mic" key here. -->
-        <case
-            latin:voiceKeyEnabled="true"
-            latin:hasVoiceKey="false"
-        >
-            <key-style
-                latin:styleName="toSymbolKeyStyle"
-                latin:codes="@integer/key_switch_alpha_symbol"
-                latin:keyIcon="@drawable/sym_keyboard_123_mic"
-                latin:iconPreview="@drawable/sym_keyboard_feedback_123_mic"
-                latin:parentStyle="functionalKeyStyle" />
-        </case>
-        <default>
-            <key-style
-                latin:styleName="toSymbolKeyStyle"
-                latin:codes="@integer/key_switch_alpha_symbol"
-                latin:keyLabel="@string/label_to_symbol_key"
-                latin:parentStyle="functionalKeyStyle" />
-        </default>
-    </switch>
-    <key-style
-        latin:styleName="toAlphaKeyStyle"
-        latin:codes="@integer/key_switch_alpha_symbol"
-        latin:keyLabel="@string/label_to_alpha_key"
-        latin:parentStyle="functionalKeyStyle" />
-    <key-style
-        latin:styleName="settingsKeyStyle"
-        latin:codes="@integer/key_settings"
-        latin:keyIcon="@drawable/sym_keyboard_settings"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-        latin:parentStyle="functionalKeyStyle" />
-    <key-style
-        latin:styleName="spaceKeyStyle"
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:parentStyle="functionalKeyStyle" />
-    <key-style
-        latin:styleName="tabKeyStyle"
-        latin:codes="@integer/key_tab"
-        latin:keyIcon="@drawable/sym_keyboard_tab"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
-        latin:parentStyle="functionalKeyStyle" />
-    <key-style
-        latin:styleName="returnKeyStyle"
-        latin:codes="@integer/key_return"
-        latin:keyIcon="@drawable/sym_keyboard_return"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-        latin:parentStyle="functionalKeyStyle" />
-    <key-style
-        latin:styleName="altKeyStyle"
-        latin:codes="@integer/key_shift"
-        latin:keyLabel="@string/label_alt_key"
-        latin:parentStyle="functionalKeyStyle"
-        latin:isSticky="true" />
-    <key-style
-        latin:styleName="smileyKeyStyle"
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys"
-        latin:parentStyle="functionalKeyStyle" />
-    <key-style
-        latin:styleName="micKeyStyle"
-        latin:codes="@integer/key_voice"
-        latin:popupKeyboard="@xml/popup_mic"
-        latin:keyIcon="@drawable/sym_keyboard_mic"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:parentStyle="functionalKeyStyle" />
-</merge>
diff --git a/java/res/xml/kbd_key_styles.xml b/java/res/xml/kbd_key_styles.xml
new file mode 100644
index 0000000..ec813d7
--- /dev/null
+++ b/java/res/xml/kbd_key_styles.xml
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2010, 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.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <switch>
+        <case
+            latin:colorScheme="white"
+        >
+            <key-style
+                latin:styleName="functionalKeyStyle"
+                latin:isModifier="true" />
+            <key-style
+                latin:styleName="shiftKeyStyle"
+                latin:codes="@integer/key_shift"
+                latin:keyIcon="@drawable/sym_keyboard_shift"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
+                latin:parentStyle="functionalKeyStyle"
+                latin:isSticky="true" />
+            <key-style
+                latin:styleName="deleteKeyStyle"
+                latin:codes="@integer/key_delete"
+                latin:keyIcon="@drawable/sym_keyboard_delete"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
+                latin:parentStyle="functionalKeyStyle"
+                latin:isRepeatable="true" />
+            <switch>
+                <!-- When this qwerty keyboard has no voice key but voice key is enabled, then
+                     symbol keyboard will have mic key. That means we should use "?123mic" key
+                     here. -->
+                <case
+                    latin:voiceKeyEnabled="true"
+                    latin:hasVoiceKey="false"
+                >
+                    <key-style
+                        latin:styleName="toSymbolKeyStyle"
+                        latin:codes="@integer/key_switch_alpha_symbol"
+                        latin:keyIcon="@drawable/sym_keyboard_123_mic"
+                        latin:iconPreview="@drawable/sym_keyboard_feedback_123_mic"
+                        latin:parentStyle="functionalKeyStyle" />
+                </case>
+                <default>
+                    <key-style
+                        latin:styleName="toSymbolKeyStyle"
+                        latin:codes="@integer/key_switch_alpha_symbol"
+                        latin:keyLabel="@string/label_to_symbol_key"
+                        latin:parentStyle="functionalKeyStyle" />
+                </default>
+            </switch>
+            <key-style
+                latin:styleName="settingsKeyStyle"
+                latin:codes="@integer/key_settings"
+                latin:keyIcon="@drawable/sym_keyboard_settings"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
+                latin:parentStyle="functionalKeyStyle" />
+            <key-style
+                latin:styleName="spaceKeyStyle"
+                latin:codes="@integer/key_space"
+                latin:keyIcon="@drawable/sym_keyboard_space"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                latin:parentStyle="functionalKeyStyle" />
+            <key-style
+                latin:styleName="tabKeyStyle"
+                latin:codes="@integer/key_tab"
+                latin:keyIcon="@drawable/sym_keyboard_tab"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
+                latin:parentStyle="functionalKeyStyle" />
+            <key-style
+                latin:styleName="returnKeyStyle"
+                latin:codes="@integer/key_return"
+                latin:keyIcon="@drawable/sym_keyboard_return"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+                latin:parentStyle="functionalKeyStyle" />
+            <key-style
+                latin:styleName="micKeyStyle"
+                latin:codes="@integer/key_voice"
+                latin:popupKeyboard="@xml/popup_mic"
+                latin:keyIcon="@drawable/sym_keyboard_mic"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
+                latin:keyHintIcon="@drawable/hint_popup"
+                latin:parentStyle="functionalKeyStyle" />
+            <!-- Note: This key style is not for functional tab key. This is used for the tab key
+                 which is laid out as normal letter key. -->
+            <key-style
+                latin:styleName="nonSpecialBackgroundTabKeyStyle"
+                latin:codes="@integer/key_tab"
+                latin:keyIcon="@drawable/sym_keyboard_tab"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_tab" />
+        </case>
+        <case
+            latin:colorScheme="black"
+        >
+            <key-style
+                latin:styleName="functionalKeyStyle" />
+            <key-style
+                latin:styleName="shiftKeyStyle"
+                latin:codes="@integer/key_shift"
+                latin:keyIcon="@drawable/sym_bkeyboard_shift"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
+                latin:parentStyle="functionalKeyStyle"
+                latin:isSticky="true" />
+            <key-style
+                latin:styleName="deleteKeyStyle"
+                latin:codes="@integer/key_delete"
+                latin:keyIcon="@drawable/sym_bkeyboard_delete"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
+                latin:parentStyle="functionalKeyStyle"
+                latin:isRepeatable="true" />
+            <switch>
+                <!-- When this qwerty keyboard has no voice key but voice key is enabled, then
+                     symbol keyboard will have mic key. That means we should use "?123mic" key
+                     here. -->
+                <case
+                    latin:voiceKeyEnabled="true"
+                    latin:hasVoiceKey="false"
+                >
+                    <key-style
+                        latin:styleName="toSymbolKeyStyle"
+                        latin:codes="@integer/key_switch_alpha_symbol"
+                        latin:keyIcon="@drawable/sym_bkeyboard_123_mic"
+                        latin:iconPreview="@drawable/sym_keyboard_feedback_123_mic"
+                        latin:parentStyle="functionalKeyStyle" />
+                </case>
+                <default>
+                    <key-style
+                        latin:styleName="toSymbolKeyStyle"
+                        latin:codes="@integer/key_switch_alpha_symbol"
+                        latin:keyLabel="@string/label_to_symbol_key"
+                        latin:parentStyle="functionalKeyStyle" />
+                </default>
+            </switch>
+            <key-style
+                latin:styleName="settingsKeyStyle"
+                latin:codes="@integer/key_settings"
+                latin:keyIcon="@drawable/sym_bkeyboard_settings"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
+                latin:parentStyle="functionalKeyStyle" />
+            <key-style
+                latin:styleName="spaceKeyStyle"
+                latin:codes="@integer/key_space"
+                latin:keyIcon="@drawable/sym_bkeyboard_space"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                latin:parentStyle="functionalKeyStyle" />
+            <key-style
+                latin:styleName="tabKeyStyle"
+                latin:codes="@integer/key_tab"
+                latin:keyIcon="@drawable/sym_bkeyboard_tab"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
+                latin:parentStyle="functionalKeyStyle" />
+            <key-style
+                latin:styleName="returnKeyStyle"
+                latin:codes="@integer/key_return"
+                latin:keyIcon="@drawable/sym_bkeyboard_return"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+                latin:parentStyle="functionalKeyStyle" />
+            <key-style
+                latin:styleName="micKeyStyle"
+                latin:codes="@integer/key_voice"
+                latin:popupKeyboard="@xml/popup_mic"
+                latin:keyIcon="@drawable/sym_bkeyboard_mic"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
+                latin:keyHintIcon="@drawable/hint_popup"
+                latin:parentStyle="functionalKeyStyle" />
+            <!-- Note: This key style is not for functional tab key. This is used for the tab key
+                 which is laid out as normal letter key. -->
+            <key-style
+                latin:styleName="nonSpecialBackgroundTabKeyStyle"
+                latin:codes="@integer/key_tab"
+                latin:keyIcon="@drawable/sym_bkeyboard_tab"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_tab" />
+        </case>
+    </switch>
+    <key-style
+        latin:styleName="toAlphaKeyStyle"
+        latin:codes="@integer/key_switch_alpha_symbol"
+        latin:keyLabel="@string/label_to_alpha_key"
+        latin:parentStyle="functionalKeyStyle" />
+    <key-style
+        latin:styleName="altKeyStyle"
+        latin:codes="@integer/key_shift"
+        latin:keyLabel="@string/label_alt_key"
+        latin:parentStyle="functionalKeyStyle"
+        latin:isSticky="true" />
+    <key-style
+        latin:styleName="smileyKeyStyle"
+        latin:keyLabel=":-)"
+        latin:keyOutputText=":-) "
+        latin:keyHintIcon="@drawable/hint_popup"
+        latin:popupKeyboard="@xml/popup_smileys"
+        latin:parentStyle="functionalKeyStyle" />
+</merge>
\ No newline at end of file
diff --git a/java/res/xml/kbd_phone.xml b/java/res/xml/kbd_phone.xml
index a01d697..c9b1ad6 100644
--- a/java/res/xml/kbd_phone.xml
+++ b/java/res/xml/kbd_phone.xml
@@ -26,20 +26,127 @@
     latin:keyHeight="@dimen/key_height"
 >
     <include
-        latin:keyboardLayout="@xml/kbd_functional_key_style" />
+        latin:keyboardLayout="@xml/kbd_key_styles" />
+    <switch>
+        <case
+            latin:colorScheme="white"
+        >
+            <key-style
+                latin:styleName="num0KeyStyle"
+                latin:codes="48"
+                latin:keyIcon="@drawable/sym_keyboard_num0" />
+            <key-style
+                latin:styleName="num1KeyStyle"
+                latin:codes="49"
+                latin:keyIcon="@drawable/sym_keyboard_num1" />
+            <key-style
+                latin:styleName="num2KeyStyle"
+                latin:codes="50"
+                latin:keyIcon="@drawable/sym_keyboard_num2" />
+            <key-style
+                latin:styleName="num3KeyStyle"
+                latin:codes="51"
+                latin:keyIcon="@drawable/sym_keyboard_num3" />
+            <key-style
+                latin:styleName="num4KeyStyle"
+                latin:codes="52"
+                latin:keyIcon="@drawable/sym_keyboard_num4" />
+            <key-style
+                latin:styleName="num5KeyStyle"
+                latin:codes="53"
+                latin:keyIcon="@drawable/sym_keyboard_num5" />
+            <key-style
+                latin:styleName="num6KeyStyle"
+                latin:codes="54"
+                latin:keyIcon="@drawable/sym_keyboard_num6" />
+            <key-style
+                latin:styleName="num7KeyStyle"
+                latin:codes="55"
+                latin:keyIcon="@drawable/sym_keyboard_num7" />
+            <key-style
+                latin:styleName="num8KeyStyle"
+                latin:codes="56"
+                latin:keyIcon="@drawable/sym_keyboard_num8" />
+            <key-style
+                latin:styleName="num9KeyStyle"
+                latin:codes="57"
+                latin:keyIcon="@drawable/sym_keyboard_num9" />
+            <key-style
+                latin:styleName="numAltKeyStyle"
+                latin:codes="@integer/key_switch_alpha_symbol"
+                latin:keyIcon="@drawable/sym_keyboard_numalt"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_numalt" />
+            <key-style
+                latin:styleName="numSpaceKeyStyle"
+                latin:codes="@integer/key_space"
+                latin:keyIcon="@drawable/sym_keyboard_space"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
+        </case>
+        <case
+            latin:colorScheme="black"
+        >
+            <key-style
+                latin:styleName="num0KeyStyle"
+                latin:codes="48"
+                latin:keyIcon="@drawable/sym_bkeyboard_num0" />
+            <key-style
+                latin:styleName="num1KeyStyle"
+                latin:codes="49"
+                latin:keyIcon="@drawable/sym_bkeyboard_num1" />
+            <key-style
+                latin:styleName="num2KeyStyle"
+                latin:codes="50"
+                latin:keyIcon="@drawable/sym_bkeyboard_num2" />
+            <key-style
+                latin:styleName="num3KeyStyle"
+                latin:codes="51"
+                latin:keyIcon="@drawable/sym_bkeyboard_num3" />
+            <key-style
+                latin:styleName="num4KeyStyle"
+                latin:codes="52"
+                latin:keyIcon="@drawable/sym_bkeyboard_num4" />
+            <key-style
+                latin:styleName="num5KeyStyle"
+                latin:codes="53"
+                latin:keyIcon="@drawable/sym_bkeyboard_num5" />
+            <key-style
+                latin:styleName="num6KeyStyle"
+                latin:codes="54"
+                latin:keyIcon="@drawable/sym_bkeyboard_num6" />
+            <key-style
+                latin:styleName="num7KeyStyle"
+                latin:codes="55"
+                latin:keyIcon="@drawable/sym_bkeyboard_num7" />
+            <key-style
+                latin:styleName="num8KeyStyle"
+                latin:codes="56"
+                latin:keyIcon="@drawable/sym_bkeyboard_num8" />
+            <key-style
+                latin:styleName="num9KeyStyle"
+                latin:codes="57"
+                latin:keyIcon="@drawable/sym_bkeyboard_num9" />
+            <key-style
+                latin:styleName="numAltKeyStyle"
+                latin:codes="@integer/key_switch_alpha_symbol"
+                latin:keyIcon="@drawable/sym_bkeyboard_numalt"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_numalt" />
+            <key-style
+                latin:styleName="numSpaceKeyStyle"
+                latin:codes="@integer/key_space"
+                latin:keyIcon="@drawable/sym_bkeyboard_space"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
+        </case>
+    </switch>
     <Row
         latin:rowEdgeFlags="top"
     >
         <Key
-            latin:codes="49"
-            latin:keyIcon="@drawable/sym_keyboard_num1"
+            latin:keyStyle="num1KeyStyle"
             latin:keyEdgeFlags="left" />
         <Key
-            latin:codes="50"
-            latin:keyIcon="@drawable/sym_keyboard_num2" />
+            latin:keyStyle="num2KeyStyle" />
         <Key
-            latin:codes="51"
-            latin:keyIcon="@drawable/sym_keyboard_num3" />
+            latin:keyStyle="num3KeyStyle" />
         <Key
             latin:keyLabel="-"
             latin:keyStyle="functionalKeyStyle"
@@ -48,15 +155,12 @@
     </Row>
     <Row>
         <Key
-            latin:codes="52"
-            latin:keyIcon="@drawable/sym_keyboard_num4"
+            latin:keyStyle="num4KeyStyle"
             latin:keyEdgeFlags="left" />
         <Key
-            latin:codes="53"
-            latin:keyIcon="@drawable/sym_keyboard_num5" />
+            latin:keyStyle="num5KeyStyle" />
         <Key
-            latin:codes="54"
-            latin:keyIcon="@drawable/sym_keyboard_num6" />
+            latin:keyStyle="num6KeyStyle" />
         <Key
             latin:keyLabel="."
             latin:keyStyle="functionalKeyStyle"
@@ -65,15 +169,12 @@
     </Row>
     <Row>
         <Key
-            latin:codes="55"
-            latin:keyIcon="@drawable/sym_keyboard_num7"
+            latin:keyStyle="num7KeyStyle"
             latin:keyEdgeFlags="left" />
         <Key
-            latin:codes="56"
-            latin:keyIcon="@drawable/sym_keyboard_num8" />
+            latin:keyStyle="num8KeyStyle" />
         <Key
-            latin:codes="57"
-            latin:keyIcon="@drawable/sym_keyboard_num9" />
+            latin:keyStyle="num9KeyStyle" />
         <Key
             latin:keyStyle="deleteKeyStyle"
             latin:keyWidth="20%p"
@@ -83,17 +184,12 @@
         latin:rowEdgeFlags="bottom"
     >
         <Key
-            latin:codes="@integer/key_switch_alpha_symbol"
-            latin:keyIcon="@drawable/sym_keyboard_numalt"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_numalt"
+            latin:keyStyle="numAltKeyStyle"
             latin:keyEdgeFlags="left" />
         <Key
-            latin:codes="48"
-            latin:keyIcon="@drawable/sym_keyboard_num0" />
+            latin:keyStyle="num0KeyStyle" />
         <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
+            latin:keyStyle="numSpaceKeyStyle" />
         <Key
             latin:keyStyle="returnKeyStyle"
             latin:keyWidth="20%p"
diff --git a/java/res/xml/kbd_phone_black.xml b/java/res/xml/kbd_phone_black.xml
deleted file mode 100644
index 75ce34a..0000000
--- a/java/res/xml/kbd_phone_black.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<Keyboard
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:keyWidth="26.67%p"
-    latin:horizontalGap="@dimen/key_horizontal_gap"
-    latin:verticalGap="@dimen/key_bottom_gap"
-    latin:keyHeight="@dimen/key_height"
->
-    <Row
-        latin:rowEdgeFlags="top"
-    >
-        <Key
-            latin:codes="49"
-            latin:keyIcon="@drawable/sym_bkeyboard_num1"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="50"
-            latin:keyIcon="@drawable/sym_bkeyboard_num2" />
-        <Key
-            latin:codes="51"
-            latin:keyIcon="@drawable/sym_bkeyboard_num3" />
-        <Key
-            latin:keyLabel="-"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Key
-            latin:codes="52"
-            latin:keyIcon="@drawable/sym_bkeyboard_num4"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="53"
-            latin:keyIcon="@drawable/sym_bkeyboard_num5" />
-        <Key
-            latin:codes="54"
-            latin:keyIcon="@drawable/sym_bkeyboard_num6" />
-        <Key
-            latin:keyLabel="."
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Key
-            latin:codes="55"
-            latin:keyIcon="@drawable/sym_bkeyboard_num7"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="56"
-            latin:keyIcon="@drawable/sym_bkeyboard_num8" />
-        <Key
-            latin:codes="57"
-            latin:keyIcon="@drawable/sym_bkeyboard_num9" />
-        <Key
-            latin:codes="@integer/key_delete"
-            latin:keyIcon="@drawable/sym_bkeyboard_delete"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
-            latin:keyWidth="20%p"
-            latin:isRepeatable="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_switch_alpha_symbol"
-            latin:keyIcon="@drawable/sym_bkeyboard_numalt"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_numalt" />
-        <Key
-            latin:codes="48"
-            latin:keyIcon="@drawable/sym_bkeyboard_num0" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_bkeyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_bkeyboard_return"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="right" />
-    </Row>
-</Keyboard>
diff --git a/java/res/xml/kbd_phone_symbols.xml b/java/res/xml/kbd_phone_symbols.xml
index d53107a..0d6d0e4 100644
--- a/java/res/xml/kbd_phone_symbols.xml
+++ b/java/res/xml/kbd_phone_symbols.xml
@@ -25,7 +25,46 @@
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:keyHeight="@dimen/key_height"
 >
-    <include latin:keyboardLayout="@xml/kbd_functional_key_style" />
+    <include
+        latin:keyboardLayout="@xml/kbd_key_styles" />
+    <switch>
+        <case
+            latin:colorScheme="white"
+        >
+            <key-style
+                latin:styleName="numStarKeyStyle"
+                latin:codes="42"
+                latin:keyIcon="@drawable/sym_keyboard_numstar"
+                latin:keyEdgeFlags="left" />
+            <key-style
+                latin:styleName="numPoundKeyStyle"
+                latin:codes="35"
+                latin:keyIcon="@drawable/sym_keyboard_numpound" />
+            <key-style
+                latin:styleName="numSpaceKeyStyle"
+                latin:codes="@integer/key_space"
+                latin:keyIcon="@drawable/sym_keyboard_space"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
+        </case>
+        <case
+            latin:colorScheme="black"
+        >
+            <key-style
+                latin:styleName="numStarKeyStyle"
+                latin:codes="42"
+                latin:keyIcon="@drawable/sym_bkeyboard_numstar"
+                latin:keyEdgeFlags="left" />
+            <key-style
+                latin:styleName="numPoundKeyStyle"
+                latin:codes="35"
+                latin:keyIcon="@drawable/sym_bkeyboard_numpound" />
+            <key-style
+                latin:styleName="numSpaceKeyStyle"
+                latin:codes="@integer/key_space"
+                latin:keyIcon="@drawable/sym_bkeyboard_space"
+                latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
+        </case>
+    </switch>
     <Row
         latin:rowEdgeFlags="top"
     >
@@ -61,16 +100,14 @@
     </Row>
     <Row>
         <Key
-            latin:codes="42"
-            latin:keyIcon="@drawable/sym_keyboard_numstar"
+            latin:keyStyle="numStarKeyStyle"
             latin:keyEdgeFlags="left" />
         <!-- Wait is a semicolon. -->
         <Key
             latin:codes="59"
             latin:keyLabel="Wait" />
         <Key
-            latin:codes="35"
-            latin:keyIcon="@drawable/sym_keyboard_numpound" />
+            latin:keyStyle="numPoundKeyStyle" />
         <Key
             latin:keyStyle="deleteKeyStyle"
             latin:keyWidth="20%p"
@@ -86,9 +123,7 @@
         <Key
             latin:keyLabel="+" />
         <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
+            latin:keyStyle="numSpaceKeyStyle" />
         <Key
             latin:keyStyle="returnKeyStyle"
             latin:keyWidth="20%p"
diff --git a/java/res/xml/kbd_phone_symbols_black.xml b/java/res/xml/kbd_phone_symbols_black.xml
deleted file mode 100644
index 06db969..0000000
--- a/java/res/xml/kbd_phone_symbols_black.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<Keyboard
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:keyWidth="26.67%p"
-    latin:horizontalGap="@dimen/key_horizontal_gap"
-    latin:verticalGap="@dimen/key_bottom_gap"
-    latin:keyHeight="@dimen/key_height"
->
-    <Row
-        latin:rowEdgeFlags="top"
-    >
-        <Key
-            latin:keyLabel="("
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="/" />
-        <Key
-            latin:keyLabel=")" />
-        <Key
-            latin:keyLabel="-"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Key
-            latin:keyLabel="N"
-            latin:keyEdgeFlags="left" />
-        <!-- Pause is a comma. Check PhoneNumberUtils.java to see if this 
-            has changed. -->
-        <Key
-            latin:codes="44"
-            latin:keyLabel="Pause" />
-        <Key
-            latin:keyLabel="," />
-        <Key
-            latin:keyLabel="."
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Key
-            latin:codes="42"
-            latin:keyIcon="@drawable/sym_bkeyboard_numstar"
-            latin:keyEdgeFlags="left" />
-        <!-- Wait is a semicolon. -->
-        <Key
-            latin:codes="59"
-            latin:keyLabel="Wait" />
-        <Key
-            latin:codes="35"
-            latin:keyIcon="@drawable/sym_bkeyboard_numpound" />
-        <Key
-            latin:codes="@integer/key_delete"
-            latin:keyIcon="@drawable/sym_bkeyboard_delete"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
-            latin:keyWidth="20%p"
-            latin:isRepeatable="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_switch_alpha_symbol"
-            latin:keyLabel="@string/label_phone_key"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="+" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_bkeyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_bkeyboard_return"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="right" />
-    </Row>
-</Keyboard>
diff --git a/java/res/xml/kbd_qwerty.xml b/java/res/xml/kbd_qwerty.xml
index aac4dfa..b75f533 100644
--- a/java/res/xml/kbd_qwerty.xml
+++ b/java/res/xml/kbd_qwerty.xml
@@ -26,7 +26,7 @@
     latin:keyHeight="@dimen/key_height"
 >
     <include
-        latin:keyboardLayout="@xml/kbd_functional_key_style" />
+        latin:keyboardLayout="@xml/kbd_key_styles" />
     <Row
         latin:rowEdgeFlags="top"
     >
diff --git a/java/res/xml/kbd_qwerty_black.xml b/java/res/xml/kbd_qwerty_black.xml
deleted file mode 100644
index 76412f6..0000000
--- a/java/res/xml/kbd_qwerty_black.xml
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2008, 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.
-*/
--->
-
-<Keyboard
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:keyWidth="10%p"
-    latin:horizontalGap="@dimen/key_horizontal_gap"
-    latin:verticalGap="@dimen/key_bottom_gap"
-    latin:keyHeight="@dimen/key_height"
->
-    <Row
-        latin:rowEdgeFlags="top"
-    >
-        <Key
-            latin:keyLabel="q"
-            latin:keyHintIcon="@drawable/keyboard_hint_1"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_q"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="w"
-            latin:keyHintIcon="@drawable/keyboard_hint_2"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_w" />
-        <Key
-            latin:keyLabel="e"
-            latin:keyHintIcon="@drawable/keyboard_hint_3"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_e" />
-        <Key
-            latin:keyLabel="r"
-            latin:keyHintIcon="@drawable/keyboard_hint_4"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_r" />
-        <Key
-            latin:keyLabel="t"
-            latin:keyHintIcon="@drawable/keyboard_hint_5"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_t" />
-        <Key
-            latin:keyLabel="y"
-            latin:keyHintIcon="@drawable/keyboard_hint_6"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_y" />
-        <Key
-            latin:keyLabel="u"
-            latin:keyHintIcon="@drawable/keyboard_hint_7"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_u" />
-        <Key
-            latin:keyLabel="i"
-            latin:keyHintIcon="@drawable/keyboard_hint_8"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_i" />
-        <Key
-            latin:keyLabel="o"
-            latin:keyHintIcon="@drawable/keyboard_hint_9"
-            latin:popupKeyboard="@xml/kbd_popup_narrow_template"
-            latin:popupCharacters="@string/alternates_for_o" />
-        <Key
-            latin:keyLabel="p"
-            latin:keyHintIcon="@drawable/keyboard_hint_0"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_p"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Spacer
-            latin:horizontalGap="5%p" />
-        <Key
-            latin:keyLabel="a"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_a"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="s"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_s" />
-        <Key
-            latin:keyLabel="d"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_d" />
-        <Key
-            latin:keyLabel="f" />
-        <Key
-            latin:keyLabel="g"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_g" />
-        <Key
-            latin:keyLabel="h" />
-        <Key
-            latin:keyLabel="j" />
-        <Key
-            latin:keyLabel="k" />
-        <Key
-            latin:keyLabel="l"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_l"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Key
-            latin:codes="@integer/key_shift"
-            latin:keyIcon="@drawable/sym_bkeyboard_shift"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
-            latin:keyWidth="15%p"
-            latin:isModifier="true"
-            latin:isSticky="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="z"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_z" />
-        <Key
-            latin:keyLabel="x" />
-        <Key
-            latin:keyLabel="c"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_c" />
-        <Key
-            latin:keyLabel="v"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_v" />
-        <Key
-            latin:keyLabel="b" />
-        <Key
-            latin:keyLabel="n"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="@string/alternates_for_n" />
-        <Key
-            latin:keyLabel="m" />
-        <Key
-            latin:codes="@integer/key_delete"
-            latin:keyIcon="@drawable/sym_bkeyboard_delete"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
-            latin:keyWidth="15%p"
-            latin:isRepeatable="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <include latin:keyboardLayout="@xml/kbd_qwerty_black_row4" />
-</Keyboard>
diff --git a/java/res/xml/kbd_qwerty_black_f1.xml b/java/res/xml/kbd_qwerty_black_f1.xml
deleted file mode 100644
index 296d8a0..0000000
--- a/java/res/xml/kbd_qwerty_black_f1.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<merge
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
-    <switch>
-        <case
-            latin:mode="url"
-        >
-            <Key
-                latin:keyLabel="/"
-                latin:popupKeyboard="@xml/popup_slash"
-                latin:keyHintIcon="@drawable/hint_popup"
-                latin:isModifier="true" />
-        </case>
-        <case
-            latin:mode="email"
-        >
-            <Key
-                latin:keyLabel="\@"
-                latin:popupKeyboard="@xml/popup_at"
-                latin:keyHintIcon="@drawable/hint_popup"
-                latin:isModifier="true" />
-        </case>
-        <case
-            latin:hasVoiceKey="true"
-        >
-            <Key
-                latin:codes="@integer/key_voice"
-                latin:popupKeyboard="@xml/popup_mic"
-                latin:keyIcon="@drawable/sym_bkeyboard_mic"
-                latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
-                latin:keyHintIcon="@drawable/hint_popup"
-                latin:isModifier="true" />
-        </case>
-        <default>
-            <Key
-                latin:keyLabel=","
-                latin:popupKeyboard="@xml/popup_comma"
-                latin:keyHintIcon="@drawable/hint_popup"
-                latin:isModifier="true" />
-        </default>
-    </switch>
-</merge>
diff --git a/java/res/xml/kbd_qwerty_black_row4.xml b/java/res/xml/kbd_qwerty_black_row4.xml
deleted file mode 100644
index c6e25b4..0000000
--- a/java/res/xml/kbd_qwerty_black_row4.xml
+++ /dev/null
@@ -1,156 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<merge
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
-    <Row
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <switch>
-            <case
-                latin:hasSettingsKey="false"
-            >
-                <include
-                    latin:keyboardLayout="@xml/kbd_qwerty_black_symbol" />
-                <include
-                    latin:keyboardLayout="@xml/kbd_qwerty_black_f1" />
-                <switch>
-                    <case
-                        latin:mode="web"
-                    >
-                        <Key
-                            latin:codes="@integer/key_space"
-                            latin:keyIcon="@drawable/sym_bkeyboard_space"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-                            latin:keyWidth="20%p" />
-                        <Key
-                            latin:codes="@integer/key_tab"
-                            latin:keyIcon="@drawable/sym_bkeyboard_tab"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
-                            latin:keyWidth="20%p" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:codes="@integer/key_space"
-                            latin:keyIcon="@drawable/sym_bkeyboard_space"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-                            latin:keyWidth="40%p" />
-                    </default>
-                </switch>
-                <Key
-                    latin:keyLabel="."
-                    latin:keyHintIcon="@drawable/hint_popup"
-                    latin:popupKeyboard="@xml/popup_punctuation" />
-                <switch>
-                    <case
-                        latin:mode="im"
-                    >
-                        <Key
-                            latin:keyLabel=":-)"
-                            latin:keyOutputText=":-) "
-                            latin:keyHintIcon="@drawable/hint_popup"
-                            latin:popupKeyboard="@xml/popup_smileys"
-                            latin:keyWidth="20%p"
-                            latin:keyEdgeFlags="right" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:codes="@integer/key_return"
-                            latin:keyIcon="@drawable/sym_bkeyboard_return"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-                            latin:keyWidth="20%p"
-                            latin:keyEdgeFlags="right" />
-                    </default>
-                </switch>
-            </case>
-            <case
-                latin:hasSettingsKey="true"
-            >
-                <include
-                    latin:keyboardLayout="@xml/kbd_qwerty_black_symbol" />
-                <Key
-                    latin:codes="@integer/key_settings"
-                    latin:keyIcon="@drawable/sym_bkeyboard_settings"
-                    latin:iconPreview="@drawable/sym_keyboard_feedback_settings" />
-                <include
-                    latin:keyboardLayout="@xml/kbd_qwerty_black_f1" />
-                <switch>
-                    <case
-                        latin:mode="web"
-                    >
-                        <Key
-                            latin:codes="@integer/key_space"
-                            latin:keyIcon="@drawable/sym_bkeyboard_space"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-                            latin:keyWidth="30%p" />
-                        <Key
-                            latin:codes="@integer/key_tab"
-                            latin:keyIcon="@drawable/sym_bkeyboard_tab"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_tab" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:codes="@integer/key_space"
-                            latin:keyIcon="@drawable/sym_bkeyboard_space"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-                            latin:keyWidth="30%p" />
-                    </default>
-                </switch>
-                <Key
-                    latin:keyLabel="."
-                    latin:keyHintIcon="@drawable/hint_popup"
-                    latin:popupKeyboard="@xml/popup_punctuation" />
-                <switch>
-                    <case
-                        latin:mode="im"
-                    >
-                        <Key
-                            latin:keyLabel=":-)"
-                            latin:keyOutputText=":-) "
-                            latin:keyHintIcon="@drawable/hint_popup"
-                            latin:popupKeyboard="@xml/popup_smileys"
-                            latin:keyWidth="25%p"
-                            latin:keyEdgeFlags="right" />
-                    </case>
-                    <case
-                        latin:mode="web"
-                    >
-                        <Key
-                            latin:codes="@integer/key_return"
-                            latin:keyIcon="@drawable/sym_bkeyboard_return"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-                            latin:keyWidth="15%p"
-                            latin:keyEdgeFlags="right" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:codes="@integer/key_return"
-                            latin:keyIcon="@drawable/sym_bkeyboard_return"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-                            latin:keyWidth="25%p"
-                            latin:keyEdgeFlags="right" />
-                    </default>
-                </switch>
-            </case>
-        </switch>
-    </Row>
-</merge>
diff --git a/java/res/xml/kbd_symbols.xml b/java/res/xml/kbd_symbols.xml
index e9df816..7264179 100644
--- a/java/res/xml/kbd_symbols.xml
+++ b/java/res/xml/kbd_symbols.xml
@@ -26,7 +26,7 @@
     latin:keyHeight="@dimen/key_height"
 >
     <include
-        latin:keyboardLayout="@xml/kbd_functional_key_style" />
+        latin:keyboardLayout="@xml/kbd_key_styles" />
     <Row
         latin:rowEdgeFlags="top"
     >
diff --git a/java/res/xml/kbd_symbols_black.xml b/java/res/xml/kbd_symbols_black.xml
deleted file mode 100644
index ea021fb..0000000
--- a/java/res/xml/kbd_symbols_black.xml
+++ /dev/null
@@ -1,145 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<Keyboard
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:keyWidth="10%p"
-    latin:horizontalGap="@dimen/key_horizontal_gap"
-    latin:verticalGap="@dimen/key_bottom_gap"
-    latin:keyHeight="@dimen/key_height"
->
-    <Row
-        latin:rowEdgeFlags="top"
-    >
-        <Key
-            latin:keyLabel="1"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="¹½⅓¼⅛"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="2"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="²⅔" />
-        <Key
-            latin:keyLabel="3"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="³¾⅜" />
-        <Key
-            latin:keyLabel="4"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="⁴" />
-        <Key
-            latin:keyLabel="5"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="⅝" />
-        <Key
-            latin:keyLabel="6" />
-        <Key
-            latin:keyLabel="7"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="⅞" />
-        <Key
-            latin:keyLabel="8" />
-        <Key
-            latin:keyLabel="9" />
-        <Key
-            latin:keyLabel="0"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="ⁿ∅"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Key
-            latin:keyLabel="\@"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="\#" />
-        <Key
-            latin:keyLabel="$"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="¢£€¥₣₤₱" />
-        <Key
-            latin:keyLabel="%"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="‰" />
-        <Key
-            latin:keyLabel="&amp;" />
-        <Key
-            latin:keyLabel="*"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="†‡★" />
-        <Key
-            latin:keyLabel="-"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="_–—" />
-        <Key
-            latin:keyLabel="+"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="±" />
-        <Key
-            latin:keyLabel="("
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="[{&lt;" />
-        <Key
-            latin:keyLabel=")"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="]}&gt;"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Key
-            latin:codes="@integer/key_shift"
-            latin:keyLabel="@string/label_alt_key"
-            latin:keyWidth="15%p"
-            latin:isModifier="true"
-            latin:isSticky="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="!"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="¡" />
-        <Key
-            latin:keyLabel="&quot;"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="“”«»˝" />
-        <Key
-            latin:keyLabel="\'"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="‘’" />
-        <Key
-            latin:keyLabel=":" />
-        <Key
-            latin:keyLabel=";" />
-        <Key
-            latin:keyLabel="/" />
-        <Key
-            latin:keyLabel="\?"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="¿" />
-        <Key
-            latin:codes="@integer/key_delete"
-            latin:keyIcon="@drawable/sym_bkeyboard_delete"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
-            latin:keyWidth="15%p"
-            latin:isRepeatable="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <include latin:keyboardLayout="@xml/kbd_symbols_black_row4" />
-</Keyboard>
diff --git a/java/res/xml/kbd_symbols_black_f1.xml b/java/res/xml/kbd_symbols_black_f1.xml
deleted file mode 100644
index 353b007..0000000
--- a/java/res/xml/kbd_symbols_black_f1.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<merge
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
-    <switch>
-        <case
-            latin:hasVoiceKey="true"
-        >
-            <Key
-                latin:codes="@integer/key_voice"
-                latin:popupKeyboard="@xml/popup_mic"
-                latin:keyIcon="@drawable/sym_bkeyboard_mic"
-                latin:iconPreview="@drawable/sym_keyboard_feedback_mic"
-                latin:keyHintIcon="@drawable/hint_popup"
-                latin:isModifier="true" />
-        </case>
-        <case
-            latin:hasVoiceKey="false"
-        >
-            <Key
-                latin:keyLabel=","
-                latin:popupKeyboard="@xml/popup_comma"
-                latin:keyHintIcon="@drawable/hint_popup"
-                latin:isModifier="true" />
-        </case>
-    </switch>
-</merge>
diff --git a/java/res/xml/kbd_symbols_black_row4.xml b/java/res/xml/kbd_symbols_black_row4.xml
deleted file mode 100644
index 57f491b..0000000
--- a/java/res/xml/kbd_symbols_black_row4.xml
+++ /dev/null
@@ -1,116 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<merge
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
-    <Row
-        latin:rowEdgeFlags="bottom"
-    >
-        <switch>
-            <case
-                latin:hasSettingsKey="false"
-            >
-                <Key
-                    latin:codes="@integer/key_switch_alpha_symbol"
-                    latin:keyLabel="@string/label_to_alpha_key"
-                    latin:keyWidth="20%p"
-                    latin:keyEdgeFlags="left" />
-                <include
-                    latin:keyboardLayout="@xml/kbd_symbols_black_f1" />
-                <Key
-                    latin:codes="@integer/key_space"
-                    latin:keyIcon="@drawable/sym_bkeyboard_space"
-                    latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-                    latin:keyWidth="40%p" />
-                <Key
-                    latin:keyLabel="."
-                    latin:keyHintIcon="@drawable/hint_popup"
-                    latin:popupKeyboard="@xml/popup_punctuation" />
-                <switch>
-                    <case
-                        latin:mode="im"
-                    >
-                        <Key
-                            latin:keyLabel=":-)"
-                            latin:keyOutputText=":-) "
-                            latin:keyHintIcon="@drawable/hint_popup"
-                            latin:popupKeyboard="@xml/popup_smileys"
-                            latin:keyWidth="20%p"
-                            latin:keyEdgeFlags="right" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:codes="@integer/key_return"
-                            latin:keyIcon="@drawable/sym_bkeyboard_return"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-                            latin:keyWidth="20%p"
-                            latin:keyEdgeFlags="right" />
-                    </default>
-                </switch>
-            </case>
-            <case
-                latin:hasSettingsKey="true"
-            >
-                <Key
-                    latin:codes="@integer/key_switch_alpha_symbol"
-                    latin:keyLabel="@string/label_to_alpha_key"
-                    latin:keyWidth="15%p"
-                    latin:keyEdgeFlags="left" />
-                <Key
-                    latin:codes="@integer/key_settings"
-                    latin:keyIcon="@drawable/sym_bkeyboard_settings"
-                    latin:iconPreview="@drawable/sym_keyboard_feedback_settings" />
-                <include
-                    latin:keyboardLayout="@xml/kbd_symbols_black_f1" />
-                <Key
-                    latin:codes="@integer/key_space"
-                    latin:keyIcon="@drawable/sym_bkeyboard_space"
-                    latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-                    latin:keyWidth="30%p" />
-                <Key
-                    latin:keyLabel="."
-                    latin:keyHintIcon="@drawable/hint_popup"
-                    latin:popupKeyboard="@xml/popup_punctuation" />
-                <switch>
-                    <case
-                        latin:mode="im"
-                    >
-                        <Key
-                            latin:keyLabel=":-)"
-                            latin:keyOutputText=":-) "
-                            latin:keyHintIcon="@drawable/hint_popup"
-                            latin:popupKeyboard="@xml/popup_smileys"
-                            latin:keyWidth="25%p"
-                            latin:keyEdgeFlags="right" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:codes="@integer/key_return"
-                            latin:keyIcon="@drawable/sym_bkeyboard_return"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-                            latin:keyWidth="25%p"
-                            latin:keyEdgeFlags="right" />
-                    </default>
-                </switch>
-            </case>
-        </switch>
-    </Row>
-</merge>
diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_symbols_shift.xml
index f3e79f7..83963bf 100644
--- a/java/res/xml/kbd_symbols_shift.xml
+++ b/java/res/xml/kbd_symbols_shift.xml
@@ -26,7 +26,7 @@
     latin:keyHeight="@dimen/key_height"
 >
     <include
-        latin:keyboardLayout="@xml/kbd_functional_key_style" />
+        latin:keyboardLayout="@xml/kbd_key_styles" />
     <Row
         latin:rowEdgeFlags="top"
     >
@@ -59,9 +59,7 @@
     </Row>
     <Row>
         <Key
-            latin:codes="@integer/key_tab"
-            latin:keyIcon="@drawable/sym_keyboard_tab"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
+            latin:keyStyle="nonSpecialBackgroundTabKeyStyle"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="£" />
diff --git a/java/res/xml/kbd_symbols_shift_black.xml b/java/res/xml/kbd_symbols_shift_black.xml
deleted file mode 100644
index 895bcef..0000000
--- a/java/res/xml/kbd_symbols_shift_black.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<Keyboard
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:keyWidth="10%p"
-    latin:horizontalGap="@dimen/key_horizontal_gap"
-    latin:verticalGap="@dimen/key_bottom_gap"
-    latin:keyHeight="@dimen/key_height"
->
-    <Row
-        latin:rowEdgeFlags="top"
-    >
-        <Key
-            latin:keyLabel="~"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="`" />
-        <Key
-            latin:keyLabel="|" />
-        <Key
-            latin:keyLabel="•"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="♪♥♠♦♣" />
-        <Key
-            latin:keyLabel="√" />
-        <Key
-            latin:keyLabel="π"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="Π" />
-        <Key
-            latin:keyLabel="÷" />
-        <Key
-            latin:keyLabel="×" />
-        <Key
-            latin:keyLabel="{" />
-        <Key
-            latin:keyLabel="}"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Key
-            latin:codes="@integer/key_tab"
-            latin:keyLabel="\u21E5"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="£" />
-        <Key
-            latin:keyLabel="¢" />
-        <Key
-            latin:keyLabel="€" />
-        <Key
-            latin:keyLabel="°" />
-        <Key
-            latin:keyLabel="^"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="↑↓←→" />
-        <Key
-            latin:keyLabel="_" />
-        <Key
-            latin:keyLabel="="
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="≠≈∞" />
-        <Key
-            latin:keyLabel="[" />
-        <Key
-            latin:keyLabel="]"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row>
-        <Key
-            latin:codes="@integer/key_shift"
-            latin:keyLabel="@string/label_alt_key"
-            latin:keyWidth="15%p"
-            latin:isModifier="true"
-            latin:isSticky="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:keyLabel="™" />
-        <Key
-            latin:keyLabel="®" />
-        <Key
-            latin:keyLabel="©" />
-        <Key
-            latin:keyLabel="¶"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="§" />
-        <Key
-            latin:keyLabel="\\" />
-        <Key
-            latin:keyLabel="&lt;"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="≤«‹" />
-        <Key
-            latin:keyLabel="&gt;"
-            latin:popupKeyboard="@xml/kbd_popup_template"
-            latin:popupCharacters="≥»›" />
-        <Key
-            latin:codes="@integer/key_delete"
-            latin:keyIcon="@drawable/sym_bkeyboard_delete"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
-            latin:keyWidth="15%p"
-            latin:isRepeatable="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4" />
-</Keyboard>
diff --git a/java/res/xml/kbd_symbols_shift_black_row4.xml b/java/res/xml/kbd_symbols_shift_black_row4.xml
deleted file mode 100644
index 731cc6e..0000000
--- a/java/res/xml/kbd_symbols_shift_black_row4.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, 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.
-*/
--->
-
-<merge
-    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
-    <Row
-        latin:rowEdgeFlags="bottom"
-    >
-        <switch>
-            <case
-                latin:hasSettingsKey="false"
-            >
-                <Key
-                    latin:codes="@integer/key_switch_alpha_symbol"
-                    latin:keyLabel="@string/label_to_alpha_key"
-                    latin:keyWidth="20%p"
-                    latin:keyEdgeFlags="left" />
-                <Key
-                    latin:keyLabel="„" />
-                <Key
-                    latin:codes="@integer/key_space"
-                    latin:keyIcon="@drawable/sym_bkeyboard_space"
-                    latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-                    latin:keyWidth="40%p" />
-                <Key
-                    latin:keyLabel="…" />
-                <switch>
-                    <case
-                        latin:mode="im"
-                    >
-                        <Key
-                            latin:keyLabel=":-)"
-                            latin:keyOutputText=":-) "
-                            latin:keyHintIcon="@drawable/hint_popup"
-                            latin:popupKeyboard="@xml/popup_smileys"
-                            latin:keyWidth="20%p"
-                            latin:keyEdgeFlags="right" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:codes="@integer/key_return"
-                            latin:keyIcon="@drawable/sym_bkeyboard_return"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-                            latin:keyWidth="20%p"
-                            latin:keyEdgeFlags="right" />
-                    </default>
-                </switch>
-            </case>
-            <case
-                latin:hasSettingsKey="true"
-            >
-                <Key
-                    latin:codes="@integer/key_switch_alpha_symbol"
-                    latin:keyLabel="@string/label_to_alpha_key"
-                    latin:keyWidth="15%p"
-                    latin:keyEdgeFlags="left" />
-                <Key
-                    latin:codes="@integer/key_settings"
-                    latin:keyIcon="@drawable/sym_bkeyboard_settings"
-                    latin:iconPreview="@drawable/sym_keyboard_feedback_settings" />
-                <Key
-                    latin:keyLabel="„" />
-                <Key
-                    latin:codes="@integer/key_space"
-                    latin:keyIcon="@drawable/sym_bkeyboard_space"
-                    latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-                    latin:keyWidth="30%p" />
-                <Key
-                    latin:keyLabel="…" />
-                <switch>
-                    <case
-                        latin:mode="im"
-                    >
-                        <Key
-                            latin:keyLabel=":-)"
-                            latin:keyOutputText=":-) "
-                            latin:keyHintIcon="@drawable/hint_popup"
-                            latin:popupKeyboard="@xml/popup_smileys"
-                            latin:keyWidth="25%p"
-                            latin:keyEdgeFlags="right" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:codes="@integer/key_return"
-                            latin:keyIcon="@drawable/sym_bkeyboard_return"
-                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-                            latin:keyWidth="25%p"
-                            latin:keyEdgeFlags="right" />
-                    </default>
-                </switch>
-            </case>
-        </switch>
-    </Row>
-</merge>