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

Change-Id: I0d92e513757e765d9de98561205754af5a143650
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>