Keyboard XML supports switch-case-default tags to select rows and keys

Change-Id: I0d92e513757e765d9de98561205754af5a143650
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 0be4cec..72e3f0d 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -112,9 +112,6 @@
         <attr name="keyIcon" format="reference" />
         <!-- The hint icon to display on the key in conjunction with the label -->
         <attr name="keyHintIcon" format="reference" />
-        <!-- Mode of the keyboard. If the mode doesn't match the
-             requested keyboard mode, the key will be skipped. -->
-        <attr name="keyboardMode" />
     </declare-styleable>
 
     <declare-styleable name="BaseKeyboard_Row">
@@ -125,12 +122,15 @@
             <!-- Row is anchored to the bottom of the keyboard. -->
             <flag name="bottom" value="8" />
         </attr>
-        <!-- Mode of the keyboard. If the mode doesn't match the
-             requested keyboard mode, the row will be skipped. -->
-        <attr name="keyboardMode" format="reference" />
     </declare-styleable>
 
     <declare-styleable name="BaseKeyboard_Include">
         <attr name="keyboardLayout" format="reference" />
     </declare-styleable>
+
+    <declare-styleable name="BaseKeyboard_Case">
+        <attr name="mode" format="string" />
+        <attr name="settingsKey" format="string" />
+        <attr name="voiceKey" format="string" />
+    </declare-styleable>
 </resources>
diff --git a/java/res/xml-xlarge/kbd_qwerty.xml b/java/res/xml-xlarge/kbd_qwerty.xml
index b4b880e..6000911 100644
--- a/java/res/xml-xlarge/kbd_qwerty.xml
+++ b/java/res/xml-xlarge/kbd_qwerty.xml
@@ -25,85 +25,8 @@
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:keyHeight="@dimen/key_height"
 >
-    <!-- This row is intentionally not marked as a top row -->
-    <Row>
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row1_common" />
-    </Row>
-    <!-- TODO: We should have new attributes for <Key> to eliminate these excess duplications -->
-    <Row
-        latin:keyboardMode="@+id/mode_normal"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row2_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_url"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row2_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_email"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row2_email" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_im"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row2_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_webentry"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row2_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_normal"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row3_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_url"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row3_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_email"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row3_email" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_im"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row3_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_webentry"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row3_common" />
-    </Row>
-    <!-- This row is intentionally not marked as a bottom row -->
-    <Row
-        latin:keyboardMode="@+id/mode_normal"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_url"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row4_url" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_email"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row4_email" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_im"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_webentry"
-    >
-        <include latin:keyboardLayout="@xml/kbd_qwerty_row4_common" />
-    </Row>
+    <include latin:keyboardLayout="@xml/kbd_qwerty_row1" />
+    <include latin:keyboardLayout="@xml/kbd_qwerty_row2" />
+    <include latin:keyboardLayout="@xml/kbd_qwerty_row3" />
+    <include latin:keyboardLayout="@xml/kbd_qwerty_row4" />
 </Keyboard>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row1.xml b/java/res/xml-xlarge/kbd_qwerty_row1.xml
new file mode 100644
index 0000000..51a7927
--- /dev/null
+++ b/java/res/xml-xlarge/kbd_qwerty_row1.xml
@@ -0,0 +1,81 @@
+<?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"
+>
+    <!-- This row is intentionally not marked as a top row -->
+    <Row>
+        <Key
+            latin:codes="@integer/key_tab"
+            latin:keyLabel="Tab"
+            latin:keyWidth="7.0%p"
+            latin:isModifier="true"
+            latin:keyEdgeFlags="left" />
+        <Key
+            latin:keyLabel="q"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_q" />
+        <Key
+            latin:keyLabel="w"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_w" />
+        <Key
+            latin:keyLabel="e"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_e" />
+        <Key
+            latin:keyLabel="r"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_r" />
+        <Key
+            latin:keyLabel="t"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_t" />
+        <Key
+            latin:keyLabel="y"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_y" />
+        <Key
+            latin:keyLabel="u"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_u" />
+        <Key
+            latin:keyLabel="i"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_i" />
+        <Key
+            latin:keyLabel="o"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_o" />
+        <Key
+            latin:keyLabel="p"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_p" />
+        <Key
+            latin:codes="@integer/key_delete"
+            latin:keyIcon="@drawable/sym_keyboard_delete"
+            latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
+            latin:keyWidth="11.0%p"
+            latin:isModifier="true"
+            latin:isRepeatable="true"
+            latin:keyEdgeFlags="right" />
+    </Row>
+</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row1_common.xml b/java/res/xml-xlarge/kbd_qwerty_row1_common.xml
deleted file mode 100644
index 95bed0d..0000000
--- a/java/res/xml-xlarge/kbd_qwerty_row1_common.xml
+++ /dev/null
@@ -1,78 +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
-        latin:codes="@integer/key_tab"
-        latin:keyLabel="Tab"
-        latin:keyWidth="7.0%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:keyLabel="q"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_q" />
-    <Key
-        latin:keyLabel="w"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_w" />
-    <Key
-        latin:keyLabel="e"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_e" />
-    <Key
-        latin:keyLabel="r"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_r" />
-    <Key
-        latin:keyLabel="t"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_t" />
-    <Key
-        latin:keyLabel="y"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_y" />
-    <Key
-        latin:keyLabel="u"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_u" />
-    <Key
-        latin:keyLabel="i"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_i" />
-    <Key
-        latin:keyLabel="o"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_o" />
-    <Key
-        latin:keyLabel="p"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_p" />
-    <Key
-        latin:codes="@integer/key_delete"
-        latin:keyIcon="@drawable/sym_keyboard_delete"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_delete"
-        latin:keyWidth="11.0%p"
-        latin:isModifier="true"
-        latin:isRepeatable="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row2.xml b/java/res/xml-xlarge/kbd_qwerty_row2.xml
new file mode 100644
index 0000000..9607730
--- /dev/null
+++ b/java/res/xml-xlarge/kbd_qwerty_row2.xml
@@ -0,0 +1,83 @@
+<?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>
+        <Key
+            latin:codes="@integer/key_symbol"
+            latin:keyLabel="@string/label_symbol_key"
+            latin:keyWidth="9.7%p"
+            latin:isModifier="true"
+            latin:keyEdgeFlags="left" />
+        <Key
+            latin:keyLabel="a"
+            latin:popupKeyboard="@xml/kbd_popup_template"
+            latin:popupCharacters="@string/alternates_for_a" />
+        <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" />
+        <switch>
+            <case
+                latin:mode="email"
+            >
+                <Key
+                    latin:keyLabel="\@" />
+            </case>
+            <default>
+                <Key
+                    latin:keyLabel="\'"
+                    latin:temporaryShiftKeyLabel="&quot;"
+                    latin:keyHintIcon="@drawable/key_hint_quote_holo"
+                    latin:popupKeyboard="@xml/kbd_popup_template"
+                    latin:popupCharacters="&quot;" />
+            </default>
+        </switch>
+        <Key
+            latin:codes="@integer/key_return"
+            latin:keyIcon="@drawable/sym_keyboard_return"
+            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+            latin:keyWidth="8.3%p"
+            latin:isModifier="true"
+            latin:keyEdgeFlags="right" />
+    </Row>
+</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row2_common.xml b/java/res/xml-xlarge/kbd_qwerty_row2_common.xml
deleted file mode 100644
index 54befca..0000000
--- a/java/res/xml-xlarge/kbd_qwerty_row2_common.xml
+++ /dev/null
@@ -1,71 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_symbol_key"
-        latin:keyWidth="9.7%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:keyLabel="a"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_a" />
-    <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" />
-    <Key
-        latin:keyLabel="\'"
-        latin:temporaryShiftKeyLabel="&quot;"
-        latin:keyHintIcon="@drawable/key_hint_quote_holo"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="&quot;" />
-    <Key
-        latin:codes="@integer/key_return"
-        latin:keyIcon="@drawable/sym_keyboard_return"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-        latin:keyWidth="8.3%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row2_email.xml b/java/res/xml-xlarge/kbd_qwerty_row2_email.xml
deleted file mode 100644
index 7fd43ce..0000000
--- a/java/res/xml-xlarge/kbd_qwerty_row2_email.xml
+++ /dev/null
@@ -1,67 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_symbol_key"
-        latin:keyWidth="9.7%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:keyLabel="a"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="@string/alternates_for_a" />
-    <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" />
-    <Key
-        latin:keyLabel="\@" />
-    <Key
-        latin:codes="@integer/key_return"
-        latin:keyIcon="@drawable/sym_keyboard_return"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-        latin:keyWidth="8.3%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row3.xml b/java/res/xml-xlarge/kbd_qwerty_row3.xml
new file mode 100644
index 0000000..77a4d48
--- /dev/null
+++ b/java/res/xml-xlarge/kbd_qwerty_row3.xml
@@ -0,0 +1,88 @@
+<?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>
+        <Key
+            latin:codes="@integer/key_shift"
+            latin:keyIcon="@drawable/sym_keyboard_shift"
+            latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
+            latin:keyWidth="13.1%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" />
+        <switch>
+            <case
+                latin:mode="email"
+            >
+                <Key
+                    latin:keyLabel="," />
+                <Key
+                    latin:keyLabel="." />
+            </case>
+            <default>
+                <Key
+                    latin:keyLabel=","
+                    latin:temporaryShiftKeyLabel="!"
+                    latin:keyHintIcon="@drawable/key_hint_exclamation_holo"
+                    latin:popupKeyboard="@xml/kbd_popup_template"
+                    latin:popupCharacters="!" />
+                <Key
+                    latin:keyLabel="."
+                    latin:temporaryShiftKeyLabel="\?"
+                    latin:keyHintIcon="@drawable/key_hint_question_holo"
+                    latin:popupKeyboard="@xml/kbd_popup_template"
+                    latin:popupCharacters="\?" />
+            </default>
+        </switch>
+        <Key
+            latin:codes="@integer/key_shift"
+            latin:keyIcon="@drawable/sym_keyboard_shift"
+            latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
+            latin:keyWidth="13.1%p"
+            latin:isModifier="true"
+            latin:isSticky="true"
+            latin:keyEdgeFlags="right" />
+    </Row>
+</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row3_common.xml b/java/res/xml-xlarge/kbd_qwerty_row3_common.xml
deleted file mode 100644
index eb1e183..0000000
--- a/java/res/xml-xlarge/kbd_qwerty_row3_common.xml
+++ /dev/null
@@ -1,74 +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
-        latin:codes="@integer/key_shift"
-        latin:keyIcon="@drawable/sym_keyboard_shift"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
-        latin:keyWidth="13.1%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:keyLabel=","
-        latin:temporaryShiftKeyLabel="!"
-        latin:keyHintIcon="@drawable/key_hint_exclamation_holo"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="!" />
-    <Key
-        latin:keyLabel="."
-        latin:temporaryShiftKeyLabel="\?"
-        latin:keyHintIcon="@drawable/key_hint_question_holo"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="\?" />
-    <Key
-        latin:codes="@integer/key_shift"
-        latin:keyIcon="@drawable/sym_keyboard_shift"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
-        latin:keyWidth="13.1%p"
-        latin:isModifier="true"
-        latin:isSticky="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row3_email.xml b/java/res/xml-xlarge/kbd_qwerty_row3_email.xml
deleted file mode 100644
index d9e3542..0000000
--- a/java/res/xml-xlarge/kbd_qwerty_row3_email.xml
+++ /dev/null
@@ -1,66 +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
-        latin:codes="@integer/key_shift"
-        latin:keyIcon="@drawable/sym_keyboard_shift"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
-        latin:keyWidth="13.1%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:keyLabel="," />
-    <Key
-        latin:keyLabel="." />
-    <Key
-        latin:codes="@integer/key_shift"
-        latin:keyIcon="@drawable/sym_keyboard_shift"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_shift"
-        latin:keyWidth="13.1%p"
-        latin:isModifier="true"
-        latin:isSticky="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row4.xml b/java/res/xml-xlarge/kbd_qwerty_row4.xml
new file mode 100644
index 0000000..2392381
--- /dev/null
+++ b/java/res/xml-xlarge/kbd_qwerty_row4.xml
@@ -0,0 +1,95 @@
+<?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"
+>
+    <!-- This row is intentionally not marked as a bottom row -->
+    <Row>
+        <Spacer
+            latin:horizontalGap="15.1%p" />
+        <switch>
+            <case
+                latin:mode="email"
+            >
+                <Key
+                    latin:keyLabel=".com"
+                    latin:keyOutputText=".com"
+                    latin:keyHintIcon="@drawable/hint_popup"
+                    latin:popupKeyboard="@xml/popup_domains"
+                    latin:keyWidth="16.4%p" />
+            </case>
+            <!-- TODO: implement logical OR for <case> attribute -->
+            <case
+                latin:mode="url"
+            >
+                <Key
+                    latin:keyLabel=".com"
+                    latin:keyOutputText=".com"
+                    latin:keyHintIcon="@drawable/hint_popup"
+                    latin:popupKeyboard="@xml/popup_domains"
+                    latin:keyWidth="16.4%p" />
+            </case>
+            <default>
+                <Key
+                    latin:keyLabel=":-)"
+                    latin:keyOutputText=":-)"
+                    latin:keyHintIcon="@drawable/hint_popup"
+                    latin:popupKeyboard="@xml/popup_smileys" />
+                <Key
+                    latin:keyLabel="="
+                    latin:temporaryShiftKeyLabel="+"
+                    latin:keyHintIcon="@drawable/key_hint_plus_holo"
+                    latin:popupKeyboard="@xml/kbd_popup_template"
+                    latin:popupCharacters="&gt;" />
+            </default>
+        </switch>
+        <Key
+            latin:codes="@integer/key_space"
+            latin:keyIcon="@drawable/sym_keyboard_space"
+            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+            latin:keyWidth="37.0%p"
+            latin:isModifier="true" />
+        <switch>
+            <case
+                latin:mode="email"
+            >
+                <Key
+                    latin:keyLabel="_" />
+                <Key
+                    latin:keyLabel="-" />
+            </case>
+            <default>
+                <Key
+                    latin:keyLabel="-"
+                    latin:temporaryShiftKeyLabel="/"
+                    latin:keyHintIcon="@drawable/key_hint_slash_holo"
+                    latin:popupKeyboard="@xml/kbd_popup_template"
+                    latin:popupCharacters="/" />
+                <Key
+                    latin:keyLabel="_"
+                    latin:temporaryShiftKeyLabel="\@"
+                    latin:keyHintIcon="@drawable/key_hint_at_holo"
+                    latin:popupKeyboard="@xml/kbd_popup_template"
+                    latin:popupCharacters="\@" />
+            </default>
+        </switch>
+    </Row>
+</merge>
\ No newline at end of file
diff --git a/java/res/xml-xlarge/kbd_qwerty_row4_common.xml b/java/res/xml-xlarge/kbd_qwerty_row4_common.xml
deleted file mode 100644
index 2bcd71d..0000000
--- a/java/res/xml-xlarge/kbd_qwerty_row4_common.xml
+++ /dev/null
@@ -1,55 +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"
->
-    <Spacer
-        latin:horizontalGap="15.1%p" />
-    <Key
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-)"
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys" />
-    <Key
-        latin:keyLabel="="
-        latin:temporaryShiftKeyLabel="+"
-        latin:keyHintIcon="@drawable/key_hint_plus_holo"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="&gt;" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="37.0%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="-"
-        latin:temporaryShiftKeyLabel="/"
-        latin:keyHintIcon="@drawable/key_hint_slash_holo"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="/" />
-    <Key
-        latin:keyLabel="_"
-        latin:temporaryShiftKeyLabel="\@"
-        latin:keyHintIcon="@drawable/key_hint_at_holo"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="\@" />
-</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row4_email.xml b/java/res/xml-xlarge/kbd_qwerty_row4_email.xml
deleted file mode 100644
index f10cf4b..0000000
--- a/java/res/xml-xlarge/kbd_qwerty_row4_email.xml
+++ /dev/null
@@ -1,42 +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"
->
-    <Spacer
-        latin:horizontalGap="15.1%p" />
-    <Key
-        latin:keyLabel=".com"
-        latin:keyOutputText=".com"
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_domains"
-        latin:keyWidth="16.4%p" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="37.0%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="_" />
-    <Key
-        latin:keyLabel="-" />
-</merge>
diff --git a/java/res/xml-xlarge/kbd_qwerty_row4_url.xml b/java/res/xml-xlarge/kbd_qwerty_row4_url.xml
deleted file mode 100644
index 420d136..0000000
--- a/java/res/xml-xlarge/kbd_qwerty_row4_url.xml
+++ /dev/null
@@ -1,50 +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"
->
-    <Spacer
-        latin:horizontalGap="15.1%p" />
-    <Key
-        latin:keyLabel=".com"
-        latin:keyOutputText=".com"
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_domains"
-        latin:keyWidth="16.4%p" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="37.0%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="-"
-        latin:temporaryShiftKeyLabel="/"
-        latin:keyHintIcon="@drawable/key_hint_slash_holo"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters="/" />
-    <Key
-        latin:keyLabel="_"
-        latin:temporaryShiftKeyLabel=":"
-        latin:keyHintIcon="@drawable/key_hint_colon_holo"
-        latin:popupKeyboard="@xml/kbd_popup_template"
-        latin:popupCharacters=":" />
-</merge>
diff --git a/java/res/xml/kbd_qwerty_black_row4.xml b/java/res/xml/kbd_qwerty_black_row4.xml
index 330ddda..2b9ef7f 100644
--- a/java/res/xml/kbd_qwerty_black_row4.xml
+++ b/java/res/xml/kbd_qwerty_black_row4.xml
@@ -22,314 +22,141 @@
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
     <Row
-        latin:keyboardMode="@+id/mode_normal"
         latin:keyWidth="10%p"
         latin:rowEdgeFlags="bottom"
     >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_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" />
-        <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" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_url"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_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" />
-        <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" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_email"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_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" />
-        <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" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_im"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_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" />
-        <Key
-            latin:keyLabel=":-)"
-            latin:keyOutputText=":-) "
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_smileys"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_webentry"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_f1" />
-        <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" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation" />
-        <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" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_normal_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_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:codes="@integer/key_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" />
-        <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" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_url_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_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:codes="@integer/key_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" />
-        <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" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_email_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_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:codes="@integer/key_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" />
-        <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" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_im_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_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:codes="@integer/key_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" />
-        <Key
-            latin:keyLabel=":-)"
-            latin:keyOutputText=":-) "
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_smileys"
-            latin:keyWidth="25%p"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_webentry_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_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:codes="@integer/key_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:codes="@integer/key_tab"
-            latin:keyIcon="@drawable/sym_bkeyboard_tab"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_tab" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation" />
-        <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" />
+        <switch>
+            <case
+                latin:settingsKey="false"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_symbol_key"
+                    latin:keyWidth="20%p"
+                    latin:keyEdgeFlags="left" />
+                <Key
+                    latin:codes="@integer/key_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:settingsKey="true"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_symbol_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:codes="@integer/key_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_qwerty_row4.xml b/java/res/xml/kbd_qwerty_row4.xml
index 17b7c52..2e2b32e 100644
--- a/java/res/xml/kbd_qwerty_row4.xml
+++ b/java/res/xml/kbd_qwerty_row4.xml
@@ -22,371 +22,159 @@
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
     <Row
-        latin:keyboardMode="@+id/mode_normal"
         latin:keyWidth="10%p"
         latin:rowEdgeFlags="bottom"
     >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="40%p"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_keyboard_return"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_url"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="40%p"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_keyboard_return"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_email"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="40%p"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_keyboard_return"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_im"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="40%p"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel=":-)"
-            latin:keyOutputText=":-) "
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_smileys"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_webentry"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="20%p"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_tab"
-            latin:keyIcon="@drawable/sym_keyboard_tab"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
-            latin:keyWidth="20%p"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_keyboard_return"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-            latin:keyWidth="20%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_normal_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="15%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_settings"
-            latin:keyIcon="@drawable/sym_keyboard_settings"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="30%p"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_keyboard_return"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-            latin:keyWidth="25%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_url_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="15%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_settings"
-            latin:keyIcon="@drawable/sym_keyboard_settings"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="30%p"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_keyboard_return"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-            latin:keyWidth="25%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_email_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="15%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_settings"
-            latin:keyIcon="@drawable/sym_keyboard_settings"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="30%p"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_keyboard_return"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-            latin:keyWidth="25%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_im_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="15%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_settings"
-            latin:keyIcon="@drawable/sym_keyboard_settings"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="30%p"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel=":-)"
-            latin:keyOutputText=":-) "
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_smileys"
-            latin:keyWidth="25%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_webentry_with_settings_key"
-        latin:keyWidth="10%p"
-        latin:rowEdgeFlags="bottom"
-    >
-        <Key
-            latin:codes="@integer/key_symbol"
-            latin:keyLabel="@string/label_symbol_key"
-            latin:keyWidth="15%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="left" />
-        <Key
-            latin:codes="@integer/key_settings"
-            latin:keyIcon="@drawable/sym_keyboard_settings"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_f1"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_space"
-            latin:keyIcon="@drawable/sym_keyboard_space"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-            latin:keyWidth="30%p"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_tab"
-            latin:keyIcon="@drawable/sym_keyboard_tab"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
-            latin:isModifier="true" />
-        <Key
-            latin:keyLabel="."
-            latin:keyHintIcon="@drawable/hint_popup"
-            latin:popupKeyboard="@xml/popup_punctuation"
-            latin:isModifier="true" />
-        <Key
-            latin:codes="@integer/key_return"
-            latin:keyIcon="@drawable/sym_keyboard_return"
-            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-            latin:keyWidth="15%p"
-            latin:isModifier="true"
-            latin:keyEdgeFlags="right" />
+        <switch>
+            <case
+                latin:settingsKey="false"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_symbol_key"
+                    latin:keyWidth="20%p"
+                    latin:isModifier="true"
+                    latin:keyEdgeFlags="left" />
+                <Key
+                    latin:codes="@integer/key_f1"
+                    latin:isModifier="true" />
+                <switch>
+                    <case
+                        latin:mode="web"
+                    >
+                        <Key
+                            latin:codes="@integer/key_space"
+                            latin:keyIcon="@drawable/sym_keyboard_space"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                            latin:keyWidth="20%p"
+                            latin:isModifier="true" />
+                        <Key
+                            latin:codes="@integer/key_tab"
+                            latin:keyIcon="@drawable/sym_keyboard_tab"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
+                            latin:keyWidth="20%p"
+                            latin:isModifier="true" />
+                    </case>
+                    <default>
+                        <Key
+                            latin:codes="@integer/key_space"
+                            latin:keyIcon="@drawable/sym_keyboard_space"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                            latin:keyWidth="40%p"
+                            latin:isModifier="true" />
+                    </default>
+                </switch>
+                <Key
+                    latin:keyLabel="."
+                    latin:keyHintIcon="@drawable/hint_popup"
+                    latin:popupKeyboard="@xml/popup_punctuation"
+                    latin:isModifier="true" />
+                <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:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </case>
+                    <default>
+                        <Key
+                            latin:codes="@integer/key_return"
+                            latin:keyIcon="@drawable/sym_keyboard_return"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+                            latin:keyWidth="20%p"
+                            latin:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </default>
+                </switch>
+            </case>
+            <case
+                latin:settingsKey="true"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_symbol_key"
+                    latin:keyWidth="15%p"
+                    latin:isModifier="true"
+                    latin:keyEdgeFlags="left" />
+                <Key
+                    latin:codes="@integer/key_settings"
+                    latin:keyIcon="@drawable/sym_keyboard_settings"
+                    latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
+                    latin:isModifier="true" />
+                <Key
+                    latin:codes="@integer/key_f1"
+                    latin:isModifier="true" />
+                <switch>
+                    <case
+                        latin:mode="web"
+                    >
+                        <Key
+                            latin:codes="@integer/key_space"
+                            latin:keyIcon="@drawable/sym_keyboard_space"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                            latin:keyWidth="30%p"
+                            latin:isModifier="true" />
+                        <Key
+                            latin:codes="@integer/key_tab"
+                            latin:keyIcon="@drawable/sym_keyboard_tab"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_tab"
+                            latin:isModifier="true" />
+                    </case>
+                    <default>
+                        <Key
+                            latin:codes="@integer/key_space"
+                            latin:keyIcon="@drawable/sym_keyboard_space"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                            latin:keyWidth="30%p"
+                            latin:isModifier="true" />
+                    </default>
+                </switch>
+                <Key
+                    latin:keyLabel="."
+                    latin:keyHintIcon="@drawable/hint_popup"
+                    latin:popupKeyboard="@xml/popup_punctuation"
+                    latin:isModifier="true" />
+                <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:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </case>
+                    <case
+                        latin:mode="web"
+                    >
+                        <Key
+                            latin:codes="@integer/key_return"
+                            latin:keyIcon="@drawable/sym_keyboard_return"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+                            latin:keyWidth="15%p"
+                            latin:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                     </case>
+                    <default>
+                        <Key
+                            latin:codes="@integer/key_return"
+                            latin:keyIcon="@drawable/sym_keyboard_return"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+                            latin:keyWidth="25%p"
+                            latin:isModifier="true"
+                            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 608ddda..55b7681 100644
--- a/java/res/xml/kbd_symbols.xml
+++ b/java/res/xml/kbd_symbols.xml
@@ -142,64 +142,5 @@
             latin:isRepeatable="true"
             latin:keyEdgeFlags="right" />
     </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_normal"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_url"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_email"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_im"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_im" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_webentry"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_normal_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_url_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_email_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_im_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_im_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_webentry_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_row4_common_with_settings_key" />
-    </Row>
+    <include latin:keyboardLayout="@xml/kbd_symbols_row4" />
 </Keyboard>
diff --git a/java/res/xml/kbd_symbols_black.xml b/java/res/xml/kbd_symbols_black.xml
index 9e401a1..ea021fb 100644
--- a/java/res/xml/kbd_symbols_black.xml
+++ b/java/res/xml/kbd_symbols_black.xml
@@ -141,64 +141,5 @@
             latin:isRepeatable="true"
             latin:keyEdgeFlags="right" />
     </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_normal"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_url"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_email"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_im"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_im" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_webentry"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_normal_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_url_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_email_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_im_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_im_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_webentry_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_black_row4_common_with_settings_key" />
-    </Row>
+    <include latin:keyboardLayout="@xml/kbd_symbols_black_row4" />
 </Keyboard>
diff --git a/java/res/xml/kbd_symbols_black_row4.xml b/java/res/xml/kbd_symbols_black_row4.xml
new file mode 100644
index 0000000..d1ed527
--- /dev/null
+++ b/java/res/xml/kbd_symbols_black_row4.xml
@@ -0,0 +1,116 @@
+<?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:settingsKey="false"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_alpha_key"
+                    latin:keyWidth="20%p"
+                    latin:keyEdgeFlags="left" />
+                <Key
+                    latin:codes="@integer/key_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:settingsKey="true"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_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:codes="@integer/key_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_black_row4_common.xml b/java/res/xml/kbd_symbols_black_row4_common.xml
deleted file mode 100644
index 7433eca..0000000
--- a/java/res/xml/kbd_symbols_black_row4_common.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"
->
-    <Key
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="20%p"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:codes="@integer/key_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" />
-    <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" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_black_row4_common_with_settings_key.xml b/java/res/xml/kbd_symbols_black_row4_common_with_settings_key.xml
deleted file mode 100644
index bbb1699..0000000
--- a/java/res/xml/kbd_symbols_black_row4_common_with_settings_key.xml
+++ /dev/null
@@ -1,50 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_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:codes="@integer/key_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" />
-    <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" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_black_row4_im.xml b/java/res/xml/kbd_symbols_black_row4_im.xml
deleted file mode 100644
index a1546b7..0000000
--- a/java/res/xml/kbd_symbols_black_row4_im.xml
+++ /dev/null
@@ -1,47 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="20%p"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:codes="@integer/key_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" />
-    <Key
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys"
-        latin:keyWidth="20%p"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_black_row4_im_with_settings_key.xml b/java/res/xml/kbd_symbols_black_row4_im_with_settings_key.xml
deleted file mode 100644
index 4cab461..0000000
--- a/java/res/xml/kbd_symbols_black_row4_im_with_settings_key.xml
+++ /dev/null
@@ -1,51 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_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:codes="@integer/key_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" />
-    <Key
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys"
-        latin:keyWidth="25%p"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_row4.xml b/java/res/xml/kbd_symbols_row4.xml
new file mode 100644
index 0000000..4b3dd90
--- /dev/null
+++ b/java/res/xml/kbd_symbols_row4.xml
@@ -0,0 +1,129 @@
+<?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:settingsKey="false"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_alpha_key"
+                    latin:keyWidth="20%p"
+                    latin:isModifier="true"
+                    latin:keyEdgeFlags="left" />
+                <Key
+                    latin:codes="@integer/key_f1"
+                    latin:isModifier="true" />
+                <Key
+                    latin:codes="@integer/key_space"
+                    latin:keyIcon="@drawable/sym_keyboard_space"
+                    latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                    latin:keyWidth="40%p"
+                    latin:isModifier="true" />
+                <Key
+                    latin:keyLabel="."
+                    latin:keyHintIcon="@drawable/hint_popup"
+                    latin:popupKeyboard="@xml/popup_punctuation"
+                    latin:isModifier="true" />
+                <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:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </case>
+                    <default>
+                        <Key
+                            latin:codes="@integer/key_return"
+                            latin:keyIcon="@drawable/sym_keyboard_return"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+                            latin:keyWidth="20%p"
+                            latin:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </default>
+                </switch>
+            </case>
+            <case
+                latin:settingsKey="true"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_alpha_key"
+                    latin:keyWidth="15%p"
+                    latin:isModifier="true"
+                    latin:keyEdgeFlags="left" />
+                <Key
+                    latin:codes="@integer/key_settings"
+                    latin:keyIcon="@drawable/sym_keyboard_settings"
+                    latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
+                    latin:isModifier="true" />
+                <Key
+                    latin:codes="@integer/key_f1"
+                    latin:isModifier="true" />
+                <Key
+                    latin:codes="@integer/key_space"
+                    latin:keyIcon="@drawable/sym_keyboard_space"
+                    latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                    latin:keyWidth="30%p"
+                    latin:isModifier="true" />
+                <Key
+                    latin:keyLabel="."
+                    latin:keyHintIcon="@drawable/hint_popup"
+                    latin:popupKeyboard="@xml/popup_punctuation"
+                    latin:isModifier="true" />
+                <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:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </case>
+                    <default>
+                        <Key
+                            latin:codes="@integer/key_return"
+                            latin:keyIcon="@drawable/sym_keyboard_return"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+                            latin:keyWidth="25%p"
+                            latin:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </default>
+                </switch>
+            </case>
+        </switch>
+    </Row>
+</merge>
diff --git a/java/res/xml/kbd_symbols_row4_common.xml b/java/res/xml/kbd_symbols_row4_common.xml
deleted file mode 100644
index ef7cdca..0000000
--- a/java/res/xml/kbd_symbols_row4_common.xml
+++ /dev/null
@@ -1,51 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="20%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:codes="@integer/key_f1"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="40%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="."
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_punctuation"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_return"
-        latin:keyIcon="@drawable/sym_keyboard_return"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-        latin:keyWidth="20%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_row4_common_with_settings_key.xml b/java/res/xml/kbd_symbols_row4_common_with_settings_key.xml
deleted file mode 100644
index 54b8542..0000000
--- a/java/res/xml/kbd_symbols_row4_common_with_settings_key.xml
+++ /dev/null
@@ -1,56 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="15%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:codes="@integer/key_settings"
-        latin:keyIcon="@drawable/sym_keyboard_settings"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_f1"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="30%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="."
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_punctuation"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_return"
-        latin:keyIcon="@drawable/sym_keyboard_return"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-        latin:keyWidth="25%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_row4_im.xml b/java/res/xml/kbd_symbols_row4_im.xml
deleted file mode 100644
index c7d679b..0000000
--- a/java/res/xml/kbd_symbols_row4_im.xml
+++ /dev/null
@@ -1,52 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="20%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:codes="@integer/key_f1"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="40%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="."
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_punctuation"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys"
-        latin:keyWidth="20%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_row4_im_with_settings_key.xml b/java/res/xml/kbd_symbols_row4_im_with_settings_key.xml
deleted file mode 100644
index 7cc209b..0000000
--- a/java/res/xml/kbd_symbols_row4_im_with_settings_key.xml
+++ /dev/null
@@ -1,57 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="15%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:codes="@integer/key_settings"
-        latin:keyIcon="@drawable/sym_keyboard_settings"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_f1"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="30%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="."
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_punctuation"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys"
-        latin:keyWidth="25%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_symbols_shift.xml
index b8f8fae..5279656 100644
--- a/java/res/xml/kbd_symbols_shift.xml
+++ b/java/res/xml/kbd_symbols_shift.xml
@@ -121,64 +121,5 @@
             latin:isRepeatable="true"
             latin:keyEdgeFlags="right" />
     </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_normal"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_url"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_email"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_im"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_im" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_webentry"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_normal_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_url_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_email_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_im_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_im_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_webentry_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4_common_with_settings_key" />
-    </Row>
+    <include latin:keyboardLayout="@xml/kbd_symbols_shift_row4" />
 </Keyboard>
diff --git a/java/res/xml/kbd_symbols_shift_black.xml b/java/res/xml/kbd_symbols_shift_black.xml
index 34684a6..895bcef 100644
--- a/java/res/xml/kbd_symbols_shift_black.xml
+++ b/java/res/xml/kbd_symbols_shift_black.xml
@@ -120,64 +120,5 @@
             latin:isRepeatable="true"
             latin:keyEdgeFlags="right" />
     </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_normal"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_url"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_email"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_im"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_im" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_webentry"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_common" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_normal_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_url_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_email_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_common_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_im_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_im_with_settings_key" />
-    </Row>
-    <Row
-        latin:keyboardMode="@+id/mode_symbols_webentry_with_settings_key"
-        latin:rowEdgeFlags="bottom"
-    >
-        <include latin:keyboardLayout="@xml/kbd_symbols_shift_black_row4_common_with_settings_key" />
-    </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
new file mode 100644
index 0000000..e18ab21
--- /dev/null
+++ b/java/res/xml/kbd_symbols_shift_black_row4.xml
@@ -0,0 +1,112 @@
+<?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:settingsKey="false"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_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:settingsKey="true"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_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>
diff --git a/java/res/xml/kbd_symbols_shift_black_row4_common.xml b/java/res/xml/kbd_symbols_shift_black_row4_common.xml
deleted file mode 100644
index beb5b3d..0000000
--- a/java/res/xml/kbd_symbols_shift_black_row4_common.xml
+++ /dev/null
@@ -1,44 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_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="…" />
-    <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" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_shift_black_row4_common_with_settings_key.xml b/java/res/xml/kbd_symbols_shift_black_row4_common_with_settings_key.xml
deleted file mode 100644
index 97f882a..0000000
--- a/java/res/xml/kbd_symbols_shift_black_row4_common_with_settings_key.xml
+++ /dev/null
@@ -1,48 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_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="…" />
-    <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" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_shift_black_row4_im.xml b/java/res/xml/kbd_symbols_shift_black_row4_im.xml
deleted file mode 100644
index c0263c2..0000000
--- a/java/res/xml/kbd_symbols_shift_black_row4_im.xml
+++ /dev/null
@@ -1,45 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_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="…" />
-    <Key
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys"
-        latin:keyWidth="20%p"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_shift_black_row4_im_with_settings_key.xml b/java/res/xml/kbd_symbols_shift_black_row4_im_with_settings_key.xml
deleted file mode 100644
index 14d6a0b..0000000
--- a/java/res/xml/kbd_symbols_shift_black_row4_im_with_settings_key.xml
+++ /dev/null
@@ -1,49 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_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="…" />
-    <Key
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys"
-        latin:keyWidth="25%p"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_shift_row4.xml b/java/res/xml/kbd_symbols_shift_row4.xml
new file mode 100644
index 0000000..f0df130
--- /dev/null
+++ b/java/res/xml/kbd_symbols_shift_row4.xml
@@ -0,0 +1,125 @@
+<?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:settingsKey="false"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_alpha_key"
+                    latin:keyWidth="20%p"
+                    latin:isModifier="true"
+                    latin:keyEdgeFlags="left" />
+                <Key
+                    latin:keyLabel="„"
+                    latin:isModifier="true" />
+                <Key
+                    latin:codes="@integer/key_space"
+                    latin:keyIcon="@drawable/sym_keyboard_space"
+                    latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                    latin:keyWidth="40%p"
+                    latin:isModifier="true" />
+                <Key
+                    latin:keyLabel="…"
+                    latin:isModifier="true" />
+                <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:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </case>
+                    <default>
+                        <Key
+                            latin:codes="@integer/key_return"
+                            latin:keyIcon="@drawable/sym_keyboard_return"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+                            latin:keyWidth="20%p"
+                            latin:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </default>
+                </switch>
+            </case>
+            <case
+                latin:settingsKey="true"
+            >
+                <Key
+                    latin:codes="@integer/key_symbol"
+                    latin:keyLabel="@string/label_alpha_key"
+                    latin:keyWidth="15%p"
+                    latin:isModifier="true"
+                    latin:keyEdgeFlags="left" />
+                <Key
+                    latin:codes="@integer/key_settings"
+                    latin:keyIcon="@drawable/sym_keyboard_settings"
+                    latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
+                    latin:isModifier="true" />
+                <Key
+                    latin:keyLabel="„"
+                    latin:isModifier="true" />
+                <Key
+                    latin:codes="@integer/key_space"
+                    latin:keyIcon="@drawable/sym_keyboard_space"
+                    latin:iconPreview="@drawable/sym_keyboard_feedback_space"
+                    latin:keyWidth="30%p"
+                    latin:isModifier="true" />
+                <Key
+                    latin:keyLabel="…"
+                    latin:isModifier="true" />
+                <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:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </case>
+                    <default>
+                        <Key
+                            latin:codes="@integer/key_return"
+                            latin:keyIcon="@drawable/sym_keyboard_return"
+                            latin:iconPreview="@drawable/sym_keyboard_feedback_return"
+                            latin:keyWidth="25%p"
+                            latin:isModifier="true"
+                            latin:keyEdgeFlags="right" />
+                    </default>
+                </switch>
+            </case>
+        </switch>
+    </Row>
+</merge>
diff --git a/java/res/xml/kbd_symbols_shift_row4_common.xml b/java/res/xml/kbd_symbols_shift_row4_common.xml
deleted file mode 100644
index 4d5199e..0000000
--- a/java/res/xml/kbd_symbols_shift_row4_common.xml
+++ /dev/null
@@ -1,49 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="20%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:keyLabel="„"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="40%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="…"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_return"
-        latin:keyIcon="@drawable/sym_keyboard_return"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-        latin:keyWidth="20%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_shift_row4_common_with_settings_key.xml b/java/res/xml/kbd_symbols_shift_row4_common_with_settings_key.xml
deleted file mode 100644
index df570ea..0000000
--- a/java/res/xml/kbd_symbols_shift_row4_common_with_settings_key.xml
+++ /dev/null
@@ -1,54 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="15%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:codes="@integer/key_settings"
-        latin:keyIcon="@drawable/sym_keyboard_settings"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="„"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="30%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="…"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_return"
-        latin:keyIcon="@drawable/sym_keyboard_return"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_return"
-        latin:keyWidth="25%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_shift_row4_im.xml b/java/res/xml/kbd_symbols_shift_row4_im.xml
deleted file mode 100644
index 69c6092..0000000
--- a/java/res/xml/kbd_symbols_shift_row4_im.xml
+++ /dev/null
@@ -1,50 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="20%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:keyLabel="„"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="40%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="…"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys"
-        latin:keyWidth="20%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>
diff --git a/java/res/xml/kbd_symbols_shift_row4_im_with_settings_key.xml b/java/res/xml/kbd_symbols_shift_row4_im_with_settings_key.xml
deleted file mode 100644
index aad6e40..0000000
--- a/java/res/xml/kbd_symbols_shift_row4_im_with_settings_key.xml
+++ /dev/null
@@ -1,55 +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
-        latin:codes="@integer/key_symbol"
-        latin:keyLabel="@string/label_alpha_key"
-        latin:keyWidth="15%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="left" />
-    <Key
-        latin:codes="@integer/key_settings"
-        latin:keyIcon="@drawable/sym_keyboard_settings"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_settings"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="„"
-        latin:isModifier="true" />
-    <Key
-        latin:codes="@integer/key_space"
-        latin:keyIcon="@drawable/sym_keyboard_space"
-        latin:iconPreview="@drawable/sym_keyboard_feedback_space"
-        latin:keyWidth="30%p"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel="…"
-        latin:isModifier="true" />
-    <Key
-        latin:keyLabel=":-)"
-        latin:keyOutputText=":-) "
-        latin:keyHintIcon="@drawable/hint_popup"
-        latin:popupKeyboard="@xml/popup_smileys"
-        latin:keyWidth="25%p"
-        latin:isModifier="true"
-        latin:keyEdgeFlags="right" />
-</merge>