Merge "[Refactor] Add DictDecoder.readUnigramsAndBigramsBinary."
diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml
index c78c25f..d411cb9 100644
--- a/java/res/values-land/dimens.xml
+++ b/java/res/values-land/dimens.xml
@@ -79,4 +79,7 @@
     <dimen name="gesture_floating_preview_text_offset">54dp</dimen>
     <dimen name="gesture_floating_preview_horizontal_padding">23dp</dimen>
     <dimen name="gesture_floating_preview_vertical_padding">15dp</dimen>
+
+    <!-- Emoji keyboard -->
+    <fraction name="emoji_keyboard_key_width">8.3333%p</fraction>
 </resources>
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 4c50976..7ebaf75 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -215,6 +215,11 @@
         <attr name="iconEmojiKey" format="reference" />
     </declare-styleable>
 
+    <declare-styleable name="Keyboard_GridRows">
+        <attr name="codesArray" format="reference" />
+        <attr name="textsArray" format="reference" />
+    </declare-styleable>
+
     <declare-styleable name="Keyboard_Key">
         <!-- The unicode value that this key outputs.
              Code value represented in hexadecimal prefixed with "0x" or code value reference using
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index 98ae76c..bb5f0bb 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -123,6 +123,9 @@
     <dimen name="gesture_floating_preview_vertical_padding">16dp</dimen>
     <dimen name="gesture_floating_preview_round_radius">3dp</dimen>
 
+    <!-- Emoji keyboard -->
+    <fraction name="emoji_keyboard_key_width">14.2857%p</fraction>
+
     <!-- Inset used in Accessibility mode to avoid accidental key presses when a finger slides off the screen. -->
     <dimen name="accessibility_edge_slop">8dp</dimen>
 
diff --git a/java/res/xml-sw600dp/keys_pcqwerty2_right3.xml b/java/res/xml-sw600dp/keys_pcqwerty2_right3.xml
index 1db6c35..324e025 100644
--- a/java/res/xml-sw600dp/keys_pcqwerty2_right3.xml
+++ b/java/res/xml-sw600dp/keys_pcqwerty2_right3.xml
@@ -23,36 +23,32 @@
 >
     <switch>
         <case
-            latin:keyboardLayoutSetElement="symbols"
+            latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
         >
             <Key
                 latin:keyLabel="["
-                latin:moreKeys="{" />
-            <Key
-                latin:keyLabel="]"
-                latin:moreKeys="}" />
-            <!-- U+00A6: "¦" BROKEN BAR -->
-            <Key
-                latin:keyLabel="\\"
-                latin:moreKeys="\\|,&#x00A6;" />
-        </case>
-        <default>
-            <Key
-                latin:keyLabel="["
                 latin:keyHintLabel="{"
-                latin:moreKeys="{"
+                latin:additionalMoreKeys="{"
                 latin:keyStyle="hasShiftedLetterHintStyle" />
             <Key
                 latin:keyLabel="]"
                 latin:keyHintLabel="}"
-                latin:moreKeys="}"
+                latin:additionalMoreKeys="}"
                 latin:keyStyle="hasShiftedLetterHintStyle" />
-            <!-- U+00A6: "¦" BROKEN BAR -->
             <Key
                 latin:keyLabel="\\"
                 latin:keyHintLabel="|"
-                latin:moreKeys="\\|,&#x00A6;"
+                latin:additionalMoreKeys="\\|"
                 latin:keyStyle="hasShiftedLetterHintStyle" />
+        </case>
+        <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
+        <default>
+            <Key
+                latin:keyLabel="{" />
+            <Key
+                latin:keyLabel="}" />
+            <Key
+                latin:keyLabel="|" />
         </default>
     </switch>
-</merge>
+</merge>
\ No newline at end of file
diff --git a/java/res/xml-sw600dp/keys_pcqwerty3_right2.xml b/java/res/xml-sw600dp/keys_pcqwerty3_right2.xml
index b3882b6..254b5e5 100644
--- a/java/res/xml-sw600dp/keys_pcqwerty3_right2.xml
+++ b/java/res/xml-sw600dp/keys_pcqwerty3_right2.xml
@@ -23,26 +23,27 @@
 >
     <switch>
         <case
-            latin:keyboardLayoutSetElement="symbols"
+            latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
         >
             <Key
                 latin:keyLabel=";"
-                latin:moreKeys=":" />
-            <Key
-                latin:keyLabel="\'"
-                latin:moreKeys="!fixedColumnOrder!3,!text/double_quotes,!text/single_quotes" />
-        </case>
-        <default>
-            <Key
-                latin:keyLabel=";"
                 latin:keyHintLabel=":"
-                latin:moreKeys=":"
+                latin:additionalMoreKeys=":"
                 latin:keyStyle="hasShiftedLetterHintStyle" />
             <Key
                 latin:keyLabel="\'"
                 latin:keyHintLabel="&quot;"
-                latin:moreKeys="!fixedColumnOrder!4,!text/double_quotes,&quot;,!text/single_quotes"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
+                latin:additionalMoreKeys="&quot;"
+                latin:keyStyle="hasShiftedLetterHintStyle"
+                latin:moreKeys="!fixedColumnOrder!4,!text/double_quotes,%,!text/single_quotes" />
+        </case>
+        <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
+        <default>
+            <Key
+                latin:keyLabel=":" />
+            <Key
+                latin:keyLabel="&quot;"
+                latin:moreKeys="!fixedColumnOrder!3,!text/double_quotes,!text/single_quotes" />
         </default>
     </switch>
 </merge>
diff --git a/java/res/xml-sw600dp/keys_pcqwerty4_right3.xml b/java/res/xml-sw600dp/keys_pcqwerty4_right3.xml
index 13e95f5..774ff8d 100644
--- a/java/res/xml-sw600dp/keys_pcqwerty4_right3.xml
+++ b/java/res/xml-sw600dp/keys_pcqwerty4_right3.xml
@@ -23,28 +23,26 @@
 >
     <switch>
         <case
-            latin:keyboardLayoutSetElement="symbols"
+            latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
         >
-            <!-- U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-                 U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-                 U+2264: "≤" LESS-THAN OR EQUAL TO
-                 U+2265: "≥" GREATER-THAN EQUAL TO
-                 U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-                 U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -->
-           <Key
+            <Key
                 latin:keyLabel=","
+                latin:keyHintLabel="&lt;"
                 latin:additionalMoreKeys="&lt;"
-                latin:moreKeys="!fixedColumnOrder!4,&#x2039;,&#x2064;,&#x00AB;" />
+                latin:keyStyle="hasShiftedLetterHintStyle" />
             <Key
                 latin:keyLabel="."
+                latin:keyHintLabel="&gt;"
                 latin:additionalMoreKeys="&gt;"
-                latin:moreKeys="!fixedColumnOrder!4,&#x203A;,&#x2065;,&#x00BB;" />
-            <!-- U+00BF: "¿" INVERTED QUESTION MARK -->
+                latin:keyStyle="hasShiftedLetterHintStyle" />
             <Key
                 latin:keyLabel="/"
+                latin:keyHintLabel="\?"
                 latin:additionalMoreKeys="\?"
-                latin:moreKeys="&#x00BF;" />
+                latin:keyStyle="hasShiftedLetterHintStyle"
+                latin:moreKeys="!text/more_keys_for_symbols_question" />
         </case>
+        <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
         <default>
             <!-- U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
                  U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
@@ -53,24 +51,14 @@
                  U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
                  U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK -->
             <Key
-                latin:keyLabel=","
-                latin:keyHintLabel="&lt;"
-                latin:additionalMoreKeys="&lt;"
-                latin:moreKeys="!fixedColumnOrder!4,&#x2039;,&#x2264;,&#x00AB;"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
+                latin:keyLabel="&lt;"
+                latin:moreKeys="!fixedColumnOrder!3,&#x2039;,&#x2264;,&#x00AB;" />
             <Key
-                latin:keyLabel="."
-                latin:keyHintLabel="&gt;"
-                latin:additionalMoreKeys="&gt;"
-                latin:moreKeys="!fixedColumnOrder!4,&#x203A;,&#x2265;,&#x00BB;"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <!-- U+00BF: "¿" INVERTED QUESTION MARK -->
+                latin:keyLabel="&gt;"
+                latin:moreKeys="!fixedColumnOrder!3,&#x203A;,&#x2265;,&#x00BB;" />
             <Key
-                latin:keyLabel="/"
-                latin:keyHintLabel="\?"
-                latin:additionalMoreKeys="\?"
-                latin:moreKeys="&#x00BF;"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
+                latin:keyLabel="\?"
+                latin:moreKeys="!text/more_keys_for_symbols_question" />
         </default>
     </switch>
 </merge>
diff --git a/java/res/xml-sw600dp/row_pcqwerty5.xml b/java/res/xml-sw600dp/row_pcqwerty5.xml
index 3c4a466..a79d2a8 100644
--- a/java/res/xml-sw600dp/row_pcqwerty5.xml
+++ b/java/res/xml-sw600dp/row_pcqwerty5.xml
@@ -38,9 +38,23 @@
             latin:keyStyle="spaceKeyStyle"
             latin:keyXPos="25.5%p"
             latin:keyWidth="49.0%p" />
-         <include
-            latin:keyXPos="-9.0%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+        <switch>
+            <case
+                latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
+            >
+                <include
+                    latin:keyXPos="-9.0%p"
+                    latin:keyWidth="9.0%p"
+                    latin:keyboardLayout="@xml/key_shortcut" />
+            </case>
+            <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
+            <default>
+                <include
+                    latin:keyXPos="-9.0%p"
+                    latin:keyWidth="9.0%p"
+                    latin:backgroundType="functional"
+                    latin:keyboardLayout="@xml/key_symbols_period" />
+            </default>
+        </switch>
     </Row>
 </merge>
diff --git a/java/res/xml-sw600dp/rowkeys_pcqwerty1.xml b/java/res/xml-sw600dp/rowkeys_pcqwerty1.xml
index d36582a..254d3fd 100644
--- a/java/res/xml-sw600dp/rowkeys_pcqwerty1.xml
+++ b/java/res/xml-sw600dp/rowkeys_pcqwerty1.xml
@@ -21,93 +21,87 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <switch>
-        <case
-            latin:keyboardLayoutSetElement="symbols"
-        >
-            <include
-                latin:keyboardLayout="@xml/keys_pcqwerty_symbols1" />
-        </case>
-        <!-- keyboardLayoutSetElement="alphabet*" -->
-        <default>
-            <!-- U+00AC: "¬" NOT SIGN -->
-            <Key
-                latin:keyLabel="`"
-                latin:keyHintLabel="~"
-                latin:additionalMoreKeys="~"
-                latin:moreKeys="&#x00AC;"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <!-- U+00A1: "¡" NVERTED EXCLAMATION MARK -->
-            <Key
-                latin:keyLabel="1"
-                latin:keyHintLabel="!"
-                latin:additionalMoreKeys="!"
-                latin:moreKeys="&#x00A1;,!text/more_keys_for_symbols_1"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="2"
-                latin:keyHintLabel="\@"
-                latin:additionalMoreKeys="\@"
-                latin:moreKeys="!text/more_keys_for_symbols_2"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="3"
-                latin:keyHintLabel="\#"
-                latin:additionalMoreKeys="\#"
-                latin:moreKeys="!text/more_keys_for_symbols_3"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="4"
-                latin:keyHintLabel="$"
-                latin:additionalMoreKeys="$"
-                latin:moreKeys="!text/more_keys_for_symbols_4"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="5"
-                latin:keyHintLabel="%"
-                latin:additionalMoreKeys="\\%"
-                latin:moreKeys="!text/more_keys_for_symbols_5"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="6"
-                latin:keyHintLabel="^"
-                latin:additionalMoreKeys="^"
-                latin:moreKeys="!text/more_keys_for_symbols_6"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="7"
-                latin:keyHintLabel="&amp;"
-                latin:additionalMoreKeys="&amp;"
-                latin:moreKeys="!text/more_keys_for_symbols_7"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="8"
-                latin:keyHintLabel="*"
-                latin:additionalMoreKeys="*"
-                latin:moreKeys="!text/more_keys_for_symbols_8"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="9"
-                latin:keyHintLabel="("
-                latin:additionalMoreKeys="("
-                latin:moreKeys="!text/more_keys_for_symbols_9"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="0"
-                latin:keyHintLabel=")"
-                latin:additionalMoreKeys=")"
-                latin:moreKeys="!text/more_keys_for_symbols_0"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="-"
-                latin:keyHintLabel="_"
-                latin:moreKeys="_"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="="
-                latin:keyHintLabel="+"
-                latin:moreKeys="+"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-        </default>
-    </switch>
+    <Key
+        latin:keyLabel="`"
+        latin:keyHintLabel="~"
+        latin:additionalMoreKeys="~"
+        latin:keyStyle="hasShiftedLetterHintStyle" />
+    <Key
+        latin:keyLabel="1"
+        latin:keyHintLabel="!"
+        latin:additionalMoreKeys="!"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_exclamation,!text/more_keys_for_symbols_1" />
+    <Key
+        latin:keyLabel="2"
+        latin:keyHintLabel="\@"
+        latin:additionalMoreKeys="\@"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_2" />
+    <Key
+        latin:keyLabel="3"
+        latin:keyHintLabel="\#"
+        latin:additionalMoreKeys="\#"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_3" />
+    <Key
+        latin:keyLabel="4"
+        latin:keyHintLabel="$"
+        latin:additionalMoreKeys="$"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_4" />
+    <Key
+        latin:keyLabel="5"
+        latin:keyHintLabel="%"
+        latin:additionalMoreKeys="\\%"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_5" />
+    <Key
+        latin:keyLabel="6"
+        latin:keyHintLabel="^"
+        latin:additionalMoreKeys="^"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_6" />
+    <Key
+        latin:keyLabel="7"
+        latin:keyHintLabel="&amp;"
+        latin:additionalMoreKeys="&amp;"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_7" />
+    <Key
+        latin:keyLabel="8"
+        latin:keyHintLabel="*"
+        latin:additionalMoreKeys="*"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_8" />
+    <Key
+        latin:keyLabel="9"
+        latin:keyHintLabel="("
+        latin:additionalMoreKeys="("
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_9" />
+    <Key
+        latin:keyLabel="0"
+        latin:keyHintLabel=")"
+        latin:additionalMoreKeys=")"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="!text/more_keys_for_symbols_0" />
+    <!-- U+2013: "–" EN DASH
+         U+2014: "—" EM DASH
+         U+00B7: "·" MIDDLE DOT -->
+    <Key
+        latin:keyLabel="-"
+        latin:keyHintLabel="_"
+        latin:additionalMoreKeys="_"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="&#x2013;,&#x2014;,&#x00B7;" />
+    <!-- U+221E: "∞" INFINITY
+         U+2260: "≠" NOT EQUAL TO
+         U+2248: "≈" ALMOST EQUAL TO -->
+    <Key
+        latin:keyLabel="="
+        latin:keyHintLabel="+"
+        latin:additionalMoreKeys="+"
+        latin:keyStyle="hasShiftedLetterHintStyle"
+        latin:moreKeys="&#x221E;,&#x2260;,&#x2248;" />
 </merge>
diff --git a/java/res/xml-sw600dp/rows_pcqwerty.xml b/java/res/xml-sw600dp/rows_pcqwerty.xml
index fa6080a..8714815 100644
--- a/java/res/xml-sw600dp/rows_pcqwerty.xml
+++ b/java/res/xml-sw600dp/rows_pcqwerty.xml
@@ -26,8 +26,19 @@
     <Row
         latin:keyWidth="7.0%p"
     >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty1" />
+        <switch>
+            <case
+                latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
+            >
+                <include
+                    latin:keyboardLayout="@xml/rowkeys_pcqwerty1" />
+            </case>
+            <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
+            <default>
+                <include
+                     latin:keyboardLayout="@xml/rowkeys_pcqwerty1_shift" />
+            </default>
+        </switch>
         <Key
             latin:keyStyle="deleteKeyStyle"
             latin:keyWidth="fillRight" />
@@ -44,9 +55,7 @@
     <Row
         latin:keyWidth="7.0%p"
     >
-        <Key
-            latin:keyStyle="toSymbolKeyStyle"
-            latin:keyLabel="!text/label_to_symbol_key_pcqwerty"
+        <Spacer
             latin:keyWidth="12.0%p" />
         <include
             latin:keyboardLayout="@xml/rowkeys_pcqwerty3" />
diff --git a/java/res/xml-sw600dp/rows_pcqwerty_symbols.xml b/java/res/xml-sw600dp/rows_pcqwerty_symbols.xml
deleted file mode 100644
index e642704..0000000
--- a/java/res/xml-sw600dp/rows_pcqwerty_symbols.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2012, 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"
->
-    <include
-        latin:keyboardLayout="@xml/key_styles_common" />
-    <Row
-        latin:keyWidth="7.0%p"
-    >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty1" />
-        <Key
-            latin:keyStyle="deleteKeyStyle"
-            latin:keyWidth="fillRight" />
-    </Row>
-    <Row
-        latin:keyWidth="7.0%p"
-    >
-        <Key
-            latin:keyStyle="tabKeyStyle"
-            latin:keyWidth="9.0%p" />
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty2" />
-    </Row>
-    <Row
-        latin:keyWidth="7.0%p"
-    >
-        <Key
-            latin:keyStyle="toAlphaKeyStyle"
-            latin:keyWidth="12.0%p" />
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty3" />
-        <Key
-            latin:keyStyle="enterKeyStyle"
-            latin:keyWidth="fillRight" />
-    </Row>
-    <Row
-        latin:keyWidth="7.0%p"
-    >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty4"
-            latin:keyXPos="15.0%p" />
-    </Row>
-    <include
-        latin:keyboardLayout="@xml/row_pcqwerty5" />
-</merge>
diff --git a/java/res/xml-sw768dp/row_pcqwerty5.xml b/java/res/xml-sw768dp/row_pcqwerty5.xml
index e395b66..6bfd646 100644
--- a/java/res/xml-sw768dp/row_pcqwerty5.xml
+++ b/java/res/xml-sw768dp/row_pcqwerty5.xml
@@ -24,36 +24,34 @@
     <Row
         latin:keyWidth="8.047%p"
     >
-        <include
-            latin:keyboardLayout="@xml/key_settings" />
         <switch>
             <case
-                latin:keyboardLayoutSetElement="symbols"
-            >
-                <Spacer
-                    latin:keyXPos="15.0%p"
-                    latin:keyWidth="10.5%p" />
-            </case>
-            <case
-                latin:mode="email|url"
+                latin:languageSwitchKeyEnabled="true"
             >
                 <Key
-                    latin:keyStyle="comKeyStyle"
-                    latin:keyXPos="15.0%p"
-                    latin:keyWidth="10.5%p" />
+                    latin:keyStyle="languageSwitchKeyStyle"
+                    latin:backgroundType="functional" />
             </case>
-            <default>
-                <Spacer
-                    latin:keyXPos="15.0%p"
-                    latin:keyWidth="10.5%p" />
-            </default>
         </switch>
         <Key
             latin:keyStyle="spaceKeyStyle"
+            latin:keyXPos="25.5%p"
             latin:keyWidth="49.0%p" />
-        <include
-            latin:keyXPos="-8.047%p"
-            latin:keyWidth="fillRight"
-            latin:keyboardLayout="@xml/key_shortcut" />
+        <switch>
+            <case
+                latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
+            >
+                <include
+                    latin:keyXPos="-8.047%p"
+                    latin:keyboardLayout="@xml/key_shortcut" />
+            </case>
+            <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
+            <default>
+                <include
+                    latin:keyXPos="-8.047%p"
+                    latin:backgroundType="functional"
+                    latin:keyboardLayout="@xml/key_symbols_period" />
+            </default>
+        </switch>
     </Row>
 </merge>
diff --git a/java/res/xml-sw768dp/rows_pcqwerty.xml b/java/res/xml-sw768dp/rows_pcqwerty.xml
index a844728..5f721a2 100644
--- a/java/res/xml-sw768dp/rows_pcqwerty.xml
+++ b/java/res/xml-sw768dp/rows_pcqwerty.xml
@@ -26,8 +26,19 @@
     <Row
         latin:keyWidth="7.0%p"
     >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty1" />
+        <switch>
+            <case
+                latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
+            >
+                <include
+                    latin:keyboardLayout="@xml/rowkeys_pcqwerty1" />
+            </case>
+            <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
+            <default>
+                <include
+                     latin:keyboardLayout="@xml/rowkeys_pcqwerty1_shift" />
+            </default>
+        </switch>
         <Key
             latin:keyStyle="deleteKeyStyle"
             latin:keyWidth="fillRight" />
@@ -44,9 +55,7 @@
     <Row
         latin:keyWidth="7.0%p"
     >
-        <Key
-            latin:keyStyle="toSymbolKeyStyle"
-            latin:keyLabel="!text/label_to_symbol_key_pcqwerty"
+        <Spacer
             latin:keyWidth="12.0%p" />
         <include
             latin:keyboardLayout="@xml/rowkeys_pcqwerty3" />
diff --git a/java/res/xml-sw768dp/rows_pcqwerty_symbols.xml b/java/res/xml-sw768dp/rows_pcqwerty_symbols.xml
deleted file mode 100644
index 45736e6..0000000
--- a/java/res/xml-sw768dp/rows_pcqwerty_symbols.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2011, 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"
->
-    <include
-        latin:keyboardLayout="@xml/key_styles_common" />
-    <Row
-        latin:keyWidth="7.0%p"
-    >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty1" />
-        <Key
-            latin:keyStyle="deleteKeyStyle"
-            latin:keyWidth="fillRight" />
-    </Row>
-    <Row
-        latin:keyWidth="7.0%p"
-    >
-        <Key
-            latin:keyStyle="tabKeyStyle"
-            latin:keyWidth="9.0%p" />
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty2" />
-    </Row>
-    <Row
-        latin:keyWidth="7.0%p"
-    >
-        <Key
-            latin:keyStyle="toAlphaKeyStyle"
-            latin:keyWidth="12.0%p" />
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty3" />
-        <Key
-            latin:keyStyle="enterKeyStyle"
-            latin:keyWidth="fillRight" />
-    </Row>
-    <Row
-        latin:keyWidth="7.0%p"
-    >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty4"
-            latin:keyXPos="15.0%p" />
-    </Row>
-    <include
-        latin:keyboardLayout="@xml/row_pcqwerty5" />
-</merge>
diff --git a/java/res/xml/kbd_pcqwerty_symbols.xml b/java/res/xml/kbd_emoji_category1.xml
similarity index 62%
copy from java/res/xml/kbd_pcqwerty_symbols.xml
copy to java/res/xml/kbd_emoji_category1.xml
index bfb39e8..92b0c3f 100644
--- a/java/res/xml/kbd_pcqwerty_symbols.xml
+++ b/java/res/xml/kbd_emoji_category1.xml
@@ -2,7 +2,7 @@
 <!--
 /*
 **
-** Copyright 2012, The Android Open Source Project
+** Copyright 2013, 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.
@@ -20,12 +20,11 @@
 
 <Keyboard
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:rowHeight="20%p"
-    latin:verticalGap="@fraction/key_bottom_gap_5row"
-    latin:keyLetterSize="@fraction/key_letter_ratio_5row"
-    latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
-    latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
+    latin:keyWidth="@fraction/emoji_keyboard_key_width"
+    latin:keyLetterSize="90%p"
 >
-    <include
-        latin:keyboardLayout="@xml/rows_pcqwerty_symbols" />
+    <GridRows
+        latin:codesArray="@array/emoji_faces"
+        latin:keyLabelFlags="fontNormal"
+        latin:backgroundType="empty" />
 </Keyboard>
diff --git a/java/res/xml/kbd_pcqwerty_symbols.xml b/java/res/xml/kbd_emoji_category2.xml
similarity index 62%
copy from java/res/xml/kbd_pcqwerty_symbols.xml
copy to java/res/xml/kbd_emoji_category2.xml
index bfb39e8..17d36c5 100644
--- a/java/res/xml/kbd_pcqwerty_symbols.xml
+++ b/java/res/xml/kbd_emoji_category2.xml
@@ -2,7 +2,7 @@
 <!--
 /*
 **
-** Copyright 2012, The Android Open Source Project
+** Copyright 2013, 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.
@@ -20,12 +20,11 @@
 
 <Keyboard
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:rowHeight="20%p"
-    latin:verticalGap="@fraction/key_bottom_gap_5row"
-    latin:keyLetterSize="@fraction/key_letter_ratio_5row"
-    latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
-    latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
+    latin:keyWidth="@fraction/emoji_keyboard_key_width"
+    latin:keyLetterSize="90%p"
 >
-    <include
-        latin:keyboardLayout="@xml/rows_pcqwerty_symbols" />
+    <GridRows
+        latin:codesArray="@array/emoji_objects"
+        latin:keyLabelFlags="fontNormal"
+        latin:backgroundType="empty" />
 </Keyboard>
diff --git a/java/res/xml/kbd_pcqwerty_symbols.xml b/java/res/xml/kbd_emoji_category3.xml
similarity index 62%
copy from java/res/xml/kbd_pcqwerty_symbols.xml
copy to java/res/xml/kbd_emoji_category3.xml
index bfb39e8..9000a3a 100644
--- a/java/res/xml/kbd_pcqwerty_symbols.xml
+++ b/java/res/xml/kbd_emoji_category3.xml
@@ -2,7 +2,7 @@
 <!--
 /*
 **
-** Copyright 2012, The Android Open Source Project
+** Copyright 2013, 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.
@@ -20,12 +20,11 @@
 
 <Keyboard
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:rowHeight="20%p"
-    latin:verticalGap="@fraction/key_bottom_gap_5row"
-    latin:keyLetterSize="@fraction/key_letter_ratio_5row"
-    latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
-    latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
+    latin:keyWidth="@fraction/emoji_keyboard_key_width"
+    latin:keyLetterSize="90%p"
 >
-    <include
-        latin:keyboardLayout="@xml/rows_pcqwerty_symbols" />
+    <GridRows
+        latin:codesArray="@array/emoji_nature"
+        latin:keyLabelFlags="fontNormal"
+        latin:backgroundType="empty" />
 </Keyboard>
diff --git a/java/res/xml/kbd_pcqwerty_symbols.xml b/java/res/xml/kbd_emoji_category4.xml
similarity index 62%
rename from java/res/xml/kbd_pcqwerty_symbols.xml
rename to java/res/xml/kbd_emoji_category4.xml
index bfb39e8..e79e124 100644
--- a/java/res/xml/kbd_pcqwerty_symbols.xml
+++ b/java/res/xml/kbd_emoji_category4.xml
@@ -2,7 +2,7 @@
 <!--
 /*
 **
-** Copyright 2012, The Android Open Source Project
+** Copyright 2013, 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.
@@ -20,12 +20,11 @@
 
 <Keyboard
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:rowHeight="20%p"
-    latin:verticalGap="@fraction/key_bottom_gap_5row"
-    latin:keyLetterSize="@fraction/key_letter_ratio_5row"
-    latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
-    latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
+    latin:keyWidth="@fraction/emoji_keyboard_key_width"
+    latin:keyLetterSize="90%p"
 >
-    <include
-        latin:keyboardLayout="@xml/rows_pcqwerty_symbols" />
+    <GridRows
+        latin:codesArray="@array/emoji_places"
+        latin:keyLabelFlags="fontNormal"
+        latin:backgroundType="empty" />
 </Keyboard>
diff --git a/java/res/xml/kbd_pcqwerty_symbols.xml b/java/res/xml/kbd_emoji_category5.xml
similarity index 62%
copy from java/res/xml/kbd_pcqwerty_symbols.xml
copy to java/res/xml/kbd_emoji_category5.xml
index bfb39e8..07b3d90 100644
--- a/java/res/xml/kbd_pcqwerty_symbols.xml
+++ b/java/res/xml/kbd_emoji_category5.xml
@@ -2,7 +2,7 @@
 <!--
 /*
 **
-** Copyright 2012, The Android Open Source Project
+** Copyright 2013, 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.
@@ -20,12 +20,11 @@
 
 <Keyboard
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:rowHeight="20%p"
-    latin:verticalGap="@fraction/key_bottom_gap_5row"
-    latin:keyLetterSize="@fraction/key_letter_ratio_5row"
-    latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
-    latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
+    latin:keyWidth="@fraction/emoji_keyboard_key_width"
+    latin:keyLetterSize="90%p"
 >
-    <include
-        latin:keyboardLayout="@xml/rows_pcqwerty_symbols" />
+    <GridRows
+        latin:codesArray="@array/emoji_symbols"
+        latin:keyLabelFlags="fontNormal"
+        latin:backgroundType="empty" />
 </Keyboard>
diff --git a/java/res/xml/kbd_pcqwerty_symbols.xml b/java/res/xml/kbd_emoji_category6.xml
similarity index 62%
copy from java/res/xml/kbd_pcqwerty_symbols.xml
copy to java/res/xml/kbd_emoji_category6.xml
index bfb39e8..a07966b 100644
--- a/java/res/xml/kbd_pcqwerty_symbols.xml
+++ b/java/res/xml/kbd_emoji_category6.xml
@@ -2,7 +2,7 @@
 <!--
 /*
 **
-** Copyright 2012, The Android Open Source Project
+** Copyright 2013, 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.
@@ -20,12 +20,11 @@
 
 <Keyboard
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:rowHeight="20%p"
-    latin:verticalGap="@fraction/key_bottom_gap_5row"
-    latin:keyLetterSize="@fraction/key_letter_ratio_5row"
-    latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
-    latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
+    latin:keyWidth="@fraction/emoji_keyboard_key_width"
+    latin:keyLetterSize="90%p"
 >
-    <include
-        latin:keyboardLayout="@xml/rows_pcqwerty_symbols" />
+    <GridRows
+        latin:textsArray="@array/emoji_emoticons"
+        latin:keyLabelFlags="fontNormal"
+        latin:backgroundType="empty" />
 </Keyboard>
diff --git a/java/res/xml/kbd_pcqwerty_symbols.xml b/java/res/xml/kbd_emoji_recents.xml
similarity index 62%
copy from java/res/xml/kbd_pcqwerty_symbols.xml
copy to java/res/xml/kbd_emoji_recents.xml
index bfb39e8..8b4fa95 100644
--- a/java/res/xml/kbd_pcqwerty_symbols.xml
+++ b/java/res/xml/kbd_emoji_recents.xml
@@ -2,7 +2,7 @@
 <!--
 /*
 **
-** Copyright 2012, The Android Open Source Project
+** Copyright 2013, 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.
@@ -20,12 +20,11 @@
 
 <Keyboard
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
-    latin:rowHeight="20%p"
-    latin:verticalGap="@fraction/key_bottom_gap_5row"
-    latin:keyLetterSize="@fraction/key_letter_ratio_5row"
-    latin:keyShiftedLetterHintRatio="@fraction/key_uppercase_letter_ratio_5row"
-    latin:touchPositionCorrectionData="@array/touch_position_correction_data_default"
+    latin:keyWidth="@fraction/emoji_keyboard_key_width"
+    latin:keyLetterSize="90%p"
 >
-    <include
-        latin:keyboardLayout="@xml/rows_pcqwerty_symbols" />
+    <GridRows
+        latin:codesArray="@array/emoji_recents"
+        latin:keyLabelFlags="fontNormal"
+        latin:backgroundType="empty" />
 </Keyboard>
diff --git a/java/res/xml/keyboard_layout_set_emoji.xml b/java/res/xml/keyboard_layout_set_emoji.xml
new file mode 100644
index 0000000..98e6b6b
--- /dev/null
+++ b/java/res/xml/keyboard_layout_set_emoji.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2013, 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.
+*/
+-->
+
+<KeyboardLayoutSet
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin">
+    <Element
+        latin:elementName="emojiRecents"
+        latin:elementKeyboard="@xml/kbd_emoji_recents" />
+    <Element
+        latin:elementName="emojiCategory1"
+        latin:elementKeyboard="@xml/kbd_emoji_category1" />
+    <Element
+        latin:elementName="emojiCategory2"
+        latin:elementKeyboard="@xml/kbd_emoji_category2" />
+    <Element
+        latin:elementName="emojiCategory3"
+        latin:elementKeyboard="@xml/kbd_emoji_category3" />
+    <Element
+        latin:elementName="emojiCategory4"
+        latin:elementKeyboard="@xml/kbd_emoji_category4" />
+    <Element
+        latin:elementName="emojiCategory5"
+        latin:elementKeyboard="@xml/kbd_emoji_category5" />
+    <Element
+        latin:elementName="emojiCategory6"
+        latin:elementKeyboard="@xml/kbd_emoji_category6" />
+</KeyboardLayoutSet>
diff --git a/java/res/xml/keyboard_layout_set_pcqwerty.xml b/java/res/xml/keyboard_layout_set_pcqwerty.xml
index bffba05..67fbd91 100644
--- a/java/res/xml/keyboard_layout_set_pcqwerty.xml
+++ b/java/res/xml/keyboard_layout_set_pcqwerty.xml
@@ -25,9 +25,6 @@
         latin:elementKeyboard="@xml/kbd_pcqwerty"
         latin:enableProximityCharsCorrection="true" />
     <Element
-        latin:elementName="symbols"
-        latin:elementKeyboard="@xml/kbd_pcqwerty_symbols" />
-    <Element
         latin:elementName="phone"
         latin:elementKeyboard="@xml/kbd_phone" />
     <Element
diff --git a/java/res/xml/keys_pcqwerty2_right3.xml b/java/res/xml/keys_pcqwerty2_right3.xml
index 2065e6b..6f86477 100644
--- a/java/res/xml/keys_pcqwerty2_right3.xml
+++ b/java/res/xml/keys_pcqwerty2_right3.xml
@@ -27,25 +27,22 @@
         >
             <Key
                 latin:keyLabel="["
-                latin:moreKeys="{" />
+                latin:additionalMoreKeys="{" />
             <Key
                 latin:keyLabel="]"
-                latin:moreKeys="}" />
-            <!-- U+00A6: "¦" BROKEN BAR -->
+                latin:additionalMoreKeys="}" />
             <Key
                 latin:keyLabel="\\"
-                latin:moreKeys="\\|,&#x00A6;" />
+                latin:additionalMoreKeys="\\|" />
         </case>
-        <!-- keyboardLayoutSetElement="alphabet*Shifted|symbols*" -->
+        <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
         <default>
             <Key
                 latin:keyLabel="{" />
             <Key
                 latin:keyLabel="}" />
-            <!-- U+00A6: "¦" BROKEN BAR -->
             <Key
-                latin:keyLabel="|"
-                latin:moreKeys="&#x00A6;" />
+                latin:keyLabel="|" />
         </default>
     </switch>
 </merge>
diff --git a/java/res/xml/keys_pcqwerty3_right2.xml b/java/res/xml/keys_pcqwerty3_right2.xml
index aa150af..8da145b 100644
--- a/java/res/xml/keys_pcqwerty3_right2.xml
+++ b/java/res/xml/keys_pcqwerty3_right2.xml
@@ -27,12 +27,13 @@
         >
             <Key
                 latin:keyLabel=";"
-                latin:moreKeys=":" />
+                latin:additionalMoreKeys=":" />
             <Key
                 latin:keyLabel="\'"
-                latin:moreKeys="!fixedColumnOrder!4,!text/double_quotes,&quot;,!text/single_quotes" />
+                latin:additionalMoreKeys="&quot;"
+                latin:moreKeys="!fixedColumnOrder!4,!text/double_quotes,%,!text/single_quotes" />
         </case>
-        <!-- keyboardLayoutSetElement="alphabet*Shifted|symbols*" -->
+        <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
         <default>
             <Key
                 latin:keyLabel=":" />
diff --git a/java/res/xml/keys_pcqwerty4_right3.xml b/java/res/xml/keys_pcqwerty4_right3.xml
index 7795b3d..e6084cb 100644
--- a/java/res/xml/keys_pcqwerty4_right3.xml
+++ b/java/res/xml/keys_pcqwerty4_right3.xml
@@ -27,16 +27,16 @@
         >
             <Key
                 latin:keyLabel=","
-                latin:moreKeys="&lt;" />
+                latin:additionalMoreKeys="&lt;" />
             <Key
                 latin:keyLabel="."
-                latin:moreKeys="&gt;" />
-            <!-- U+00BF: "¿" INVERTED QUESTION MARK -->
+                latin:additionalMoreKeys="&gt;" />
             <Key
                 latin:keyLabel="/"
-                latin:moreKeys="\?,&#x00BF;" />
+                latin:additionalMoreKeys="\?"
+                latin:moreKeys="!text/more_keys_for_symbols_question" />
         </case>
-        <!-- keyboardLayoutSetElement="alphabet*Shifted|symbols*" -->
+        <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
         <default>
             <!-- U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
                  U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
@@ -50,10 +50,9 @@
             <Key
                 latin:keyLabel="&gt;"
                 latin:moreKeys="!fixedColumnOrder!3,&#x203A;,&#x2265;,&#x00BB;" />
-            <!-- U+00BF: "¿" INVERTED QUESTION MARK -->
             <Key
                 latin:keyLabel="\?"
-                latin:moreKeys="&#x00BF;" />
+                latin:moreKeys="!text/more_keys_for_symbols_question" />
         </default>
     </switch>
 </merge>
diff --git a/java/res/xml/keys_pcqwerty_symbols2.xml b/java/res/xml/keys_pcqwerty_symbols2.xml
deleted file mode 100644
index d0ea984..0000000
--- a/java/res/xml/keys_pcqwerty_symbols2.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2012, 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"
->
-    <!-- U+2022: "•" BULLET -->
-    <Key
-        latin:keyLabel="&#x2022;"
-        latin:moreKeys="!text/more_keys_for_bullet" />
-    <!-- U+00B1: "±" PLUS-MINUS SIGN -->
-    <Key
-        latin:keyLabel="&#x00B1;" />
-    <!-- U+00AC: "¬" NOT SIGN -->
-    <Key
-        latin:keyLabel="&#x00AC;" />
-    <!-- U+00A6: "¦" BROKEN BAR -->
-    <Key
-        latin:keyLabel="&#x00A6;" />
-    <!-- U+221A: "√" SQUARE ROOT -->
-    <Key
-        latin:keyLabel="&#x221A;" />
-    <!-- U+03C0: "π" GREEK SMALL LETTER PI
-         U+03A0: "Π" GREEK CAPITAL LETTER PI -->
-    <Key
-        latin:keyLabel="&#x03C0;"
-        latin:moreKeys="&#x03A0;" />
-    <!-- U+03CC: "σ" GREEK SMALL LETTER SIGMA
-         U+03A3: "Σ" GREEK CAPITAL LETTER SIGMA -->
-    <Key
-        latin:keyLabel="&#x03C3;"
-        latin:moreKeys="&#x03A3;" />
-    <!-- U+00B5: "µ" MICRO SIGN -->
-    <Key
-        latin:keyLabel="&#x00B5;" />
-    <!-- U+00F7: "÷" DIVISION SIGN -->
-    <Key
-        latin:keyLabel="&#x00F7;" />
-    <!-- U+00D7: "×" MULTIPLICATION SIGN -->
-    <Key
-        latin:keyLabel="&#x00D7;" />
-</merge>
diff --git a/java/res/xml/keys_pcqwerty_symbols3.xml b/java/res/xml/keys_pcqwerty_symbols3.xml
deleted file mode 100644
index 35279de..0000000
--- a/java/res/xml/keys_pcqwerty_symbols3.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2012, 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"
->
-    <!-- U+00A3: "£" POUND SIGN; -->
-    <Key
-        latin:keyLabel="&#x00A3;" />
-    <!-- U+00A2: "¢" CENT SIGN -->
-    <Key
-        latin:keyLabel="&#x00A2;" />
-    <!-- U+20AC: "€" EURO SIGN -->
-    <Key
-        latin:keyLabel="&#x20AC;" />
-    <!-- U+00A5: "¥" YEN SIGN -->
-    <Key
-        latin:keyLabel="&#x00A5;" />
-    <!-- U+00A4: "¤" CURRENCY SIGN -->
-    <Key
-        latin:keyLabel="&#x00A4;" />
-    <!-- U+00B0: "°" DEGREE SIGN
-         U+2032: "′" PRIME
-         U+2033: "″" DOUBLE PRIME -->
-    <Key
-        latin:keyLabel="&#x00B0;"
-        latin:moreKeys="&#x2032;,&#x2033;" />
-    <!-- U+2260: "≠" NOT EQUAL TO -->
-    <Key
-        latin:keyLabel="&#x2260;" />
-    <!-- U+2248: "≈" ALMOST EQUAL TO -->
-    <Key
-        latin:keyLabel="&#x2248;" />
-    <!-- U+221E: "∞" INFINITY -->
-    <Key
-        latin:keyLabel="&#x221E;" />
-</merge>
diff --git a/java/res/xml/keys_pcqwerty_symbols4.xml b/java/res/xml/keys_pcqwerty_symbols4.xml
deleted file mode 100644
index 3c628f0..0000000
--- a/java/res/xml/keys_pcqwerty_symbols4.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2012, 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"
->
-    <!-- U+2122: "™" TRADE MARK SIGN -->
-    <Key
-        latin:keyLabel="&#x2122;" />
-    <!-- U+00AE: "®" REGISTERED SIGN -->
-    <Key
-        latin:keyLabel="&#x00AE;" />
-    <!-- U+00A9: "©" COPYRIGHT SIGN -->
-    <Key
-        latin:keyLabel="&#x00A9;" />
-    <!-- U+00B6: "¶" PILCROW SIGN -->
-    <Key
-        latin:keyLabel="&#x00B6;" />
-    <!-- U+00A7: "§" SECTION SIGN -->
-    <Key
-        latin:keyLabel="&#x00A7;" />
-    <!-- U+2191: "↑" UPWARDS ARROW
-         U+2193: "↓" DOWNWARDS ARROW
-         U+2190: "←" LEFTWARDS ARROW
-         U+2192: "→" RIGHTWARDS ARROW -->
-    <Key
-        latin:keyLabel="&#x2191;"
-        latin:moreKeys="&#x2193;" />
-    <Key
-        latin:keyLabel="&#x2190;"
-        latin:moreKeys="&#x2192;" />
-</merge>
diff --git a/java/res/xml/row_pcqwerty5.xml b/java/res/xml/row_pcqwerty5.xml
index 7fbcd8e..0e61805 100644
--- a/java/res/xml/row_pcqwerty5.xml
+++ b/java/res/xml/row_pcqwerty5.xml
@@ -24,36 +24,23 @@
     <Row
         latin:keyWidth="7.692%p"
     >
-        <switch>
-            <case
-                latin:keyboardLayoutSetElement="symbols"
-            >
-                <Key
-                    latin:keyStyle="toAlphaKeyStyle"
-                    latin:keyWidth="11.538%p" />
-            </case>
-            <!-- keyboardLayoutSetElement="alphabet*" -->
-            <default>
-                <Key
-                    latin:keyStyle="toSymbolKeyStyle"
-                    latin:keyIcon="!icon/undefined"
-                    latin:keyLabel="!text/label_to_symbol_key_pcqwerty"
-                    latin:keyWidth="11.538%p" />
-            </default>
-        </switch>
+        <Spacer
+            latin:keyWidth="11.538%p" />
         <switch>
             <case
                 latin:shortcutKeyEnabled="true"
             >
                 <Key
-                    latin:keyStyle="shortcutKeyStyle" />
-            </case>
+                    latin:keyStyle="shortcutKeyStyle"
+                    latin:keyWidth="11.538%p" />
+                </case>
             <case
                 latin:clobberSettingsKey="false"
             >
                 <Key
-                    latin:keyStyle="settingsKeyStyle" />
-            </case>
+                    latin:keyStyle="settingsKeyStyle"
+                    latin:keyWidth="11.538%p" />
+                </case>
         </switch>
         <switch>
             <case
@@ -61,21 +48,33 @@
             >
                 <Key
                     latin:keyStyle="languageSwitchKeyStyle"
-                    latin:keyXPos="19.230%p" />
+                    latin:keyWidth="11.538%p" />
                 <Key
                     latin:keyStyle="spaceKeyStyle"
-                    latin:keyWidth="53.844%p" />
-            </case>
+                    latin:keyWidth="42.310%p" />
+                </case>
             <!-- languageSwitchKeyEnabled="false" -->
             <default>
                 <Key
                     latin:keyStyle="spaceKeyStyle"
-                    latin:keyXPos="19.230%p"
-                    latin:keyWidth="61.536%p" />
+                    latin:keyWidth="53.848%p" />
             </default>
         </switch>
         <Key
-            latin:keyStyle="enterKeyStyle"
-            latin:keyWidth="fillRight" />
+            latin:keyStyle="defaultEnterKeyStyle"
+            latin:keyWidth="15.384%p" />
+        <switch>
+            <case
+                latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
+            >
+                <Spacer />
+            </case>
+            <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
+            <default>
+                <include
+                    latin:keyboardLayout="@xml/key_symbols_period"
+                    latin:backgroundType="functional" />
+            </default>
+        </switch>
     </Row>
 </merge>
diff --git a/java/res/xml/rowkeys_pcqwerty1.xml b/java/res/xml/rowkeys_pcqwerty1.xml
index 2822d92..de548d0 100644
--- a/java/res/xml/rowkeys_pcqwerty1.xml
+++ b/java/res/xml/rowkeys_pcqwerty1.xml
@@ -21,67 +21,61 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <switch>
-        <case
-            latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
-        >
-            <!-- U+00AC: "¬" NOT SIGN -->
-            <Key
-                latin:keyLabel="`"
-                latin:moreKeys="~"
-                latin:additionalMoreKeys="&#x00AC;" />
-            <!-- U+00A1: "¡" NVERTED EXCLAMATION MARK -->
-            <Key
-                latin:keyLabel="1"
-                latin:additionalMoreKeys="!"
-                latin:moreKeys="&#x00A1;,!text/more_keys_for_symbols_1" />
-            <Key
-                latin:keyLabel="2"
-                latin:additionalMoreKeys="\@"
-                latin:moreKeys="!text/more_keys_for_symbols_2" />
-            <Key
-                latin:keyLabel="3"
-                latin:additionalMoreKeys="\#"
-                latin:moreKeys="!text/more_keys_for_symbols_3" />
-            <Key
-                latin:keyLabel="4"
-                latin:additionalMoreKeys="$"
-                latin:moreKeys="!text/more_keys_for_symbols_4" />
-            <Key
-                latin:keyLabel="5"
-                latin:additionalMoreKeys="\\%"
-                latin:moreKeys="!text/more_keys_for_symbols_5" />
-            <Key
-                latin:keyLabel="6"
-                latin:additionalMoreKeys="^"
-                latin:moreKeys="!text/more_keys_for_symbols_6" />
-            <Key
-                latin:keyLabel="7"
-                latin:additionalMoreKeys="&amp;"
-                latin:moreKeys="!text/more_keys_for_symbols_7" />
-            <Key
-                latin:keyLabel="8"
-                latin:additionalMoreKeys="*,%"
-                latin:moreKeys="!text/more_keys_for_symbols_8" />
-            <Key
-                latin:keyLabel="9"
-                latin:additionalMoreKeys="("
-                latin:moreKeys="!text/more_keys_for_symbols_9" />
-            <Key
-                latin:keyLabel="0"
-                latin:additionalMoreKeys=")"
-                latin:moreKeys="!text/more_keys_for_symbols_0" />
-            <Key
-                latin:keyLabel="-"
-                latin:moreKeys="_" />
-            <Key
-                latin:keyLabel="="
-                latin:moreKeys="+" />
-        </case>
-        <!-- keyboardLayoutSetElement="alphabet*Shifted|symbols" -->
-        <default>
-            <include
-                latin:keyboardLayout="@xml/keys_pcqwerty_symbols1" />
-        </default>
-    </switch>
+    <Key
+        latin:keyLabel="`"
+        latin:additionalMoreKeys="~" />
+    <Key
+        latin:keyLabel="1"
+        latin:additionalMoreKeys="!,!text/more_keys_for_symbols_exclamation"
+        latin:moreKeys="!text/more_keys_for_symbols_1" />
+    <Key
+        latin:keyLabel="2"
+        latin:additionalMoreKeys="\@"
+        latin:moreKeys="!text/more_keys_for_symbols_2" />
+    <Key
+        latin:keyLabel="3"
+        latin:additionalMoreKeys="\#"
+        latin:moreKeys="!text/more_keys_for_symbols_3" />
+    <Key
+        latin:keyLabel="4"
+        latin:additionalMoreKeys="$"
+        latin:moreKeys="!text/more_keys_for_symbols_4" />
+    <Key
+        latin:keyLabel="5"
+        latin:additionalMoreKeys="\\%"
+        latin:moreKeys="!text/more_keys_for_symbols_5" />
+    <Key
+        latin:keyLabel="6"
+        latin:additionalMoreKeys="^"
+        latin:moreKeys="!text/more_keys_for_symbols_6" />
+    <Key
+        latin:keyLabel="7"
+        latin:additionalMoreKeys="&amp;"
+        latin:moreKeys="!text/more_keys_for_symbols_7" />
+    <Key
+        latin:keyLabel="8"
+        latin:additionalMoreKeys="*"
+        latin:moreKeys="!text/more_keys_for_symbols_8" />
+    <Key
+        latin:keyLabel="9"
+        latin:additionalMoreKeys="("
+        latin:moreKeys="!text/more_keys_for_symbols_9" />
+    <Key
+        latin:keyLabel="0"
+        latin:additionalMoreKeys=")"
+        latin:moreKeys="!text/more_keys_for_symbols_0" />
+    <!-- U+2013: "–" EN DASH
+         U+2014: "—" EM DASH
+         U+00B7: "·" MIDDLE DOT -->
+    <Key
+        latin:keyLabel="-"
+        latin:additionalMoreKeys="_"
+        latin:moreKeys="&#x2013;,&#x2014;,&#x00B7;" />
+    <!-- U+221E: "∞" INFINITY
+         U+2260: "≠" NOT EQUAL TO
+         U+2248: "≈" ALMOST EQUAL TO -->
+    <Key
+        latin:keyLabel="="
+        latin:additionalMoreKeys="+"
+        latin:moreKeys="!fixedColumnOrder!4,&#x221E;,&#x2260;,&#x2248;,%" />
 </merge>
diff --git a/java/res/xml/keys_pcqwerty_symbols1.xml b/java/res/xml/rowkeys_pcqwerty1_shift.xml
similarity index 64%
rename from java/res/xml/keys_pcqwerty_symbols1.xml
rename to java/res/xml/rowkeys_pcqwerty1_shift.xml
index 2364e10..bc39f94 100644
--- a/java/res/xml/keys_pcqwerty_symbols1.xml
+++ b/java/res/xml/rowkeys_pcqwerty1_shift.xml
@@ -21,37 +21,40 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <!-- U+00AC: "¬" NOT SIGN -->
     <Key
-        latin:keyLabel="~"
-        latin:moreKeys="&#x00AC;" />
-    <!-- U+00A1: "¡" NVERTED EXCLAMATION MARK -->
+        latin:keyLabel="~" />
     <Key
         latin:keyLabel="!"
-        latin:moreKeys="&#x00A1;" />
+        latin:additionalMoreKeys="!text/more_keys_for_symbols_exclamation" />
     <Key
         latin:keyLabel="\@" />
     <Key
         latin:keyLabel="\#" />
     <Key
-        latin:keyLabel="$" />
-    <!-- U+2030: "‰" PER MILLE SIGN -->
+        latin:keyLabel="$"
+        latin:additionalMoreKeys="!text/more_keys_for_currency_dollar" />
     <Key
         latin:keyLabel="%"
-        latin:moreKeys="&#x2030;" />
+        latin:additionalMoreKeys="!text/more_keys_for_symbols_percent" />
     <Key
         latin:keyLabel="^" />
     <Key
         latin:keyLabel="&amp;" />
     <Key
         latin:keyLabel="*"
-        latin:moreKeys="!text/more_keys_for_star" />
+        latin:additionalMoreKeys="!text/more_keys_for_star" />
     <Key
         latin:keyLabel="(" />
     <Key
         latin:keyLabel=")" />
     <Key
         latin:keyLabel="_" />
+    <!-- U+00B1: "±" PLUS-MINUS SIGN
+         U+00D7: "×" MULTIPLICATION SIGN
+         U+00F7: "÷" DIVISION SIGN
+         U+221A: "√" SQUARE ROOT -->
     <Key
-        latin:keyLabel="+" />
+        latin:keyLabel="+"
+        latin:additionalMoreKeys="!text/more_keys_for_plus"
+        latin:moreKeys="&#x00B1;,&#x00D7;,&#x00F7;,&#x221A;" />
 </merge>
diff --git a/java/res/xml/rowkeys_pcqwerty2.xml b/java/res/xml/rowkeys_pcqwerty2.xml
index 2dfb653..8db704d 100644
--- a/java/res/xml/rowkeys_pcqwerty2.xml
+++ b/java/res/xml/rowkeys_pcqwerty2.xml
@@ -21,21 +21,11 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <switch>
-        <case
-            latin:keyboardLayoutSetElement="symbols"
-        >
-            <include
-                latin:keyboardLayout="@xml/keys_pcqwerty_symbols2" />
-        </case>
-        <default>
-            <!-- The keys on this PC layout row2 consist of the letters of QWERTY layout row1 and
-                 some symbols keys. -->
-            <include
-                latin:keyboardLayout="@xml/rowkeys_qwerty1"
-                latin:keyLabelFlags="disableAdditionalMoreKeys|disableKeyHintLabel" />
-        </default>
-    </switch>
+    <!-- The keys on this PC layout row2 consist of the letters of QWERTY layout row1 and
+         some symbols keys. -->
+    <include
+        latin:keyboardLayout="@xml/rowkeys_qwerty1"
+        latin:keyLabelFlags="disableAdditionalMoreKeys|disableKeyHintLabel" />
     <include
         latin:keyboardLayout="@xml/keys_pcqwerty2_right3" />
 </merge>
diff --git a/java/res/xml/rowkeys_pcqwerty3.xml b/java/res/xml/rowkeys_pcqwerty3.xml
index eca3362..ad122d3 100644
--- a/java/res/xml/rowkeys_pcqwerty3.xml
+++ b/java/res/xml/rowkeys_pcqwerty3.xml
@@ -21,20 +21,10 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <switch>
-        <case
-            latin:keyboardLayoutSetElement="symbols"
-        >
-            <include
-                latin:keyboardLayout="@xml/keys_pcqwerty_symbols3" />
-        </case>
-        <default>
-            <!-- The keys on this PC layout row3 consist of the letters of QWERTY layout row2 and
-                 some symbols keys. -->
-            <include
-                latin:keyboardLayout="@xml/rowkeys_qwerty2" />
-        </default>
-    </switch>
+    <!-- The keys on this PC layout row3 consist of the letters of QWERTY layout row2 and
+         some symbols keys. -->
+    <include
+        latin:keyboardLayout="@xml/rowkeys_qwerty2" />
     <include
         latin:keyboardLayout="@xml/keys_pcqwerty3_right2" />
 </merge>
diff --git a/java/res/xml/rowkeys_pcqwerty4.xml b/java/res/xml/rowkeys_pcqwerty4.xml
index f00baeb..b558f41 100644
--- a/java/res/xml/rowkeys_pcqwerty4.xml
+++ b/java/res/xml/rowkeys_pcqwerty4.xml
@@ -21,20 +21,10 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <switch>
-        <case
-            latin:keyboardLayoutSetElement="symbols"
-        >
-            <include
-                latin:keyboardLayout="@xml/keys_pcqwerty_symbols4" />
-        </case>
-        <default>
-            <!-- The keys on this PC layout row4 consist of the letters of QWERTY layout row3 and
-                 some symbols keys. -->
-            <include
-                latin:keyboardLayout="@xml/rowkeys_qwerty3" />
-        </default>
-    </switch>
+    <!-- The keys on this PC layout row4 consist of the letters of QWERTY layout row3 and
+         some symbols keys. -->
+    <include
+        latin:keyboardLayout="@xml/rowkeys_qwerty3" />
     <include
         latin:keyboardLayout="@xml/keys_pcqwerty4_right3" />
 </merge>
diff --git a/java/res/xml/rows_pcqwerty.xml b/java/res/xml/rows_pcqwerty.xml
index a5ed745..8846989 100644
--- a/java/res/xml/rows_pcqwerty.xml
+++ b/java/res/xml/rows_pcqwerty.xml
@@ -26,8 +26,19 @@
     <Row
         latin:keyWidth="7.692%p"
     >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty1" />
+        <switch>
+            <case
+                latin:keyboardLayoutSetElement="alphabet|alphabetAutomaticShifted"
+            >
+                <include
+                    latin:keyboardLayout="@xml/rowkeys_pcqwerty1" />
+            </case>
+            <!-- keyboardLayoutSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted" -->
+            <default>
+                <include
+                     latin:keyboardLayout="@xml/rowkeys_pcqwerty1_shift" />
+            </default>
+        </switch>
     </Row>
     <Row
         latin:keyWidth="7.692%p"
diff --git a/java/res/xml/rows_pcqwerty_symbols.xml b/java/res/xml/rows_pcqwerty_symbols.xml
deleted file mode 100644
index 195678e..0000000
--- a/java/res/xml/rows_pcqwerty_symbols.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2012, 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"
->
-    <include
-        latin:keyboardLayout="@xml/key_styles_common" />
-    <Row
-        latin:keyWidth="7.692%p"
-    >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty1" />
-    </Row>
-    <Row
-        latin:keyWidth="7.692%p"
-    >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty2" />
-    </Row>
-    <Row
-        latin:keyWidth="7.692%p"
-    >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty3"
-            latin:keyXPos="3.846%p" />
-        <Key
-            latin:keyStyle="deleteKeyStyle"
-            latin:keyWidth="fillRight"
-            latin:visualInsetsLeft="1%p" />
-    </Row>
-    <Row
-        latin:keyWidth="7.692%p"
-    >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_pcqwerty4"
-            latin:keyXPos="11.538%p" />
-    </Row>
-    <include
-        latin:keyboardLayout="@xml/row_pcqwerty5" />
-</merge>
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 0b3737e..23f037f 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -51,6 +51,11 @@
     /** Total width of the keyboard, including the padding and keys */
     public final int mOccupiedWidth;
 
+    /** Base height of the keyboard, used to calculate rows' height */
+    public final int mBaseHeight;
+    /** Base width of the keyboard, used to calculate keys' width */
+    public final int mBaseWidth;
+
     /** The padding above the keyboard */
     public final int mTopPadding;
     /** Default gap between rows */
@@ -84,6 +89,8 @@
         mThemeId = params.mThemeId;
         mOccupiedHeight = params.mOccupiedHeight;
         mOccupiedWidth = params.mOccupiedWidth;
+        mBaseHeight = params.mBaseHeight;
+        mBaseWidth = params.mBaseWidth;
         mMostCommonKeyHeight = params.mMostCommonKeyHeight;
         mMostCommonKeyWidth = params.mMostCommonKeyWidth;
         mMoreKeysTemplate = params.mMoreKeysTemplate;
@@ -109,6 +116,8 @@
         mThemeId = keyboard.mThemeId;
         mOccupiedHeight = keyboard.mOccupiedHeight;
         mOccupiedWidth = keyboard.mOccupiedWidth;
+        mBaseHeight = keyboard.mBaseHeight;
+        mBaseWidth = keyboard.mBaseWidth;
         mMostCommonKeyHeight = keyboard.mMostCommonKeyHeight;
         mMostCommonKeyWidth = keyboard.mMostCommonKeyWidth;
         mMoreKeysTemplate = keyboard.mMoreKeysTemplate;
diff --git a/java/src/com/android/inputmethod/keyboard/internal/CodesArrayParser.java b/java/src/com/android/inputmethod/keyboard/internal/CodesArrayParser.java
new file mode 100644
index 0000000..c10fdba
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/CodesArrayParser.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import com.android.inputmethod.latin.Constants;
+
+/**
+ * The string parser of codesArray specification for <GridRows />. The attribute codesArray is an
+ * array of string.
+ * Each element of the array defines a key label by specifying a code point as a hexadecimal string.
+ * A key label may consist of multiple code points separated by comma.
+ * Each element of the array optionally can have an output text definition after vertical bar
+ * marker. An output text may consist of multiple code points separated by comma.
+ * The format of the codesArray element should be:
+ * <pre>
+ *   codePointInHex[,codePoint2InHex]*(|outputTextCodePointInHex[,outputTextCodePoint2InHex]*)?
+ * </pre>
+ */
+// TODO: Write unit tests for this class.
+public final class CodesArrayParser {
+    // Constants for parsing.
+    private static final char COMMA = ',';
+    private static final char VERTICAL_BAR = '|';
+    private static final String COMMA_STRING = ",";
+    private static final int BASE_HEX = 16;
+
+    private CodesArrayParser() {
+     // This utility class is not publicly instantiable.
+    }
+
+    private static String getLabelSpec(final String codesArraySpec) {
+        final int pos = codesArraySpec.indexOf(VERTICAL_BAR);
+        return (pos < 0) ? codesArraySpec : codesArraySpec.substring(0, pos);
+    }
+
+    public static String parseLabel(final String codesArraySpec) {
+        final String labelSpec = getLabelSpec(codesArraySpec);
+        final StringBuilder sb = new StringBuilder();
+        for (final String codeInHex : labelSpec.split(COMMA_STRING)) {
+            final int codePoint = Integer.parseInt(codeInHex, BASE_HEX);
+            sb.appendCodePoint(codePoint);
+        }
+        return sb.toString();
+    }
+
+    private static String getCodeSpec(final String codesArraySpec) {
+        final int pos = codesArraySpec.indexOf(VERTICAL_BAR);
+        return (pos < 0) ? codesArraySpec : codesArraySpec.substring(pos + 1);
+    }
+
+    public static int parseCode(final String codesArraySpec) {
+        final String codeSpec = getCodeSpec(codesArraySpec);
+        if (codeSpec.indexOf(COMMA) < 0) {
+            return Integer.parseInt(codeSpec, BASE_HEX);
+        }
+        return Constants.CODE_OUTPUT_TEXT;
+    }
+
+    public static String parseOutputText(final String codesArraySpec) {
+        final String codeSpec = getCodeSpec(codesArraySpec);
+        if (codeSpec.indexOf(COMMA) < 0) {
+            return null;
+        }
+        final StringBuilder sb = new StringBuilder();
+        for (final String codeInHex : codeSpec.split(COMMA_STRING)) {
+            final int codePoint = Integer.parseInt(codeInHex, BASE_HEX);
+            sb.appendCodePoint(codePoint);
+        }
+        return sb.toString();
+    }
+}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
index 3f0773e..8c70389 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
@@ -29,6 +29,7 @@
 import com.android.inputmethod.keyboard.Key;
 import com.android.inputmethod.keyboard.Keyboard;
 import com.android.inputmethod.keyboard.KeyboardId;
+import com.android.inputmethod.latin.Constants;
 import com.android.inputmethod.latin.R;
 import com.android.inputmethod.latin.utils.ResourceUtils;
 import com.android.inputmethod.latin.utils.RunInLocale;
@@ -113,6 +114,7 @@
  * </pre>
  */
 
+// TODO: Write unit tests for this class.
 public class KeyboardBuilder<KP extends KeyboardParams> {
     private static final String BUILDER_TAG = "Keyboard.Builder";
     private static final boolean DEBUG = false;
@@ -120,6 +122,7 @@
     // Keyboard XML Tags
     private static final String TAG_KEYBOARD = "Keyboard";
     private static final String TAG_ROW = "Row";
+    private static final String TAG_GRID_ROWS = "GridRows";
     private static final String TAG_KEY = "Key";
     private static final String TAG_SPACER = "Spacer";
     private static final String TAG_INCLUDE = "include";
@@ -312,6 +315,9 @@
                         startRow(row);
                     }
                     parseRowContent(parser, row, skip);
+                } else if (TAG_GRID_ROWS.equals(tag)) {
+                    if (DEBUG) startTag("<%s>%s", TAG_GRID_ROWS, skip ? " skipped" : "");
+                    parseGridRows(parser, skip);
                 } else if (TAG_INCLUDE.equals(tag)) {
                     parseIncludeKeyboardContent(parser, skip);
                 } else if (TAG_SWITCH.equals(tag)) {
@@ -389,6 +395,73 @@
         }
     }
 
+    private void parseGridRows(final XmlPullParser parser, final boolean skip)
+            throws XmlPullParserException, IOException {
+        if (skip) {
+            XmlParseUtils.checkEndTag(TAG_GRID_ROWS, parser);
+            if (DEBUG) {
+                startEndTag("<%s /> skipped", TAG_GRID_ROWS);
+            }
+            return;
+        }
+        final KeyboardRow gridRows = new KeyboardRow(mResources, mParams, parser, mCurrentY);
+        final TypedArray gridRowAttr = mResources.obtainAttributes(
+                Xml.asAttributeSet(parser), R.styleable.Keyboard_GridRows);
+        final int codesArrayId = gridRowAttr.getResourceId(
+                R.styleable.Keyboard_GridRows_codesArray, 0);
+        final int textsArrayId = gridRowAttr.getResourceId(
+                R.styleable.Keyboard_GridRows_textsArray, 0);
+        gridRowAttr.recycle();
+        if (codesArrayId == 0 && textsArrayId == 0) {
+            throw new XmlParseUtils.ParseException(
+                    "Missing codesArray or textsArray attributes", parser);
+        }
+        if (codesArrayId != 0 && textsArrayId != 0) {
+            throw new XmlParseUtils.ParseException(
+                    "Both codesArray and textsArray attributes specifed", parser);
+        }
+        final String[] array = mResources.getStringArray(
+                codesArrayId != 0 ? codesArrayId : textsArrayId);
+        final int counts = array.length;
+        final float keyWidth = gridRows.getKeyWidth(null, 0.0f);
+        final int numColumns = (int)(mParams.mOccupiedWidth / keyWidth);
+        for (int index = 0; index < counts; index += numColumns) {
+            final KeyboardRow row = new KeyboardRow(mResources, mParams, parser, mCurrentY);
+            startRow(row);
+            for (int c = 0; c < numColumns; c++) {
+                final int i = index + c;
+                if (i >= counts) {
+                    break;
+                }
+                final String label;
+                final int code;
+                final String outputText;
+                if (codesArrayId != 0) {
+                    final String codeArraySpec = array[i];
+                    label = CodesArrayParser.parseLabel(codeArraySpec);
+                    code = CodesArrayParser.parseCode(codeArraySpec);
+                    outputText = CodesArrayParser.parseOutputText(codeArraySpec);
+                } else {
+                    final String textArraySpec = array[i];
+                    // TODO: Utilize KeySpecParser or write more generic TextsArrayParser.
+                    label = textArraySpec;
+                    code = Constants.CODE_OUTPUT_TEXT;
+                    outputText = textArraySpec + (char)Constants.CODE_SPACE;
+                }
+                final int x = (int)row.getKeyX(null);
+                final int y = row.getKeyY();
+                final Key key = new Key(mParams, label, null /* hintLabel */, 0 /* iconId */,
+                        code, outputText, x, y, (int)keyWidth, (int)row.getRowHeight(),
+                        row.getDefaultKeyLabelFlags(), row.getDefaultBackgroundType());
+                endKey(key);
+                row.advanceXPos(keyWidth);
+            }
+            endRow(row);
+        }
+
+        XmlParseUtils.checkEndTag(TAG_GRID_ROWS, parser);
+    }
+
     private void parseKey(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
             throws XmlPullParserException, IOException {
         if (skip) {
@@ -744,7 +817,10 @@
     }
 
     private void endKeyboard() {
-        // nothing to do here.
+        // {@link #parseGridRows(XmlPullParser,boolean)} may populate keyboard rows higher than
+        // previously expected.
+        final int actualHeight = mCurrentY - mParams.mVerticalGap + mParams.mBottomPadding;
+        mParams.mOccupiedHeight = Math.max(mParams.mOccupiedHeight, actualHeight);
     }
 
     private void addEdgeSpace(final float width, final KeyboardRow row) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
index 507080d..c6d652c 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java
@@ -231,25 +231,24 @@
         /* 126 */ "label_to_phone_symbols_key",
         /* 127 */ "label_time_am",
         /* 128 */ "label_time_pm",
-        /* 129 */ "label_to_symbol_key_pcqwerty",
-        /* 130 */ "keylabel_for_popular_domain",
-        /* 131 */ "more_keys_for_popular_domain",
-        /* 132 */ "more_keys_for_smiley",
-        /* 133 */ "single_laqm_raqm",
-        /* 134 */ "single_laqm_raqm_rtl",
-        /* 135 */ "single_raqm_laqm",
-        /* 136 */ "double_laqm_raqm",
-        /* 137 */ "double_laqm_raqm_rtl",
-        /* 138 */ "double_raqm_laqm",
-        /* 139 */ "single_lqm_rqm",
-        /* 140 */ "single_9qm_lqm",
-        /* 141 */ "single_9qm_rqm",
-        /* 142 */ "double_lqm_rqm",
-        /* 143 */ "double_9qm_lqm",
-        /* 144 */ "double_9qm_rqm",
-        /* 145 */ "more_keys_for_single_quote",
-        /* 146 */ "more_keys_for_double_quote",
-        /* 147 */ "more_keys_for_tablet_double_quote",
+        /* 129 */ "keylabel_for_popular_domain",
+        /* 130 */ "more_keys_for_popular_domain",
+        /* 131 */ "more_keys_for_smiley",
+        /* 132 */ "single_laqm_raqm",
+        /* 133 */ "single_laqm_raqm_rtl",
+        /* 134 */ "single_raqm_laqm",
+        /* 135 */ "double_laqm_raqm",
+        /* 136 */ "double_laqm_raqm_rtl",
+        /* 137 */ "double_raqm_laqm",
+        /* 138 */ "single_lqm_rqm",
+        /* 139 */ "single_9qm_lqm",
+        /* 140 */ "single_9qm_rqm",
+        /* 141 */ "double_lqm_rqm",
+        /* 142 */ "double_9qm_lqm",
+        /* 143 */ "double_9qm_rqm",
+        /* 144 */ "more_keys_for_single_quote",
+        /* 145 */ "more_keys_for_double_quote",
+        /* 146 */ "more_keys_for_tablet_double_quote",
     };
 
     private static final String EMPTY = "";
@@ -389,12 +388,10 @@
         /* 127 */ "AM",
         // Key label for "post meridiem"
         /* 128 */ "PM",
-        // Label for "switch to symbols" key on PC QWERTY layout
-        /* 129 */ "Sym",
-        /* 130 */ ".com",
+        /* 129 */ ".com",
         // popular web domains for the locale - most popular, displayed on the keyboard
-        /* 131 */ "!hasLabels!,.net,.org,.gov,.edu",
-        /* 132 */ "!fixedColumnOrder!5,!hasLabels!,=-O|=-O ,:-P|:-P ,;-)|;-) ,:-(|:-( ,:-)|:-) ,:-!|:-! ,:-$|:-$ ,B-)|B-) ,:O|:O ,:-*|:-* ,:-D|:-D ,:\'(|:\'( ,:-\\\\|:-\\\\ ,O:-)|O:-) ,:-[|:-[ ",
+        /* 130 */ "!hasLabels!,.net,.org,.gov,.edu",
+        /* 131 */ "!fixedColumnOrder!5,!hasLabels!,=-O|=-O ,:-P|:-P ,;-)|;-) ,:-(|:-( ,:-)|:-) ,:-!|:-! ,:-$|:-$ ,B-)|B-) ,:O|:O ,:-*|:-* ,:-D|:-D ,:\'(|:\'( ,:-\\\\|:-\\\\ ,O:-)|O:-) ,:-[|:-[ ",
         // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
         // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
         // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
@@ -416,24 +413,24 @@
         // The following each quotation mark pair consist of
         // <opening quotation mark>, <closing quotation mark>
         // and is named after (single|double)_<opening quotation mark>_<closing quotation mark>.
-        /* 133 */ "\u2039,\u203A",
-        /* 134 */ "\u2039|\u203A,\u203A|\u2039",
-        /* 135 */ "\u203A,\u2039",
-        /* 136 */ "\u00AB,\u00BB",
-        /* 137 */ "\u00AB|\u00BB,\u00BB|\u00AB",
-        /* 138 */ "\u00BB,\u00AB",
+        /* 132 */ "\u2039,\u203A",
+        /* 133 */ "\u2039|\u203A,\u203A|\u2039",
+        /* 134 */ "\u203A,\u2039",
+        /* 135 */ "\u00AB,\u00BB",
+        /* 136 */ "\u00AB|\u00BB,\u00BB|\u00AB",
+        /* 137 */ "\u00BB,\u00AB",
         // The following each quotation mark triplet consists of
         // <another quotation mark>, <opening quotation mark>, <closing quotation mark>
         // and is named after (single|double)_<opening quotation mark>_<closing quotation mark>.
-        /* 139 */ "\u201A,\u2018,\u2019",
-        /* 140 */ "\u2019,\u201A,\u2018",
-        /* 141 */ "\u2018,\u201A,\u2019",
-        /* 142 */ "\u201E,\u201C,\u201D",
-        /* 143 */ "\u201D,\u201E,\u201C",
-        /* 144 */ "\u201C,\u201E,\u201D",
-        /* 145 */ "!fixedColumnOrder!5,!text/single_quotes,!text/single_angle_quotes",
-        /* 146 */ "!fixedColumnOrder!5,!text/double_quotes,!text/double_angle_quotes",
-        /* 147 */ "!fixedColumnOrder!6,!text/double_quotes,!text/single_quotes,!text/double_angle_quotes,!text/single_angle_quotes",
+        /* 138 */ "\u201A,\u2018,\u2019",
+        /* 139 */ "\u2019,\u201A,\u2018",
+        /* 140 */ "\u2018,\u201A,\u2019",
+        /* 141 */ "\u201E,\u201C,\u201D",
+        /* 142 */ "\u201D,\u201E,\u201C",
+        /* 143 */ "\u201C,\u201E,\u201D",
+        /* 144 */ "!fixedColumnOrder!5,!text/single_quotes,!text/single_angle_quotes",
+        /* 145 */ "!fixedColumnOrder!5,!text/double_quotes,!text/double_angle_quotes",
+        /* 146 */ "!fixedColumnOrder!6,!text/double_quotes,!text/single_quotes,!text/double_angle_quotes,!text/single_angle_quotes",
     };
 
     /* Language af: Afrikaans */
diff --git a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml
index fa9739b..66172bd 100644
--- a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml
+++ b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml
@@ -197,8 +197,6 @@
     <string name="label_time_am">"AM"</string>
     <!-- Key label for "post meridiem" -->
     <string name="label_time_pm">"PM"</string>
-    <!-- Label for "switch to symbols" key on PC QWERTY layout -->
-    <string name="label_to_symbol_key_pcqwerty">Sym</string>
     <string name="keylabel_for_popular_domain">".com"</string>
     <!-- popular web domains for the locale - most popular, displayed on the keyboard -->
     <string name="more_keys_for_popular_domain">"!hasLabels!,.net,.org,.gov,.edu"</string>