Merge "Fix mini keyboard position"
diff --git a/java/res/values-sw768dp-land/dimens.xml b/java/res/values-sw768dp-land/dimens.xml
index 65fd29d..ce36145 100644
--- a/java/res/values-sw768dp-land/dimens.xml
+++ b/java/res/values-sw768dp-land/dimens.xml
@@ -24,8 +24,8 @@
     <fraction name="minKeyboardHeight">45%p</fraction>
     <!-- key_height + key_bottom_gap = popup_key_height -->
     <!-- <dimen name="key_height">14.5mm</dimen> -->
-    <dimen name="key_bottom_gap">0.0mm</dimen>
-    <dimen name="key_horizontal_gap">0.0mm</dimen>
+    <dimen name="key_bottom_gap">1.6mm</dimen>
+    <dimen name="key_horizontal_gap">1.6mm</dimen>
     <dimen name="popup_key_height">13.0mm</dimen>
     <dimen name="keyboard_top_padding">1.1mm</dimen>
     <dimen name="keyboard_bottom_padding">0.0mm</dimen>
diff --git a/java/res/values-sw768dp/dimens.xml b/java/res/values-sw768dp/dimens.xml
index 37cfc9d..cb380fb 100644
--- a/java/res/values-sw768dp/dimens.xml
+++ b/java/res/values-sw768dp/dimens.xml
@@ -24,8 +24,8 @@
     <fraction name="minKeyboardHeight">-35.0%p</fraction>
     <!-- key_height + key_bottom_gap = popup_key_height -->
     <!-- <dimen name="key_height">14.5mm</dimen> -->
-    <dimen name="key_bottom_gap">0.0mm</dimen>
-    <dimen name="key_horizontal_gap">0.0mm</dimen>
+    <dimen name="key_bottom_gap">1.1mm</dimen>
+    <dimen name="key_horizontal_gap">1.1mm</dimen>
     <dimen name="popup_key_height">10.0mm</dimen>
     <dimen name="keyboard_top_padding">1.1mm</dimen>
     <dimen name="keyboard_bottom_padding">0.0mm</dimen>
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 7473b42..5557dde 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -70,7 +70,7 @@
         <attr name="shadowRadius" format="float" />
         <attr name="backgroundDimAmount" format="float" />
 
-        <attr name="keyLetterStyle">
+        <attr name="keyLetterStyle" format="enum">
             <!-- This should be aligned with Typeface.NORMAL etc. -->
             <enum name="normal" value="0" />
             <enum name="bold" value="1" />
@@ -78,7 +78,7 @@
             <enum name="boldItalic" value="3" />
         </attr>
 
-        <attr name="colorScheme">
+        <attr name="colorScheme" format="enum">
             <!-- This should be aligned with KeyboardView.COLOR_SCHEME_* -->
             <enum name="white" value="0" />
             <enum name="black" value="1" />
@@ -125,7 +125,7 @@
         <!-- Maximum column of popup keyboard -->
         <attr name="maxPopupKeyboardColumn" format="integer" />
         <!-- Key edge flags. -->
-        <attr name="keyEdgeFlags">
+        <attr name="keyEdgeFlags" format="integer">
             <!-- Key is anchored to the left of the keyboard. -->
             <flag name="left" value="1" />
             <!-- Key is anchored to the right of the keyboard. -->
@@ -144,7 +144,7 @@
         <!-- The label to display on the key. -->
         <attr name="keyLabel" format="string" />
         <!-- The key label option -->
-        <attr name="keyLabelOption">
+        <attr name="keyLabelOption" format="integer">
             <!-- This should be aligned with KeyboardView.KEY_LABEL_OPTION_* -->
             <flag name="alignLeft" value="1" />
             <flag name="alignRight" value="2" />
@@ -176,7 +176,7 @@
 
     <declare-styleable name="Keyboard_Row">
         <!-- Row edge flags. -->
-        <attr name="rowEdgeFlags">
+        <attr name="rowEdgeFlags" format="integer">
             <!-- Row is anchored to the top of the keyboard. -->
             <flag name="top" value="4" />
             <!-- Row is anchored to the bottom of the keyboard. -->
@@ -190,7 +190,7 @@
 
     <declare-styleable name="Keyboard_Case">
         <!-- This should be aligned with KeyboardId.MODE_* -->
-        <attr name="mode">
+        <attr name="mode" format="enum|string">
             <enum name="text" value="0" />
             <enum name="url" value="1" />
             <enum name="email" value="2" />
@@ -203,17 +203,18 @@
         <attr name="hasSettingsKey" format="string" />
         <attr name="voiceKeyEnabled" format="string" />
         <attr name="hasVoiceKey" format="string" />
-        <attr name="imeAction">
+        <attr name="imeAction" format="enum">
             <!-- This should be aligned with EditorInfo.IME_ACTION_* -->
-            <flag name="actionUnspecified" value="0" />
-            <flag name="actionNone" value="1" />
-            <flag name="actionGo" value="2" />
-            <flag name="actionSearch" value="3" />
-            <flag name="actionSend" value="4" />
-            <flag name="actionNext" value="5" />
-            <flag name="actionDone" value="6" />
-            <flag name="actionPrevious" value="7" />
+            <enum name="actionUnspecified" value="0" />
+            <enum name="actionNone" value="1" />
+            <enum name="actionGo" value="2" />
+            <enum name="actionSearch" value="3" />
+            <enum name="actionSend" value="4" />
+            <enum name="actionNext" value="5" />
+            <enum name="actionDone" value="6" />
+            <enum name="actionPrevious" value="7" />
         </attr>
+        <attr name="localeCode" format="string" />
         <attr name="languageCode" format="string" />
         <attr name="countryCode" format="string" />
     </declare-styleable>
diff --git a/java/res/xml-ar/kbd_qwerty.xml b/java/res/xml-ar/kbd_qwerty.xml
index 93310bf..57823c9 100644
--- a/java/res/xml-ar/kbd_qwerty.xml
+++ b/java/res/xml-ar/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-cs/kbd_qwerty.xml b/java/res/xml-cs/kbd_qwerty.xml
index a74f7fa..9ead49c 100644
--- a/java/res/xml-cs/kbd_qwerty.xml
+++ b/java/res/xml-cs/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-de/kbd_qwerty.xml b/java/res/xml-de/kbd_qwerty.xml
index cc7722a..5c51bbd 100644
--- a/java/res/xml-de/kbd_qwerty.xml
+++ b/java/res/xml-de/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-es/kbd_qwerty.xml b/java/res/xml-es/kbd_qwerty.xml
index 3906bde..f986491 100644
--- a/java/res/xml-es/kbd_qwerty.xml
+++ b/java/res/xml-es/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-fr-rCA/kbd_qwerty.xml b/java/res/xml-fr-rCA/kbd_qwerty.xml
index e649a1e..7f25848 100644
--- a/java/res/xml-fr-rCA/kbd_qwerty.xml
+++ b/java/res/xml-fr-rCA/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-fr-rCH/kbd_qwerty.xml b/java/res/xml-fr-rCH/kbd_qwerty.xml
index f82becb..2baed3c 100644
--- a/java/res/xml-fr-rCH/kbd_qwerty.xml
+++ b/java/res/xml-fr-rCH/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-fr/kbd_qwerty.xml b/java/res/xml-fr/kbd_qwerty.xml
index 5d1f10c..1b10655 100644
--- a/java/res/xml-fr/kbd_qwerty.xml
+++ b/java/res/xml-fr/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-hu/kbd_qwerty.xml b/java/res/xml-hu/kbd_qwerty.xml
index 952ad9a..250b455 100644
--- a/java/res/xml-hu/kbd_qwerty.xml
+++ b/java/res/xml-hu/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-iw/kbd_qwerty.xml b/java/res/xml-iw/kbd_qwerty.xml
index cfe404c..e93927f 100644
--- a/java/res/xml-iw/kbd_qwerty.xml
+++ b/java/res/xml-iw/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-pl/kbd_qwerty.xml b/java/res/xml-pl/kbd_qwerty.xml
index ab5b887..7d9476d 100644
--- a/java/res/xml-pl/kbd_qwerty.xml
+++ b/java/res/xml-pl/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-pt/kbd_qwerty.xml b/java/res/xml-pt/kbd_qwerty.xml
index 83fb5b4..1a89955 100644
--- a/java/res/xml-pt/kbd_qwerty.xml
+++ b/java/res/xml-pt/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/res/xml-sw768dp/kbd_ar_rows.xml b/java/res/xml-sw768dp/kbd_ar_rows.xml
index daaa38e..c181002 100644
--- a/java/res/xml-sw768dp/kbd_ar_rows.xml
+++ b/java/res/xml-sw768dp/kbd_ar_rows.xml
@@ -27,12 +27,12 @@
     <include
         latin:keyboardLayout="@xml/kbd_key_styles" />
     <Row
-        latin:keyWidth="7.579%p"
+        latin:keyWidth="7.375%p"
     >
         <Key
             latin:keyStyle="tabKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="7.969%p"
+            latin:keyWidth="7.500%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="ض" />
@@ -61,17 +61,17 @@
             latin:popupCharacters="ج,چ" />
         <Key
             latin:keyStyle="deleteKeyStyle"
-            latin:keyXPos="-9.219%p"
+            latin:keyXPos="-11.500%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
     <Row
-        latin:keyWidth="7.500%p"
+        latin:keyWidth="7.375%p"
     >
         <Key
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="9.219%p"
+            latin:keyWidth="9.375%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="ش" />
@@ -101,16 +101,16 @@
             latin:keyLabel="ط" />
         <Key
             latin:keyStyle="returnKeyStyle"
-            latin:keyXPos="-15.704%p"
+            latin:keyXPos="-9.375%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
     <Row
-        latin:keyWidth="7.500%p"
+        latin:keyWidth="7.375%p"
     >
         <Key
             latin:keyStyle="shiftKeyStyle"
-            latin:keyWidth="9.219%p"
+            latin:keyWidth="12.750%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="ئ" />
@@ -135,11 +135,6 @@
             latin:keyLabel="ظ" />
         <Key
             latin:keyLabel="د" />
-        <Key
-            latin:keyStyle="shiftKeyStyle"
-            latin:keyXPos="-13.750%p"
-            latin:keyWidth="fillBoth"
-            latin:keyEdgeFlags="right" />
     </Row>
     <include latin:keyboardLayout="@xml/kbd_qwerty_row4" />
 </merge>
diff --git a/java/res/xml-sw768dp/kbd_iw_rows.xml b/java/res/xml-sw768dp/kbd_iw_rows.xml
index 33263f5..5275a1f 100644
--- a/java/res/xml-sw768dp/kbd_iw_rows.xml
+++ b/java/res/xml-sw768dp/kbd_iw_rows.xml
@@ -24,12 +24,11 @@
     <include
         latin:keyboardLayout="@xml/kbd_key_styles" />
     <Row
-        latin:keyWidth="8.282%p"
+        latin:keyWidth="8.000%p"
     >
         <Key
             latin:keyStyle="tabKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="7.969%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="," />
@@ -53,17 +52,17 @@
             latin:keyLabel="פ" />
         <Key
             latin:keyStyle="deleteKeyStyle"
-            latin:keyXPos="-9.219%p"
+            latin:keyXPos="-12.000%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
     <Row
-        latin:keyWidth="8.125%p"
+        latin:keyWidth="8.000%p"
     >
         <Key
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="10.167%p"
+            latin:keyWidth="9.600%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="ש" />
@@ -90,16 +89,16 @@
             latin:keyLabel="ף" />
         <Key
             latin:keyStyle="returnKeyStyle"
-            latin:keyXPos="-15.704%p"
+            latin:keyXPos="-10.400%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
     <Row
-        latin:keyWidth="8.047%p"
+        latin:keyWidth="8.000%p"
     >
         <Key
             latin:keyStyle="shiftKeyStyle"
-            latin:keyWidth="13.829%p"
+            latin:keyWidth="13.200%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="ז"
@@ -123,11 +122,6 @@
         <Key
             latin:keyLabel="ץ"
             latin:popupCharacters="ץ,ץ׳" />
-        <Key
-            latin:keyStyle="shiftKeyStyle"
-            latin:keyXPos="-13.750%p"
-            latin:keyWidth="fillBoth"
-            latin:keyEdgeFlags="right" />
     </Row>
     <include latin:keyboardLayout="@xml/kbd_qwerty_row4" />
 </merge>
diff --git a/java/res/xml-sw768dp/kbd_number.xml b/java/res/xml-sw768dp/kbd_number.xml
index 01c41a5..faab38a 100644
--- a/java/res/xml-sw768dp/kbd_number.xml
+++ b/java/res/xml-sw768dp/kbd_number.xml
@@ -24,7 +24,7 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="11.954%p"
+    latin:keyWidth="13.250%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
@@ -43,7 +43,7 @@
                 <Key
                     latin:keyStyle="tabKeyStyle"
                     latin:keyLabelOption="alignLeft"
-                    latin:keyWidth="7.969%p"
+                    latin:keyWidth="11.172%p"
                     latin:keyEdgeFlags="left" />
                 <Key
                     latin:keyStyle="num1KeyStyle"
@@ -54,7 +54,7 @@
                     latin:keyStyle="num3KeyStyle" />
                 <Key
                     latin:keyStyle="deleteKeyStyle"
-                    latin:keyXPos="-9.219%p"
+                    latin:keyXPos="-11.172%p"
                     latin:keyWidth="fillRight"
                     latin:keyEdgeFlags="right" />
             </Row>
@@ -68,7 +68,7 @@
                     latin:keyStyle="num6KeyStyle" />
                 <Key
                     latin:keyStyle="returnKeyStyle"
-                    latin:keyXPos="-15.704%p"
+                    latin:keyXPos="-11.172%p"
                     latin:keyWidth="fillRight"
                     latin:keyEdgeFlags="right" />
             </Row>
@@ -102,7 +102,7 @@
                 <Key
                     latin:keyStyle="tabKeyStyle"
                     latin:keyLabelOption="alignLeft"
-                    latin:keyWidth="7.969%p"
+                    latin:keyWidth="11.172%p"
                     latin:keyEdgeFlags="left" />
                 <Key
                     latin:keyLabel="-"
@@ -116,14 +116,14 @@
                     latin:keyWidth="8.047%p" />
                 <Key
                     latin:keyLabel="1"
-                    latin:keyXPos="45.000%p" />
+                    latin:keyXPos="43.125%p" />
                 <Key
                     latin:keyLabel="2" />
                 <Key
                     latin:keyLabel="3" />
                 <Key
                     latin:keyStyle="deleteKeyStyle"
-                    latin:keyXPos="-9.219%p"
+                    latin:keyXPos="-11.172%p"
                     latin:keyWidth="fillRight"
                     latin:keyEdgeFlags="right" />
             </Row>
@@ -140,14 +140,14 @@
                     latin:keyWidth="8.047%p" />
                 <Key
                     latin:keyLabel="4"
-                    latin:keyXPos="45.000%p" />
+                    latin:keyXPos="43.125%p" />
                 <Key
                     latin:keyLabel="5" />
                 <Key
                     latin:keyLabel="6" />
                 <Key
                     latin:keyStyle="returnKeyStyle"
-                    latin:keyXPos="-15.704%p"
+                    latin:keyXPos="-11.172%p"
                     latin:keyWidth="fillRight"
                     latin:keyEdgeFlags="right" />
             </Row>
@@ -167,7 +167,7 @@
                     latin:keyWidth="8.047%p" />
                 <Key
                     latin:keyLabel="7"
-                    latin:keyXPos="45.000%p" />
+                    latin:keyXPos="43.125%p" />
                 <Key
                     latin:keyLabel="8" />
                 <Key
@@ -191,7 +191,7 @@
                     latin:keyWidth="24.140%p" />
                 <Key
                     latin:keyLabel="*"
-                    latin:keyXPos="45.000%p" />
+                    latin:keyXPos="43.125%p" />
                 <Key
                     latin:keyLabel="0" />
                 <Key
diff --git a/java/res/xml-sw768dp/kbd_phone.xml b/java/res/xml-sw768dp/kbd_phone.xml
index 583239a..51627aa 100644
--- a/java/res/xml-sw768dp/kbd_phone.xml
+++ b/java/res/xml-sw768dp/kbd_phone.xml
@@ -24,7 +24,7 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="11.954%p"
+    latin:keyWidth="13.250%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
@@ -39,7 +39,7 @@
         <Key
             latin:keyStyle="tabKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="7.969%p"
+            latin:keyWidth="11.172%p"
             latin:keyEdgeFlags="left" />
         <!-- To match one character label size with "Tab", I placed spaces around the char '-'
              and '+'. -->
@@ -54,14 +54,14 @@
             latin:keyWidth="8.047%p" />
         <Key
             latin:keyStyle="num1KeyStyle"
-            latin:keyXPos="45.000%p" />
+            latin:keyXPos="43.125%p" />
         <Key
             latin:keyStyle="num2KeyStyle" />
         <Key
             latin:keyStyle="num3KeyStyle" />
         <Key
             latin:keyStyle="deleteKeyStyle"
-            latin:keyXPos="-9.219%p"
+            latin:keyXPos="-11.172%p"
             latin:keyWidth="fillRight"
             latin:keyEdgeFlags="right" />
     </Row>
@@ -83,14 +83,14 @@
             latin:keyWidth="8.047%p" />
         <Key
             latin:keyStyle="num4KeyStyle"
-            latin:keyXPos="45.000%p" />
+            latin:keyXPos="43.125%p" />
         <Key
             latin:keyStyle="num5KeyStyle" />
         <Key
             latin:keyStyle="num6KeyStyle" />
         <Key
             latin:keyStyle="returnKeyStyle"
-            latin:keyXPos="-15.704%p"
+            latin:keyXPos="-11.172%p"
             latin:keyWidth="fillRight"
             latin:keyEdgeFlags="right" />
     </Row>
@@ -110,7 +110,7 @@
             latin:keyWidth="8.047%p" />
         <Key
             latin:keyStyle="num7KeyStyle"
-            latin:keyXPos="45.000%p" />
+            latin:keyXPos="43.125%p" />
         <Key
             latin:keyStyle="num8KeyStyle" />
         <Key
@@ -133,7 +133,7 @@
             latin:keyWidth="16.084%p" />
         <Key
             latin:keyStyle="numStarKeyStyle"
-            latin:keyXPos="45.000%p" />
+            latin:keyXPos="43.125%p" />
         <Key
             latin:keyStyle="num0KeyStyle" />
         <Key
diff --git a/java/res/xml-sw768dp/kbd_phone_symbols.xml b/java/res/xml-sw768dp/kbd_phone_symbols.xml
index 714e5e5..b086b41 100644
--- a/java/res/xml-sw768dp/kbd_phone_symbols.xml
+++ b/java/res/xml-sw768dp/kbd_phone_symbols.xml
@@ -24,7 +24,7 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="11.954%p"
+    latin:keyWidth="13.250%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
@@ -39,7 +39,7 @@
         <Key
             latin:keyStyle="tabKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="7.969%p"
+            latin:keyWidth="11.172%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:code="45"
@@ -58,14 +58,14 @@
              char '-' and '+'. -->
         <Key
             latin:keyStyle="num1KeyStyle"
-            latin:keyXPos="45.000%p" />
+            latin:keyXPos="43.125%p" />
         <Key
             latin:keyStyle="num2KeyStyle" />
         <Key
             latin:keyStyle="num3KeyStyle" />
         <Key
             latin:keyStyle="deleteKeyStyle"
-            latin:keyXPos="-9.219%p"
+            latin:keyXPos="-11.172%p"
             latin:keyWidth="fillRight"
             latin:keyEdgeFlags="right" />
     </Row>
@@ -91,14 +91,14 @@
              char ',' and '.'. -->
         <Key
             latin:keyStyle="num4KeyStyle"
-            latin:keyXPos="45.000%p" />
+            latin:keyXPos="43.125%p" />
         <Key
             latin:keyStyle="num5KeyStyle" />
         <Key
             latin:keyStyle="num6KeyStyle" />
         <Key
             latin:keyStyle="returnKeyStyle"
-            latin:keyXPos="-15.704%p"
+            latin:keyXPos="-11.172%p"
             latin:keyWidth="fillRight"
             latin:keyEdgeFlags="right" />
     </Row>
@@ -122,7 +122,7 @@
             latin:keyWidth="8.047%p" />
         <Key
             latin:keyStyle="num7KeyStyle"
-            latin:keyXPos="45.000%p" />
+            latin:keyXPos="43.125%p" />
         <Key
             latin:keyStyle="num8KeyStyle" />
         <Key
@@ -145,7 +145,7 @@
             latin:keyWidth="24.140%p" />
         <Key
             latin:keyStyle="numStarKeyStyle"
-            latin:keyXPos="45.000%p" />
+            latin:keyXPos="43.125%p" />
         <Key
             latin:keyStyle="num0KeyStyle" />
         <Key
diff --git a/java/res/xml-sw768dp/kbd_qwerty_row3.xml b/java/res/xml-sw768dp/kbd_qwerty_row3.xml
index 7d59dfb..7297ea5 100644
--- a/java/res/xml-sw768dp/kbd_qwerty_row3.xml
+++ b/java/res/xml-sw768dp/kbd_qwerty_row3.xml
@@ -46,30 +46,8 @@
             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:manualTemporaryUpperCaseCode="33"
-                    latin:keyHintIcon="@drawable/key_hint_exclamation_holo"
-                    latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_exclamation_large_holo"
-                    latin:popupCharacters="!" />
-                <Key
-                    latin:keyLabel="."
-                    latin:manualTemporaryUpperCaseCode="63"
-                    latin:keyHintIcon="@drawable/key_hint_question_holo"
-                    latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_question_large_holo"
-                    latin:popupCharacters="\?" />
-            </default>
-        </switch>
+        <include
+            latin:keyboardLayout="@xml/kbd_row3_right2" />
         <Key
             latin:keyStyle="shiftKeyStyle"
             latin:keyXPos="-13.750%p"
diff --git a/java/res/xml-sw768dp/kbd_qwerty_row4.xml b/java/res/xml-sw768dp/kbd_qwerty_row4.xml
index b24ea5e..0e71cbf 100644
--- a/java/res/xml-sw768dp/kbd_qwerty_row4.xml
+++ b/java/res/xml-sw768dp/kbd_qwerty_row4.xml
@@ -26,7 +26,9 @@
         latin:keyWidth="8.047%p"
     >
         <switch>
-            <case latin:hasSettingsKey="true">
+            <case
+                latin:hasSettingsKey="true"
+            >
                 <Key
                     latin:keyStyle="settingsKeyStyle"
                     latin:keyWidth="8.047%p" />
@@ -37,10 +39,14 @@
             latin:keyWidth="fillRight" />
         <switch>
             <case
-                latin:languageCode="ru"
+                latin:mode="url"
             >
+                <Key
+                    latin:keyStyle="comKeyStyle"
+                    latin:keyWidth="16.084%p" />
+            </case>
+            <default>
                 <switch>
-                    <!-- TODO: implement logical OR for <case> attribute -->
                     <case
                         latin:mode="email"
                     >
@@ -48,12 +54,6 @@
                             latin:keyStyle="comKeyStyle" />
                     </case>
                     <case
-                        latin:mode="url"
-                    >
-                        <Key
-                            latin:keyStyle="comKeyStyle" />
-                    </case>
-                    <case
                         latin:imeAction="actionSearch"
                     >
                         <Key
@@ -75,16 +75,6 @@
                         <Key
                             latin:keyLabel="\@" />
                     </case>
-                    <case
-                        latin:mode="url"
-                    >
-                        <Key
-                            latin:keyLabel="-"
-                            latin:manualTemporaryUpperCaseCode="95"
-                            latin:keyHintIcon="@drawable/key_hint_underline_holo"
-                            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_underline_large_holo"
-                            latin:popupCharacters="_" />
-                    </case>
                     <default>
                         <Key
                             latin:keyLabel="/"
@@ -94,58 +84,6 @@
                             latin:popupCharacters="\@" />
                     </default>
                 </switch>
-            </case>
-            <!-- not languageCode="ru" -->
-            <default>
-                <switch>
-                    <case
-                        latin:mode="url"
-                    >
-                        <Key
-                            latin:keyStyle="comKeyStyle"
-                            latin:keyWidth="16.084%p" />
-                    </case>
-                    <default>
-                        <switch>
-                            <case
-                                latin:mode="email"
-                            >
-                                <Key
-                                    latin:keyStyle="comKeyStyle" />
-                            </case>
-                            <case
-                                latin:imeAction="actionSearch"
-                            >
-                                <Key
-                                    latin:keyLabel=":"
-                                    latin:manualTemporaryUpperCaseCode="43"
-                                    latin:keyHintIcon="@drawable/key_hint_plus_holo"
-                                    latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_plus_large_holo"
-                                    latin:popupCharacters="+" />
-                            </case>
-                            <default>
-                                <Key
-                                    latin:keyStyle="smileyKeyStyle" />
-                            </default>
-                        </switch>
-                        <switch>
-                            <case
-                                latin:mode="email"
-                            >
-                                <Key
-                                    latin:keyLabel="\@" />
-                            </case>
-                            <default>
-                                <Key
-                                    latin:keyLabel="/"
-                                    latin:manualTemporaryUpperCaseCode="64"
-                                    latin:keyHintIcon="@drawable/key_hint_at_holo"
-                                    latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_at_large_holo"
-                                    latin:popupCharacters="\@" />
-                            </default>
-                        </switch>
-                    </default>
-                </switch>
             </default>
         </switch>
         <Key
@@ -154,95 +92,44 @@
             latin:keyWidth="37.500%p" />
         <switch>
             <case
-                latin:languageCode="ru"
+                latin:mode="email"
             >
-                <switch>
-                    <case
-                        latin:mode="email"
-                    >
-                        <Key
-                            latin:keyLabel="-" />
-                    </case>
-                    <case
-                        latin:mode="url"
-                    >
-                        <Key
-                            latin:keyLabel="/"
-                            latin:manualTemporaryUpperCaseCode="58"
-                            latin:keyHintIcon="@drawable/key_hint_colon_holo"
-                            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_colon_large_holo"
-                            latin:popupCharacters=":" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:keyLabel="\?"
-                            latin:manualTemporaryUpperCaseCode="95"
-                            latin:keyHintIcon="@drawable/key_hint_underline_holo"
-                            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_underline_large_holo"
-                            latin:popupCharacters="_" />
-                    </default>
-                </switch>
-                <switch>
-                    <case
-                        latin:mode="email"
-                    >
-                        <Key
-                            latin:keyLabel="_" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:keyLabel="!"
-                            latin:manualTemporaryUpperCaseCode="34"
-                            latin:keyHintIcon="@drawable/key_hint_quote_holo"
-                            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_quote_large_holo"
-                            latin:popupCharacters="\'" />
-                    </default>
-                </switch>
+                <Key
+                    latin:keyLabel="-" />
             </case>
-            <!-- not languageCode="ru" -->
+            <case
+                latin:mode="url"
+            >
+                <Key
+                    latin:keyLabel="/"
+                    latin:manualTemporaryUpperCaseCode="58"
+                    latin:keyHintIcon="@drawable/key_hint_colon_holo"
+                    latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_colon_large_holo"
+                    latin:popupCharacters=":" />
+            </case>
             <default>
-                <switch>
-                    <case
-                        latin:mode="email"
-                    >
-                        <Key
-                            latin:keyLabel="-" />
-                    </case>
-                    <case
-                        latin:mode="url"
-                    >
-                        <Key
-                            latin:keyLabel="/"
-                            latin:manualTemporaryUpperCaseCode="58"
-                            latin:keyHintIcon="@drawable/key_hint_colon_holo"
-                            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_colon_large_holo"
-                            latin:popupCharacters=":" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:keyLabel="\'"
-                            latin:manualTemporaryUpperCaseCode="34"
-                            latin:keyHintIcon="@drawable/key_hint_quote_holo"
-                            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_quote_large_holo"
-                            latin:popupCharacters="&quot;" />
-                    </default>
-                </switch>
-                <switch>
-                    <case
-                        latin:mode="email"
-                    >
-                        <Key
-                            latin:keyLabel="_" />
-                    </case>
-                    <default>
-                        <Key
-                            latin:keyLabel="-"
-                            latin:manualTemporaryUpperCaseCode="95"
-                            latin:keyHintIcon="@drawable/key_hint_underline_holo"
-                            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_underline_large_holo"
-                            latin:popupCharacters="_" />
-                    </default>
-                </switch>
+                <Key
+                    latin:keyLabel="\'"
+                    latin:manualTemporaryUpperCaseCode="34"
+                    latin:keyHintIcon="@drawable/key_hint_quote_holo"
+                    latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_quote_large_holo"
+                    latin:popupCharacters="&quot;" />
+            </default>
+        </switch>
+        <switch>
+            <case
+                latin:mode="email"
+            >
+                <Key
+                    latin:keyLabel="_" />
+            </case>
+            <default>
+                <Key
+                    latin:keyLabel="-"
+                    latin:manualTemporaryUpperCaseCode="95"
+                    latin:keyHintIcon="@drawable/key_hint_underline_holo"
+                    latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_underline_large_holo"
+                    latin:popupCharacters="_" />
             </default>
         </switch>
         <switch>
diff --git a/java/res/xml-sw768dp/kbd_qwerty_rows_scandinavia.xml b/java/res/xml-sw768dp/kbd_qwerty_rows_scandinavia.xml
index b887528..7e9f604 100644
--- a/java/res/xml-sw768dp/kbd_qwerty_rows_scandinavia.xml
+++ b/java/res/xml-sw768dp/kbd_qwerty_rows_scandinavia.xml
@@ -24,12 +24,12 @@
     <include
         latin:keyboardLayout="@xml/kbd_key_styles" />
     <Row
-        latin:keyWidth="7.579%p"
+        latin:keyWidth="7.375%p"
     >
         <Key
             latin:keyStyle="tabKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="7.969%p"
+            latin:keyWidth="7.500%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="q"
@@ -65,17 +65,17 @@
             latin:keyLabel="å" />
         <Key
             latin:keyStyle="deleteKeyStyle"
-            latin:keyXPos="-9.219%p"
+            latin:keyXPos="-11.500%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
     <Row
-        latin:keyWidth="7.500%p"
+        latin:keyWidth="7.375%p"
     >
         <Key
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="7.969%p"
+            latin:keyWidth="9.375%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="a"
@@ -109,12 +109,43 @@
             latin:popupCharacters="@string/alternates_for_scandinavia_row2_11" />
         <Key
             latin:keyStyle="returnKeyStyle"
-            latin:keyXPos="-15.704%p"
+            latin:keyXPos="-9.375%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
-    <include
-        latin:keyboardLayout="@xml/kbd_qwerty_row3" />
+    <Row
+        latin:keyWidth="7.375%p"
+    >
+        <Key
+            latin:keyStyle="shiftKeyStyle"
+            latin:keyWidth="12.750%p"
+            latin:keyEdgeFlags="left" />
+        <Key
+            latin:keyLabel="z"
+            latin:popupCharacters="@string/alternates_for_z" />
+        <Key
+            latin:keyLabel="x" />
+        <Key
+            latin:keyLabel="c"
+            latin:popupCharacters="@string/alternates_for_c" />
+        <Key
+            latin:keyLabel="v"
+            latin:popupCharacters="@string/alternates_for_v" />
+        <Key
+            latin:keyLabel="b" />
+        <Key
+            latin:keyLabel="n"
+            latin:popupCharacters="@string/alternates_for_n" />
+        <Key
+            latin:keyLabel="m" />
+        <include
+            latin:keyboardLayout="@xml/kbd_row3_right2" />
+        <Key
+            latin:keyStyle="shiftKeyStyle"
+            latin:keyXPos="-12.750%p"
+            latin:keyWidth="fillRight"
+            latin:keyEdgeFlags="right" />
+    </Row>
     <include
         latin:keyboardLayout="@xml/kbd_qwerty_row4" />
 </merge>
diff --git a/java/res/xml-sw768dp/kbd_row3_right2.xml b/java/res/xml-sw768dp/kbd_row3_right2.xml
new file mode 100644
index 0000000..1759ea1
--- /dev/null
+++ b/java/res/xml-sw768dp/kbd_row3_right2.xml
@@ -0,0 +1,48 @@
+<?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"
+>
+    <switch>
+        <case
+            latin:mode="email"
+        >
+            <Key
+                latin:keyLabel="," />
+            <Key
+                latin:keyLabel="." />
+        </case>
+        <default>
+            <Key
+                latin:keyLabel=","
+                latin:manualTemporaryUpperCaseCode="33"
+                latin:keyHintIcon="@drawable/key_hint_exclamation_holo"
+                latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_exclamation_large_holo"
+                latin:popupCharacters="!" />
+            <Key
+                latin:keyLabel="."
+                latin:manualTemporaryUpperCaseCode="63"
+                latin:keyHintIcon="@drawable/key_hint_question_holo"
+                latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_question_large_holo"
+                latin:popupCharacters="\?" />
+        </default>
+    </switch>
+</merge>
diff --git a/java/res/xml-sw768dp/kbd_ru_rows.xml b/java/res/xml-sw768dp/kbd_ru_rows.xml
index 3849141..ee91481 100644
--- a/java/res/xml-sw768dp/kbd_ru_rows.xml
+++ b/java/res/xml-sw768dp/kbd_ru_rows.xml
@@ -25,12 +25,11 @@
         latin:keyboardLayout="@xml/kbd_key_styles" />
     <!-- This row is intentionally not marked as a top row -->
     <Row
-        latin:keyWidth="7.579%p"
+        latin:keyWidth="7.125%p"
     >
         <Key
             latin:keyStyle="tabKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="7.969%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="й" />
@@ -56,18 +55,19 @@
         <Key
             latin:keyLabel="х" />
         <Key
+            latin:keyLabel="ъ" />
+        <Key
             latin:keyStyle="deleteKeyStyle"
-            latin:keyXPos="-9.219%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
     <Row
-        latin:keyWidth="7.500%p"
+        latin:keyWidth="7.125%p"
     >
         <Key
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="9.219%p"
+            latin:keyWidth="9.375%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="ф" />
@@ -93,16 +93,16 @@
             latin:keyLabel="э" />
         <Key
             latin:keyStyle="returnKeyStyle"
-            latin:keyXPos="-15.704%p"
+            latin:keyXPos="-9.375%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
     <Row
-        latin:keyWidth="7.500%p"
+        latin:keyWidth="7.125%p"
     >
         <Key
             latin:keyStyle="shiftKeyStyle"
-            latin:keyWidth="12.400%p"
+            latin:keyWidth="12.750%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="я" />
@@ -117,21 +117,15 @@
         <Key
             latin:keyLabel="т" />
         <Key
-            latin:keyLabel="ь"
-            latin:popupCharacters="@string/alternates_for_cyrillic_soft_sign" />
+            latin:keyLabel="ь" />
         <Key
             latin:keyLabel="б" />
         <Key
             latin:keyLabel="ю" />
-        <Key
-            latin:keyLabel="."
-            latin:manualTemporaryUpperCaseCode="44"
-            latin:keyHintIcon="@drawable/key_hint_comma_holo"
-            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_comma_large_holo"
-            latin:popupCharacters="," />
+        <include
+            latin:keyboardLayout="@xml/kbd_row3_right2" />
         <Key
             latin:keyStyle="shiftKeyStyle"
-            latin:keyXPos="-13.750%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
diff --git a/java/res/xml-sw768dp/kbd_sr_rows.xml b/java/res/xml-sw768dp/kbd_sr_rows.xml
index fbf1e9b..4997dab 100644
--- a/java/res/xml-sw768dp/kbd_sr_rows.xml
+++ b/java/res/xml-sw768dp/kbd_sr_rows.xml
@@ -25,12 +25,11 @@
         latin:keyboardLayout="@xml/kbd_key_styles" />
     <!-- This row is intentionally not marked as a top row -->
     <Row
-        latin:keyWidth="7.579%p"
+        latin:keyWidth="7.125%p"
     >
         <Key
             latin:keyStyle="tabKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="7.969%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="љ" />
@@ -55,18 +54,19 @@
         <Key
             latin:keyLabel="ш" />
         <Key
-            latin:keyStyle="deleteKeyStyle"
-            latin:keyXPos="-9.219%p"
-            latin:keyWidth="fillBoth"
-            latin:keyEdgeFlags="right" />
+            latin:keyLabel="ђ" />
+        <Key
+            latin:keyLabel="ж"
+            latin:keyWidth="fillRight"
+            latin:keyEdgeFlags="right"/>
     </Row>
     <Row
-        latin:keyWidth="7.500%p"
+        latin:keyWidth="7.250%p"
     >
         <Key
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyLabelOption="alignLeft"
-            latin:keyWidth="9.219%p"
+            latin:keyWidth="11.172%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="а" />
@@ -91,17 +91,17 @@
         <Key
             latin:keyLabel="ћ" />
         <Key
-            latin:keyStyle="returnKeyStyle"
-            latin:keyXPos="-15.704%p"
+            latin:keyStyle="deleteKeyStyle"
+            latin:keyXPos="-9.219%p"
             latin:keyWidth="fillBoth"
             latin:keyEdgeFlags="right" />
     </Row>
     <Row
-        latin:keyWidth="7.500%p"
+        latin:keyWidth="7.250%p"
     >
         <Key
             latin:keyStyle="shiftKeyStyle"
-            latin:keyWidth="9.219%p"
+            latin:keyWidth="13.829%p"
             latin:keyEdgeFlags="left" />
         <Key
             latin:keyLabel="ѕ" />
@@ -117,26 +117,12 @@
             latin:keyLabel="н" />
         <Key
             latin:keyLabel="м" />
+        <include
+            latin:keyboardLayout="@xml/kbd_row3_right2" />
         <Key
-            latin:keyLabel="ђ" />
-        <Key
-            latin:keyLabel="ж" />
-        <Key
-            latin:keyLabel=","
-            latin:manualTemporaryUpperCaseCode="33"
-            latin:keyHintIcon="@drawable/key_hint_exclamation_holo"
-            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_exclamation_large_holo"
-            latin:popupCharacters="!" />
-        <Key
-            latin:keyLabel="."
-            latin:manualTemporaryUpperCaseCode="63"
-            latin:keyHintIcon="@drawable/key_hint_question_holo"
-            latin:manualTemporaryUpperCaseHintIcon="@drawable/key_hint_question_large_holo"
-            latin:popupCharacters="\?" />
-        <Key
-            latin:keyStyle="shiftKeyStyle"
+            latin:keyStyle="returnKeyStyle"
             latin:keyXPos="-13.750%p"
-            latin:keyWidth="fillBoth"
+            latin:keyWidth="fillRight"
             latin:keyEdgeFlags="right" />
     </Row>
     <include
diff --git a/java/res/xml-sw768dp/kbd_symbols.xml b/java/res/xml-sw768dp/kbd_symbols.xml
index 26cf1ac..5b359bf 100644
--- a/java/res/xml-sw768dp/kbd_symbols.xml
+++ b/java/res/xml-sw768dp/kbd_symbols.xml
@@ -72,7 +72,7 @@
         <Key
             latin:keyStyle="deleteKeyStyle"
             latin:keyXPos="-9.219%p"
-            latin:keyWidth="fillBoth"
+            latin:keyWidth="fillRight"
             latin:keyEdgeFlags="right" />
     </Row>
     <Row
@@ -131,12 +131,6 @@
             latin:popupCharacters="≠,≈" />
         <switch>
             <case
-                latin:languageCode="ru"
-            >
-                <Key
-                    latin:keyLabel=":" />
-            </case>
-            <case
                 latin:mode="url"
             >
                 <Key
@@ -150,36 +144,16 @@
         </switch>
         <Key
             latin:keyLabel=";" />
-        <switch>
-            <case
-                latin:languageCode="ru"
-            >
-                <Key
-                    latin:keyLabel="\'"
-                    latin:popupCharacters="‘,’,‚,‛" />
-                <!-- Note: DroidSans doesn't have double-high-reversed-quotation '\u201f' glyph. -->
-                <!-- latin:popupCharacters="“,”,„,‟,«,»" -->
-                <Key
-                    latin:keyLabel="&quot;"
-                    latin:popupCharacters="“,”,«,»" />
-                <Key
-                    latin:keyLabel="." />
-                <Key
-                    latin:keyLabel="," />
-            </case>
-            <default>
-                <Key
-                    latin:keyLabel="," />
-                <Key
-                    latin:keyLabel="." />
-                <Key
-                    latin:keyLabel="!"
-                    latin:popupCharacters="¡" />
-                <Key
-                    latin:keyLabel="\?"
-                    latin:popupCharacters="¿" />
-            </default>
-        </switch>
+        <Key
+            latin:keyLabel="," />
+        <Key
+            latin:keyLabel="." />
+        <Key
+            latin:keyLabel="!"
+            latin:popupCharacters="¡" />
+        <Key
+            latin:keyLabel="\?"
+            latin:popupCharacters="¿" />
         <Key
             latin:keyStyle="moreKeyStyle"
             latin:keyXPos="-13.750%p"
@@ -191,7 +165,9 @@
         latin:keyWidth="8.047%p"
     >
         <switch>
-            <case latin:hasSettingsKey="true">
+            <case
+                latin:hasSettingsKey="true"
+            >
                 <Key
                     latin:keyStyle="settingsKeyStyle"
                     latin:keyWidth="8.047%p" />
@@ -206,25 +182,13 @@
             latin:keyStyle="spaceKeyStyle"
             latin:keyXPos="31.250%p"
             latin:keyWidth="37.500%p" />
-        <switch>
-            <case
-                latin:languageCode="ru"
-            >
-                <Key
-                    latin:keyLabel="_" />
-                <Key
-                    latin:keyLabel="-" />
-            </case>
-            <default>
-                <!-- Note: DroidSans doesn't have double-high-reversed-quotation '\u201f' glyph. -->
-                <!-- latin:popupCharacters="“,”,„,‟,«,»,‘,’,‚,‛" -->
-                <Key
-                    latin:keyLabel="&quot;"
-                    latin:popupCharacters="“,”,«,»,‘,’,‚,‛" />
-                <Key
-                    latin:keyLabel="_" />
-            </default>
-        </switch>
+        <!-- Note: DroidSans doesn't have double-high-reversed-quotation '\u201f' glyph. -->
+        <!-- latin:popupCharacters="“,”,„,‟,«,»,‘,’,‚,‛" -->
+        <Key
+            latin:keyLabel="&quot;"
+            latin:popupCharacters="“,”,«,»,‘,’,‚,‛" />
+        <Key
+            latin:keyLabel="_" />
         <switch>
             <case
                 latin:voiceKeyEnabled="true"
diff --git a/java/res/xml/kbd_currency_key_styles.xml b/java/res/xml/kbd_currency_key_styles.xml
index b30dd64..9d3bb47 100644
--- a/java/res/xml/kbd_currency_key_styles.xml
+++ b/java/res/xml/kbd_currency_key_styles.xml
@@ -27,229 +27,59 @@
         >
             <key-style
                 latin:styleName="currencyKeyStyle"
-                latin:keyLabel="$"
-                latin:popupCharacters="@string/alternates_for_currency_dollar" />
+                latin:keyLabel="$" />
         </case>
         <!-- Countries using Euro currency, 23 countries as for January 2011. -->
-        <!-- 1. Andorra (ca_AD, ca_ES) -->
+              1. Andorra (ca_AD, ca_ES)
+              2. Austria (de_AT)
+              3. Belgium (nl_BE, fr_BE, de_BE)
+              4. Cyprus (el_CY, tr_CY)
+              5. Estonia (et_EE)
+              6. Finland (fi_FI, sv_FI)
+              7. France (fr_FR)
+              8. Germany (de_DE)
+              9. Greece (el_GR)
+             10. Ireland (ga_IE, en_IE)
+             11. Italy (it_IT)
+             12. Kosovo (??_XK) ??
+             13. Luxembourg (lb_LU, fr_LU, de_LU)
+             14. Malta (mt_MT, en_MT)
+             15. Monaco (fr_MO)
+             16. Montenegro (sla_ME)
+             17. Netherlands (nl_NL)
+             18. Portugal (pt_PT)
+             19. San Marino (it_SM)
+             20. Slovakia (sk_SK)
+             21. Slovenia (sl_SI)
+             22. Spain (es_ES, ca_ES)
+             23. Vatican City (it_VA)
+        -->
+        <!-- Note: Some locales may not have country code, and it it supposed to indicate the
+             country where the language originally/mainly spoken. -->
         <case
-            latin:languageCode="ca"
-            latin:countryCode=""
+            latin:localeCode="de|es|el|fi|fr|it|nl|sk|sl|pt_PT"
         >
             <key-style
                 latin:styleName="currencyKeyStyle"
                 latin:keyLabel="€"
                 latin:popupCharacters="@string/alternates_for_currency_euro" />
         </case>
-        <!-- 2. Austria (de_AT) -->
-<!--        <case-->
-<!--            latin:countryCode="AT"-->
-<!--        >-->
-<!--            <key-style-->
-<!--                latin:styleName="currencyKeyStyle"-->
-<!--                latin:keyLabel="€"-->
-<!--                latin:popupCharacters="@string/alternates_for_currency_euro" />-->
-<!--        </case>-->
-        <!-- 3. Belgium (nl_BE, fr_BE, de_BE) -->
-<!--        <case-->
-<!--            latin:countryCode="BE"-->
-<!--        >-->
-<!--            <key-style-->
-<!--                latin:styleName="currencyKeyStyle"-->
-<!--                latin:keyLabel="€"-->
-<!--                latin:popupCharacters="@string/alternates_for_currency_euro" />-->
-<!--        </case>-->
-        <!-- 4. Cyprus (el_CY, tr_CY) -->
         <case
-            latin:countryCode="CY"
+            latin:languageCode="ca|et|lb|mt|sla"
         >
             <key-style
                 latin:styleName="currencyKeyStyle"
                 latin:keyLabel="€"
                 latin:popupCharacters="@string/alternates_for_currency_euro" />
         </case>
-        <!-- 5. Estonia (et_EE) -->
-<!--        <case-->
-<!--            latin:languageCode="et"-->
-<!--            latin:countryCode=""-->
-<!--        >-->
-<!--            <key-style-->
-<!--                latin:styleName="currencyKeyStyle"-->
-<!--                latin:keyLabel="€"-->
-<!--                latin:popupCharacters="@string/alternates_for_currency_euro" />-->
-<!--        </case>-->
-        <!-- 6. Finland (fi_FI, sv_FI) -->
         <case
-            latin:languageCode="fi"
-            latin:countryCode=""
+            latin:countryCode="AD|AT|BE|CY|EE|FI|FR|DE|GR|IE|IT|XK|LU|MT|MO|ME|NL|PT|SM|SK|SI|ES|VA"
         >
             <key-style
                 latin:styleName="currencyKeyStyle"
                 latin:keyLabel="€"
                 latin:popupCharacters="@string/alternates_for_currency_euro" />
         </case>
-        <!-- 7. France (fr_FR) -->
-        <case
-            latin:languageCode="fr"
-            latin:countryCode=""
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 8. Germany (de_DE) -->
-        <case
-            latin:languageCode="de"
-            latin:countryCode=""
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 9. Greece (el_GR) -->
-        <case
-            latin:languageCode="el"
-            latin:countryCode=""
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 10. Ireland (ga_IE, en_IE) -->
-        <case
-            latin:countryCode="IE"
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 11. Italy (it_IT) -->
-        <case
-            latin:languageCode="it"
-            latin:countryCode=""
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 12. Kosovo -->
-<!--        <case-->
-<!--            latin:countryCode="XK"-->
-<!--        >-->
-<!--            <key-style-->
-<!--                latin:styleName="currencyKeyStyle"-->
-<!--                latin:keyLabel="€"-->
-<!--                latin:popupCharacters="@string/alternates_for_currency_euro" />-->
-<!--        </case>-->
-        <!-- 13. Luxembourg (lb_LU, fr_LU, de_LU) -->
-        <case
-            latin:countryCode="LU"
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 14. Malta (mt_MT, en_MT) -->
-        <case
-            latin:countryCode="MT"
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 15. Monaco (fr_MO) -->
-<!--        <case-->
-<!--            latin:countryCode="MO"-->
-<!--        >-->
-<!--            <key-style-->
-<!--                latin:styleName="currencyKeyStyle"-->
-<!--                latin:keyLabel="€"-->
-<!--                latin:popupCharacters="@string/alternates_for_currency_euro" />-->
-<!--        </case>-->
-        <!-- 16. Montenegro (sla_ME) -->
-        <case
-            latin:countryCode="ME"
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 17. Netherlands (nl_NL) -->
-        <case
-            latin:languageCode="nl"
-            latin:countryCode=""
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 18. Portugal (pt_PT) -->
-        <case
-            latin:languageCode="pt"
-            latin:countryCode=""
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 19. San Marino (it_SM) -->
-<!--        <case-->
-<!--            latin:countryCode="SM"-->
-<!--        >-->
-<!--            <key-style-->
-<!--                latin:styleName="currencyKeyStyle"-->
-<!--                latin:keyLabel="€"-->
-<!--                latin:popupCharacters="@string/alternates_for_currency_euro" />-->
-<!--        </case>-->
-        <!-- 20. Slovakia (sk_SK) -->
-        <case
-            latin:languageCode="sk"
-            latin:countryCode=""
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 21. Slovenia (sl_SI) -->
-        <case
-            latin:languageCode="sl"
-            latin:countryCode=""
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 22. Spain (es_ES, ca_ES) -->
-        <case
-            latin:languageCode="es"
-            latin:countryCode=""
-        >
-            <key-style
-                latin:styleName="currencyKeyStyle"
-                latin:keyLabel="€"
-                latin:popupCharacters="@string/alternates_for_currency_euro" />
-        </case>
-        <!-- 23. Vatican City (it_VA) -->
-<!--        <case-->
-<!--            latin:countryCode="VA"-->
-<!--        >-->
-<!--            <key-style-->
-<!--                latin:styleName="currencyKeyStyle"-->
-<!--                latin:keyLabel="€"-->
-<!--                latin:popupCharacters="@string/alternates_for_currency_euro" />-->
-<!--        </case>-->
         <!-- United Kingdom -->
         <case
             latin:countryCode="GB"
@@ -266,4 +96,4 @@
                 latin:popupCharacters="@string/alternates_for_currency_dollar" />
         </default>
     </switch>
-</merge>
\ No newline at end of file
+</merge>
diff --git a/java/res/xml/kbd_iw_rows.xml b/java/res/xml/kbd_iw_rows.xml
index af017ad..c3c8f7d 100644
--- a/java/res/xml/kbd_iw_rows.xml
+++ b/java/res/xml/kbd_iw_rows.xml
@@ -27,6 +27,7 @@
     <include
         latin:keyboardLayout="@xml/kbd_key_styles" />
     <Row
+        latin:keyWidth="10%p"
         latin:rowEdgeFlags="top"
     >
         <Key
@@ -53,7 +54,9 @@
             latin:visualInsetsLeft="1%p"
             latin:keyEdgeFlags="right" />
     </Row>
-    <Row>
+    <Row
+        latin:keyWidth="10%p"
+    >
         <Key
             latin:keyLabel="ש"
             latin:keyEdgeFlags="left" />
@@ -78,7 +81,9 @@
             latin:keyWidth="fillRight"
             latin:keyEdgeFlags="right" />
     </Row>
-    <Row>
+    <Row
+        latin:keyWidth="10%p"
+    >
         <Key
             latin:keyLabel="ז"
             latin:keyXPos="5%p"
diff --git a/java/res/xml/kbd_qwerty.xml b/java/res/xml/kbd_qwerty.xml
index fd43740..f0c1fa7 100644
--- a/java/res/xml/kbd_qwerty.xml
+++ b/java/res/xml/kbd_qwerty.xml
@@ -24,7 +24,6 @@
     latin:maxKeyboardHeight="@fraction/maxKeyboardHeight"
     latin:minKeyboardHeight="@fraction/minKeyboardHeight"
     latin:rowHeight="25%p"
-    latin:keyWidth="10%p"
     latin:horizontalGap="@dimen/key_horizontal_gap"
     latin:verticalGap="@dimen/key_bottom_gap"
     latin:popupKeyboardTemplate="@xml/kbd_popup_template"
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
index 4ae0113..c2db62a 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardParser.java
@@ -467,8 +467,8 @@
         final TypedArray viewAttr = mResources.obtainAttributes(Xml.asAttributeSet(parser),
                 R.styleable.KeyboardView);
         try {
-            final boolean modeMatched = matchInteger(a,
-                    R.styleable.Keyboard_Case_mode, id.mMode);
+            final boolean modeMatched = matchTypedValue(a,
+                    R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode));
             final boolean webInputMatched = matchBoolean(a,
                     R.styleable.Keyboard_Case_webInput, id.mWebInput);
             final boolean passwordInputMatched = matchBoolean(a,
@@ -487,21 +487,22 @@
             // this attribute with id.mImeOptions as integer value is enough for our purpose.
             final boolean imeActionMatched = matchInteger(a,
                     R.styleable.Keyboard_Case_imeAction, id.mImeAction);
+            final boolean localeCodeMatched = matchString(a,
+                    R.styleable.Keyboard_Case_localeCode, id.mLocale.toString());
             final boolean languageCodeMatched = matchString(a,
                     R.styleable.Keyboard_Case_languageCode, id.mLocale.getLanguage());
             final boolean countryCodeMatched = matchString(a,
                     R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
             final boolean selected = modeMatched && webInputMatched && passwordInputMatched
                     && settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched
-                    && colorSchemeMatched && imeActionMatched && languageCodeMatched
-                    && countryCodeMatched;
+                    && colorSchemeMatched && imeActionMatched && localeCodeMatched
+                    && languageCodeMatched && countryCodeMatched;
 
-            if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE,
-                    textAttr(KeyboardId.modeName(
-                            a.getInt(R.styleable.Keyboard_Case_mode, -1)), "mode"),
+            if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE,
+                    textAttr(a.getString(R.styleable.Keyboard_Case_mode), "mode"),
                     textAttr(KeyboardId.colorSchemeName(
                             viewAttr.getInt(
-                                    R.styleable.KeyboardView_colorScheme, -1)), "colorSchemeName"),
+                                    R.styleable.KeyboardView_colorScheme, -1)), "colorScheme"),
                     booleanAttr(a, R.styleable.Keyboard_Case_webInput, "webInput"),
                     booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"),
                     booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"),
@@ -509,6 +510,7 @@
                     booleanAttr(a, R.styleable.Keyboard_Case_hasVoiceKey, "hasVoiceKey"),
                     textAttr(EditorInfoCompatUtils.imeOptionsName(
                             a.getInt(R.styleable.Keyboard_Case_imeAction, -1)), "imeAction"),
+                    textAttr(a.getString(R.styleable.Keyboard_Case_localeCode), "localeCode"),
                     textAttr(a.getString(R.styleable.Keyboard_Case_languageCode), "languageCode"),
                     textAttr(a.getString(R.styleable.Keyboard_Case_countryCode), "countryCode"),
                     Boolean.toString(selected)));
@@ -535,7 +537,30 @@
     private static boolean matchString(TypedArray a, int index, String value) {
         // If <case> does not have "index" attribute, that means this <case> is wild-card for the
         // attribute.
-        return !a.hasValue(index) || a.getString(index).equals(value);
+        return !a.hasValue(index) || stringArrayContains(a.getString(index).split("\\|"), value);
+    }
+
+    private static boolean matchTypedValue(TypedArray a, int index, int intValue, String strValue) {
+        // If <case> does not have "index" attribute, that means this <case> is wild-card for the
+        // attribute.
+        final TypedValue v = a.peekValue(index);
+        if (v == null)
+            return true;
+
+        if (isIntegerValue(v)) {
+            return intValue == a.getInt(index, 0);
+        } else if (isStringValue(v)) {
+            return stringArrayContains(a.getString(index).split("\\|"), strValue);
+        }
+        return false;
+    }
+
+    private static boolean stringArrayContains(String[] array, String value) {
+        for (final String elem : array) {
+            if (elem.equals(value))
+                return true;
+        }
+        return false;
     }
 
     private boolean parseDefault(XmlResourceParser parser, Row row, List<Key> keys)
@@ -594,7 +619,7 @@
     }
 
     private void endKey(Key key) {
-        mCurrentX = key.mX + key.mGap + key.mWidth;
+        mCurrentX = key.mX - key.mGap / 2 + key.mWidth + key.mGap;
     }
 
     private void endKeyboard(int defaultVerticalGap) {
@@ -610,19 +635,34 @@
         final TypedValue value = a.peekValue(index);
         if (value == null)
             return defValue;
-        if (value.type == TypedValue.TYPE_FRACTION) {
+        if (isFractionValue(value)) {
             // Round it to avoid values like 47.9999 from getting truncated
             return Math.round(a.getFraction(index, base, base, defValue));
-        } else if (value.type == TypedValue.TYPE_DIMENSION) {
+        } else if (isDimensionValue(value)) {
             return a.getDimensionPixelOffset(index, defValue);
-        } else if (value.type >= TypedValue.TYPE_FIRST_INT
-                && value.type <= TypedValue.TYPE_LAST_INT) {
+        } else if (isIntegerValue(value)) {
             // For enum value.
             return a.getInt(index, defValue);
         }
         return defValue;
     }
 
+    private static boolean isFractionValue(TypedValue v) {
+        return v.type == TypedValue.TYPE_FRACTION;
+    }
+
+    private static boolean isDimensionValue(TypedValue v) {
+        return v.type == TypedValue.TYPE_DIMENSION;
+    }
+
+    private static boolean isIntegerValue(TypedValue v) {
+        return v.type >= TypedValue.TYPE_FIRST_INT && v.type <= TypedValue.TYPE_LAST_INT;
+    }
+
+    private static boolean isStringValue(TypedValue v) {
+        return v.type == TypedValue.TYPE_STRING;
+    }
+
     @SuppressWarnings("serial")
     public static class ParseException extends InflateException {
         public ParseException(String msg, XmlResourceParser parser) {