Merge "Use DistracterFilterCheckingIsInDictionary for User History" into lmp-dev
diff --git a/java/res/anim/more_keys_keyboard_fadein.xml b/java/res/anim/more_keys_keyboard_fadein.xml
deleted file mode 100644
index c781f36..0000000
--- a/java/res/anim/more_keys_keyboard_fadein.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-
-<set
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:interpolator="@android:anim/decelerate_interpolator"
->
-    <alpha
-        android:fromAlpha="0.5"
-        android:toAlpha="1.0"
-        android:duration="@integer/config_more_keys_keyboard_fadein_anim_time" />
-</set>
diff --git a/java/res/anim/more_keys_keyboard_fadeout.xml b/java/res/anim/more_keys_keyboard_fadeout.xml
deleted file mode 100644
index 32fae6b..0000000
--- a/java/res/anim/more_keys_keyboard_fadeout.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-
-<set
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:interpolator="@android:anim/accelerate_interpolator"
->
-    <alpha
-        android:fromAlpha="1.0"
-        android:toAlpha="0.0"
-        android:duration="@integer/config_more_keys_keyboard_fadeout_anim_time" />
-</set>
diff --git a/java/res/drawable/btn_keyboard_key_lxx_dark.xml b/java/res/drawable/btn_keyboard_key_lxx_dark.xml
index bb1789a..c82c138 100644
--- a/java/res/drawable/btn_keyboard_key_lxx_dark.xml
+++ b/java/res/drawable/btn_keyboard_key_lxx_dark.xml
@@ -15,6 +15,11 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- Custom label action keys. -->
+    <item android:state_active="true" android:state_checked="true" android:state_pressed="true"
+          android:drawable="@color/key_background_pressed_lxx_dark" />
+    <item android:state_active="true" android:state_checked="true"
+          android:drawable="@color/key_background_lxx_dark" />
     <!-- Action keys. -->
     <item android:state_active="true" android:state_pressed="true"
           android:drawable="@drawable/btn_keyboard_key_active_pressed_lxx_dark" />
diff --git a/java/res/drawable/btn_keyboard_key_lxx_light.xml b/java/res/drawable/btn_keyboard_key_lxx_light.xml
index 60fe02d..f237fbe 100644
--- a/java/res/drawable/btn_keyboard_key_lxx_light.xml
+++ b/java/res/drawable/btn_keyboard_key_lxx_light.xml
@@ -15,6 +15,11 @@
 -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- Custom label action keys. -->
+    <item android:state_active="true" android:state_checked="true" android:state_pressed="true"
+          android:drawable="@color/key_background_pressed_lxx_light" />
+    <item android:state_active="true" android:state_checked="true"
+          android:drawable="@color/key_background_lxx_light" />
     <!-- Action keys. -->
     <item android:state_active="true" android:state_pressed="true"
           android:drawable="@drawable/btn_keyboard_key_active_pressed_lxx_light" />
diff --git a/java/res/values-land/config.xml b/java/res/values-land/config.xml
index 5eea4c1..34d6d4e 100644
--- a/java/res/values-land/config.xml
+++ b/java/res/values-land/config.xml
@@ -43,10 +43,12 @@
 
     <fraction name="config_key_preview_text_ratio">90%</fraction>
     <fraction name="config_key_letter_ratio">65%</fraction>
-    <fraction name="config_key_large_letter_ratio">74%</fraction>
+    <fraction name="config_key_large_letter_ratio_holo">74%</fraction>
+    <fraction name="config_key_large_letter_ratio_lxx">90%</fraction>
     <fraction name="config_key_label_ratio">40%</fraction>
     <fraction name="config_key_hint_letter_ratio">30%</fraction>
-    <fraction name="config_key_hint_label_ratio">52%</fraction>
+    <fraction name="config_key_hint_label_ratio_holo">52%</fraction>
+    <fraction name="config_key_hint_label_ratio_lxx">30%</fraction>
     <fraction name="config_key_shifted_letter_hint_ratio">40%</fraction>
     <fraction name="config_language_on_spacebar_text_ratio">40.000%</fraction>
 
diff --git a/java/res/values-sw600dp-land/config.xml b/java/res/values-sw600dp-land/config.xml
index 6368eef..c238b2c 100644
--- a/java/res/values-sw600dp-land/config.xml
+++ b/java/res/values-sw600dp-land/config.xml
@@ -33,10 +33,12 @@
     <fraction name="config_key_horizontal_gap_holo">0.9%p</fraction>
 
     <fraction name="config_key_letter_ratio">50%</fraction>
-    <fraction name="config_key_large_letter_ratio">48%</fraction>
+    <fraction name="config_key_large_letter_ratio_holo">48%</fraction>
+    <fraction name="config_key_large_letter_ratio_lxx">60%</fraction>
     <fraction name="config_key_label_ratio">32%</fraction>
     <fraction name="config_key_hint_letter_ratio">23%</fraction>
-    <fraction name="config_key_hint_label_ratio">34%</fraction>
+    <fraction name="config_key_hint_label_ratio_holo">34%</fraction>
+    <fraction name="config_key_hint_label_ratio_lxx">20%</fraction>
     <fraction name="config_key_shifted_letter_hint_ratio">29%</fraction>
     <fraction name="config_language_on_spacebar_text_ratio">30.0%</fraction>
     <dimen name="config_key_shifted_letter_hint_padding">4dp</dimen>
diff --git a/java/res/values-sw600dp/config.xml b/java/res/values-sw600dp/config.xml
index 9d16e2c..3c489bb 100644
--- a/java/res/values-sw600dp/config.xml
+++ b/java/res/values-sw600dp/config.xml
@@ -45,11 +45,12 @@
     <dimen name="config_key_preview_height">94.5dp</dimen>
     <fraction name="config_key_preview_text_ratio">50%</fraction>
     <fraction name="config_key_letter_ratio">42%</fraction>
-    <fraction name="config_key_large_letter_ratio">45%</fraction>
+    <fraction name="config_key_large_letter_ratio_holo">45%</fraction>
+    <fraction name="config_key_large_letter_ratio_lxx">60%</fraction>
     <fraction name="config_key_label_ratio">25%</fraction>
-    <fraction name="config_key_large_label_ratio">32%</fraction>
     <fraction name="config_key_hint_letter_ratio">23%</fraction>
-    <fraction name="config_key_hint_label_ratio">28%</fraction>
+    <fraction name="config_key_hint_label_ratio_holo">28%</fraction>
+    <fraction name="config_key_hint_label_ratio_lxx">20%</fraction>
     <fraction name="config_key_shifted_letter_hint_ratio">22%</fraction>
     <fraction name="config_language_on_spacebar_text_ratio">28.0%</fraction>
     <dimen name="config_key_hint_letter_padding">3dp</dimen>
diff --git a/java/res/values-sw768dp-land/config.xml b/java/res/values-sw768dp-land/config.xml
index a1659b4..587a3c1 100644
--- a/java/res/values-sw768dp-land/config.xml
+++ b/java/res/values-sw768dp-land/config.xml
@@ -35,10 +35,12 @@
 
     <dimen name="config_key_preview_height">107.1dp</dimen>
     <fraction name="config_key_letter_ratio">43%</fraction>
-    <fraction name="config_key_large_letter_ratio">42%</fraction>
+    <fraction name="config_key_large_letter_ratio_holo">42%</fraction>
+    <fraction name="config_key_large_letter_ratio_lxx">60%</fraction>
     <fraction name="config_key_label_ratio">28%</fraction>
     <fraction name="config_key_hint_letter_ratio">23%</fraction>
-    <fraction name="config_key_hint_label_ratio">28%</fraction>
+    <fraction name="config_key_hint_label_ratio_holo">28%</fraction>
+    <fraction name="config_key_hint_label_ratio_lxx">20%</fraction>
     <fraction name="config_key_shifted_letter_hint_ratio">24%</fraction>
     <fraction name="config_language_on_spacebar_text_ratio">24.00%</fraction>
 
diff --git a/java/res/values-sw768dp/config.xml b/java/res/values-sw768dp/config.xml
index 635061d..f573c40 100644
--- a/java/res/values-sw768dp/config.xml
+++ b/java/res/values-sw768dp/config.xml
@@ -43,11 +43,12 @@
     <dimen name="config_key_preview_height">94.5dp</dimen>
     <fraction name="config_key_preview_text_ratio">50%</fraction>
     <fraction name="config_key_letter_ratio">40%</fraction>
-    <fraction name="config_key_large_letter_ratio">42%</fraction>
+    <fraction name="config_key_large_letter_ratio_holo">42%</fraction>
+    <fraction name="config_key_large_letter_ratio_lxx">60%</fraction>
     <fraction name="config_key_label_ratio">28%</fraction>
-    <fraction name="config_key_large_label_ratio">28%</fraction>
     <fraction name="config_key_hint_letter_ratio">23%</fraction>
-    <fraction name="config_key_hint_label_ratio">28%</fraction>
+    <fraction name="config_key_hint_label_ratio_holo">28%</fraction>
+    <fraction name="config_key_hint_label_ratio_lxx">20%</fraction>
     <fraction name="config_key_shifted_letter_hint_ratio">26%</fraction>
     <fraction name="config_language_on_spacebar_text_ratio">29.03%</fraction>
     <dimen name="config_key_hint_letter_padding">3dp</dimen>
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index 9a22273..bfe3856 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -270,9 +270,10 @@
             <enum name="empty" value="0" />
             <enum name="normal" value="1" />
             <enum name="functional" value="2" />
-            <enum name="action" value="3" />
-            <enum name="stickyOff" value="4" />
-            <enum name="stickyOn" value="5" />
+            <enum name="stickyOff" value="3" />
+            <enum name="stickyOn" value="4" />
+            <enum name="action" value="5" />
+            <enum name="customAction" value="6" />
         </attr>
         <!-- The key action flags. -->
         <attr name="keyActionFlags" format="integer">
@@ -291,14 +292,15 @@
         <!-- The key label flags. -->
         <attr name="keyLabelFlags" format="integer">
             <!-- This should be aligned with Key.LABEL_FLAGS__* -->
-            <flag name="alignLeftOfCenter" value="0x08" />
+            <flag name="alignHintLabelToBottom" value="0x02" />
+            <flag name="alignIconToBottom" value="0x04" />
+            <flag name="alignLabelOffCenter" value="0x08" />
             <flag name="fontNormal" value="0x10" />
             <flag name="fontMonoSpace" value="0x20" />
             <flag name="fontDefault" value="0x30" />
             <flag name="followKeyLargeLetterRatio" value="0x40" />
             <flag name="followKeyLetterRatio" value="0x80" />
             <flag name="followKeyLabelRatio" value="0xC0" />
-            <flag name="followKeyLargeLabelRatio" value="0x100" />
             <flag name="followKeyHintLabelRatio" value="0x140" />
             <flag name="hasPopupHint" value="0x200" />
             <flag name="hasShiftedLetterHint" value="0x400" />
@@ -357,8 +359,6 @@
         <attr name="keyLabelSize" format="dimension|fraction" />
         <!-- Large size of the text for one letter keys, in the proportion of key height. -->
         <attr name="keyLargeLetterRatio" format="fraction" />
-        <!-- Large size of the text for keys with multiple letters, in the proportion of key height. -->
-        <attr name="keyLargeLabelRatio" format="fraction" />
         <!-- Size of the text for hint letter (= one character hint label), in the proportion of
              key height. -->
         <attr name="keyHintLetterRatio" format="fraction" />
@@ -366,6 +366,14 @@
         <attr name="keyHintLabelRatio" format="fraction" />
         <!-- Size of the text for shifted letter hint, in the proportion of key height. -->
         <attr name="keyShiftedLetterHintRatio" format="fraction" />
+        <!-- The label's horizontal offset to the center of the key. Negative is to left and
+             positive is to right. The value is in proportion of the width of
+             TypefaceUtils.KEY_LABEL_REFERENCE_CHAR. -->
+        <attr name="keyLabelOffCenterRatio" format="fraction" />
+        <!-- The hint label's horizontal offset to the center of the key. Negative is to left and
+             positive is to right. The value is in proportion of the width of
+             TypefaceUtils.KEY_LABEL_REFERENCE_CHAR. -->
+        <attr name="keyHintLabelOffCenterRatio" format="fraction" />
         <!-- Color to use for the label in a key. -->
         <attr name="keyTextColor" format="color" />
         <attr name="keyTextShadowColor" format="color" />
diff --git a/java/res/values/config.xml b/java/res/values/config.xml
index d748c91..af3b589 100644
--- a/java/res/values/config.xml
+++ b/java/res/values/config.xml
@@ -47,11 +47,12 @@
     <dimen name="config_key_preview_height">80dp</dimen>
     <fraction name="config_key_preview_text_ratio">82%</fraction>
     <fraction name="config_key_letter_ratio">55%</fraction>
-    <fraction name="config_key_large_letter_ratio">65%</fraction>
+    <fraction name="config_key_large_letter_ratio_holo">65%</fraction>
+    <fraction name="config_key_large_letter_ratio_lxx">90%</fraction>
     <fraction name="config_key_label_ratio">34%</fraction>
-    <fraction name="config_key_large_label_ratio">40%</fraction>
     <fraction name="config_key_hint_letter_ratio">25%</fraction>
-    <fraction name="config_key_hint_label_ratio">44%</fraction>
+    <fraction name="config_key_hint_label_ratio_holo">44%</fraction>
+    <fraction name="config_key_hint_label_ratio_lxx">30%</fraction>
     <fraction name="config_key_shifted_letter_hint_ratio">35%</fraction>
     <fraction name="config_language_on_spacebar_text_ratio">33.735%</fraction>
     <dimen name="config_key_hint_letter_padding">1dp</dimen>
diff --git a/java/res/values/themes-common.xml b/java/res/values/themes-common.xml
index b139110..46f2553 100644
--- a/java/res/values/themes-common.xml
+++ b/java/res/values/themes-common.xml
@@ -22,23 +22,27 @@
     <style name="KeyboardIcons" />
     <!-- Default theme values -->
     <style name="Keyboard">
-        <item name="touchPositionCorrectionData">@array/touch_position_correction_data_default</item>
         <item name="rowHeight">25%p</item>
-        <item name="moreKeysTemplate">@xml/kbd_more_keys_keyboard_template</item>
+        <item name="horizontalGap">@fraction/config_key_horizontal_gap_holo</item>
+        <item name="verticalGap">@fraction/config_key_vertical_gap_holo</item>
+        <item name="touchPositionCorrectionData">@array/touch_position_correction_data_holo</item>
+        <item name="keyboardTopPadding">@fraction/config_keyboard_top_padding_holo</item>
+        <item name="keyboardBottomPadding">@fraction/config_keyboard_bottom_padding_holo</item>
         <item name="keyboardLeftPadding">@fraction/config_keyboard_left_padding</item>
         <item name="keyboardRightPadding">@fraction/config_keyboard_right_padding</item>
+        <item name="moreKeysTemplate">@xml/kbd_more_keys_keyboard_template</item>
         <item name="maxMoreKeysColumn">@integer/config_max_more_keys_column</item>
     </style>
     <style name="KeyboardView">
-        <item name="keyBackground">@drawable/btn_keyboard_key_klp</item>
         <item name="keyLetterSize">@fraction/config_key_letter_ratio</item>
-        <item name="keyLargeLetterRatio">@fraction/config_key_large_letter_ratio</item>
+        <item name="keyLargeLetterRatio">@fraction/config_key_large_letter_ratio_holo</item>
         <item name="keyLabelSize">@fraction/config_key_label_ratio</item>
-        <item name="keyLargeLabelRatio">@fraction/config_key_large_label_ratio</item>
         <item name="keyHintLetterRatio">@fraction/config_key_hint_letter_ratio</item>
-        <item name="keyHintLabelRatio">@fraction/config_key_hint_label_ratio</item>
+        <item name="keyHintLabelRatio">@fraction/config_key_hint_label_ratio_holo</item>
         <item name="keyShiftedLetterHintRatio">@fraction/config_key_shifted_letter_hint_ratio</item>
         <item name="keyTypeface">normal</item>
+        <!-- A negative value to disable key text shadow layer. -->
+        <item name="keyTextShadowRadius">-1.0</item>
         <item name="keyHintLetterPadding">@dimen/config_key_hint_letter_padding</item>
         <item name="keyPopupHintLetterPadding">@dimen/config_key_popup_hint_letter_padding</item>
         <item name="keyShiftedLetterHintPadding">@dimen/config_key_shifted_letter_hint_padding</item>
@@ -130,8 +134,4 @@
         <item name="android:singleLine">true</item>
         <item name="android:ellipsize">none</item>
     </style>
-    <style name="MoreKeysKeyboardAnimation">
-        <item name="android:windowEnterAnimation">@anim/more_keys_keyboard_fadein</item>
-        <item name="android:windowExitAnimation">@anim/more_keys_keyboard_fadeout</item>
-    </style>
 </resources>
diff --git a/java/res/values/themes-holo.xml b/java/res/values/themes-holo.xml
new file mode 100644
index 0000000..cb3ad7a
--- /dev/null
+++ b/java/res/values/themes-holo.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2014, 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.
+*/
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- Holo KeyboardView theme (ICS and KLP) -->
+    <style
+        name="KeyboardView.Holo"
+        parent="KeyboardView"
+    >
+        <item name="keyTypeface">bold</item>
+        <item name="keyLargeLetterRatio">@fraction/config_key_large_letter_ratio_holo</item>
+        <item name="keyLabelOffCenterRatio">-175%</item>
+        <item name="keyHintLabelRatio">@fraction/config_key_hint_label_ratio_holo</item>
+        <item name="keyHintLabelOffCenterRatio">200%</item>
+        <!-- U+2026: "…" HORIZONTAL ELLIPSIS -->
+        <item name="keyPopupHintLetter">&#x2026;</item>
+    </style>
+</resources>
diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml
index a6f390c..6fddcb9 100644
--- a/java/res/values/themes-ics.xml
+++ b/java/res/values/themes-ics.xml
@@ -35,21 +35,15 @@
     >
         <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
         <item name="themeId">2</item>
-        <item name="keyboardTopPadding">@fraction/config_keyboard_top_padding_holo</item>
-        <item name="keyboardBottomPadding">@fraction/config_keyboard_bottom_padding_holo</item>
-        <item name="horizontalGap">@fraction/config_key_horizontal_gap_holo</item>
-        <item name="verticalGap">@fraction/config_key_vertical_gap_holo</item>
-        <item name="touchPositionCorrectionData">@array/touch_position_correction_data_holo</item>
     </style>
     <style
         name="KeyboardView.ICS"
-        parent="KeyboardView"
+        parent="KeyboardView.Holo"
     >
         <item name="android:background">@drawable/keyboard_background_holo</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_ics</item>
         <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_ics</item>
         <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_ics</item>
-        <item name="keyTypeface">bold</item>
         <item name="keyTextColor">@color/key_text_color_holo</item>
         <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_holo</item>
         <item name="functionalTextColor">@color/key_text_color_holo</item>
@@ -58,10 +52,6 @@
         <item name="keyShiftedLetterHintInactivatedColor">@color/key_shifted_letter_hint_inactivated_color_holo</item>
         <item name="keyShiftedLetterHintActivatedColor">@color/key_shifted_letter_hint_activated_color_holo</item>
         <item name="keyPreviewTextColor">@color/key_text_color_holo</item>
-        <!-- A negative value to disable key text shadow layer. -->
-        <item name="keyTextShadowRadius">-1.0</item>
-        <!-- U+2026: "…" HORIZONTAL ELLIPSIS -->
-        <item name="keyPopupHintLetter">&#x2026;</item>
     </style>
     <style
         name="MainKeyboardView.ICS"
diff --git a/java/res/values/themes-klp.xml b/java/res/values/themes-klp.xml
index 8782a76..c9b8331 100644
--- a/java/res/values/themes-klp.xml
+++ b/java/res/values/themes-klp.xml
@@ -35,21 +35,15 @@
     >
         <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
         <item name="themeId">0</item>
-        <item name="keyboardTopPadding">@fraction/config_keyboard_top_padding_holo</item>
-        <item name="keyboardBottomPadding">@fraction/config_keyboard_bottom_padding_holo</item>
-        <item name="horizontalGap">@fraction/config_key_horizontal_gap_holo</item>
-        <item name="verticalGap">@fraction/config_key_vertical_gap_holo</item>
-        <item name="touchPositionCorrectionData">@array/touch_position_correction_data_holo</item>
     </style>
     <style
         name="KeyboardView.KLP"
-        parent="KeyboardView"
+        parent="KeyboardView.Holo"
     >
         <item name="android:background">@drawable/keyboard_background_holo</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_klp</item>
         <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_klp</item>
         <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_klp</item>
-        <item name="keyTypeface">bold</item>
         <item name="keyTextColor">@color/key_text_color_holo</item>
         <item name="keyTextInactivatedColor">@color/key_text_inactivated_color_holo</item>
         <item name="functionalTextColor">@color/key_text_color_holo</item>
@@ -58,10 +52,6 @@
         <item name="keyShiftedLetterHintInactivatedColor">@color/key_shifted_letter_hint_inactivated_color_holo</item>
         <item name="keyShiftedLetterHintActivatedColor">@color/key_shifted_letter_hint_activated_color_holo</item>
         <item name="keyPreviewTextColor">@color/key_text_color_holo</item>
-        <!-- A negative value to disable key text shadow layer. -->
-        <item name="keyTextShadowRadius">-1.0</item>
-        <!-- U+2026: "…" HORIZONTAL ELLIPSIS -->
-        <item name="keyPopupHintLetter">&#x2026;</item>
     </style>
     <style
         name="MainKeyboardView.KLP"
diff --git a/java/res/values/themes-lxx-dark.xml b/java/res/values/themes-lxx-dark.xml
index fa6aa62..6afbd9b 100644
--- a/java/res/values/themes-lxx-dark.xml
+++ b/java/res/values/themes-lxx-dark.xml
@@ -35,22 +35,15 @@
     >
         <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
         <item name="themeId">4</item>
-        <item name="keyboardTopPadding">@fraction/config_keyboard_top_padding_holo</item>
-        <item name="keyboardBottomPadding">@fraction/config_keyboard_bottom_padding_holo</item>
-        <item name="horizontalGap">@fraction/config_key_horizontal_gap_holo</item>
-        <item name="verticalGap">@fraction/config_key_vertical_gap_holo</item>
-        <item name="touchPositionCorrectionData">@array/touch_position_correction_data_holo</item>
     </style>
     <style
         name="KeyboardView.LXX_Dark"
-        parent="KeyboardView"
+        parent="KeyboardView.LXX"
     >
         <item name="android:background">@drawable/keyboard_background_lxx_dark</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_lxx_dark</item>
         <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_lxx_dark</item>
         <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_lxx_dark</item>
-        <item name="spacebarIconWidthRatio">0.9</item>
-        <item name="keyTypeface">normal</item>
         <item name="keyTextColor">@color/key_text_color_lxx_dark</item>
         <item name="keyTextInactivatedColor">@color/key_functional_text_color_lxx_dark</item>
         <item name="functionalTextColor">@color/key_text_color_lxx_dark</item>
@@ -59,9 +52,6 @@
         <item name="keyShiftedLetterHintInactivatedColor">@color/key_text_inactive_color_lxx_dark</item>
         <item name="keyShiftedLetterHintActivatedColor">@color/key_text_color_lxx_dark</item>
         <item name="keyPreviewTextColor">@color/key_text_color_lxx_dark</item>
-        <!-- A negative value to disable key text shadow layer. -->
-        <item name="keyTextShadowRadius">-1.0</item>
-        <item name="keyPopupHintLetter"></item> <!-- No popup hint letter -->
     </style>
     <style
         name="MainKeyboardView.LXX_Dark"
diff --git a/java/res/values/themes-lxx-light.xml b/java/res/values/themes-lxx-light.xml
index e7350f9..b3ced80 100644
--- a/java/res/values/themes-lxx-light.xml
+++ b/java/res/values/themes-lxx-light.xml
@@ -35,22 +35,15 @@
     >
         <!-- This should be aligned with KeyboardSwitcher.KEYBOARD_THEMES[] -->
         <item name="themeId">3</item>
-        <item name="keyboardTopPadding">@fraction/config_keyboard_top_padding_holo</item>
-        <item name="keyboardBottomPadding">@fraction/config_keyboard_bottom_padding_holo</item>
-        <item name="horizontalGap">@fraction/config_key_horizontal_gap_holo</item>
-        <item name="verticalGap">@fraction/config_key_vertical_gap_holo</item>
-        <item name="touchPositionCorrectionData">@array/touch_position_correction_data_holo</item>
     </style>
     <style
         name="KeyboardView.LXX_Light"
-        parent="KeyboardView"
+        parent="KeyboardView.LXX"
     >
         <item name="android:background">@drawable/keyboard_background_lxx_light</item>
         <item name="keyBackground">@drawable/btn_keyboard_key_lxx_light</item>
         <item name="functionalKeyBackground">@drawable/btn_keyboard_key_functional_lxx_light</item>
         <item name="spacebarBackground">@drawable/btn_keyboard_spacebar_lxx_light</item>
-        <item name="spacebarIconWidthRatio">0.9</item>
-        <item name="keyTypeface">normal</item>
         <item name="keyTextColor">@color/key_text_color_lxx_light</item>
         <item name="keyTextInactivatedColor">@color/key_text_inactive_color_lxx_light</item>
         <item name="functionalTextColor">@color/key_functional_text_color_lxx_light</item>
@@ -59,9 +52,6 @@
         <item name="keyShiftedLetterHintInactivatedColor">@color/key_text_inactive_color_lxx_light</item>
         <item name="keyShiftedLetterHintActivatedColor">@color/key_text_color_lxx_light</item>
         <item name="keyPreviewTextColor">@color/key_text_color_lxx_light</item>
-        <!-- A negative value to disable key text shadow layer. -->
-        <item name="keyTextShadowRadius">-1.0</item>
-        <item name="keyPopupHintLetter"></item> <!-- No popup hint letter -->
     </style>
     <style
         name="MainKeyboardView.LXX_Light"
diff --git a/java/res/values/themes-lxx.xml b/java/res/values/themes-lxx.xml
new file mode 100644
index 0000000..1c33cd6
--- /dev/null
+++ b/java/res/values/themes-lxx.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2014, 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.
+*/
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- LXX KeyboardView theme (LXX_Light and LXX_Dark) -->
+    <style
+        name="KeyboardView.LXX"
+        parent="KeyboardView"
+    >
+        <item name="keyTypeface">normal</item>
+        <item name="keyLargeLetterRatio">@fraction/config_key_large_letter_ratio_lxx</item>
+        <item name="keyLabelOffCenterRatio">-80%</item>
+        <item name="keyHintLabelRatio">@fraction/config_key_hint_label_ratio_lxx</item>
+        <item name="keyHintLabelOffCenterRatio">300%</item>
+        <item name="keyLabelFlags">alignHintLabelToBottom</item>
+        <item name="spacebarIconWidthRatio">0.9</item>
+        <!-- No popup hint letter -->
+        <item name="keyPopupHintLetter"></item>
+    </style>
+</resources>
diff --git a/java/res/xml-sw600dp/key_styles_enter.xml b/java/res/xml-sw600dp/key_styles_enter.xml
index 740bf35..d0167d3 100644
--- a/java/res/xml-sw600dp/key_styles_enter.xml
+++ b/java/res/xml-sw600dp/key_styles_enter.xml
@@ -230,6 +230,7 @@
                 latin:styleName="enterKeyStyle"
                 latin:keySpec="dummy_label|!code/key_enter"
                 latin:keyLabelFlags="fromCustomActionLabel"
+                latin:backgroundType="customAction"
                 latin:parentStyle="defaultEnterKeyStyle" />
         </case>
         <!-- imeAction is either actionNone or actionUnspecified. -->
diff --git a/java/res/xml/key_styles_enter.xml b/java/res/xml/key_styles_enter.xml
index 770bf38..960c79c 100644
--- a/java/res/xml/key_styles_enter.xml
+++ b/java/res/xml/key_styles_enter.xml
@@ -398,6 +398,7 @@
                 latin:styleName="enterKeyStyle"
                 latin:keySpec="dummy_label|!code/key_enter"
                 latin:keyLabelFlags="fromCustomActionLabel"
+                latin:backgroundType="customAction"
                 latin:parentStyle="defaultEnterKeyStyle" />
         </case>
         <!-- imeAction is either actionNone or actionUnspecified. -->
diff --git a/java/res/xml/key_styles_number.xml b/java/res/xml/key_styles_number.xml
index f754b99..14b2028 100644
--- a/java/res/xml/key_styles_number.xml
+++ b/java/res/xml/key_styles_number.xml
@@ -39,7 +39,7 @@
         latin:parentStyle="numKeyBaseStyle" />
     <key-style
         latin:styleName="numberKeyStyle"
-        latin:keyLabelFlags="alignLeftOfCenter|hasHintLabel"
+        latin:keyLabelFlags="alignLabelOffCenter|hasHintLabel"
         latin:parentStyle="numKeyStyle" />
     <key-style
         latin:styleName="num0KeyStyle"
@@ -120,6 +120,7 @@
     <key-style
         latin:styleName="numSpaceKeyStyle"
         latin:keySpec="!icon/space_key_for_number_layout|!code/key_space"
+        latin:keyLabelFlags="alignIconToBottom"
         latin:keyActionFlags="enableLongPress"
         latin:parentStyle="numKeyBaseStyle" />
 </merge>
diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml
index 5021f33..7013c6b 100644
--- a/java/res/xml/method.xml
+++ b/java/res/xml/method.xml
@@ -51,7 +51,7 @@
     fr_CH: French (Switzerland)/swiss
     gl_ES: Galician (Spain)/spanish
     hi: Hindi/hindi
-    (hi: Hindi/hindi_compact) # This is a preliminary keyboard layout.
+    hi: Hindi/hindi_compact
     hr: Croatian/qwertz
     hu: Hungarian/qwertz
     hy_AM: Armenian (Armenia) Phonetic/armenian_phonetic
@@ -178,6 +178,7 @@
     />
     <!-- TODO: This bengali keyboard is a preliminary layout.
                This isn't based on the final specification. -->
+    <!--
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0xbff5986c"
@@ -186,6 +187,7 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=bengali,EmojiCapable"
             android:isAsciiCapable="false"
     />
+    -->
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0xd2e520d5"
@@ -346,8 +348,6 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=hindi,EmojiCapable"
             android:isAsciiCapable="false"
     />
-    <!-- TODO: This hindi_compact keyboard is a preliminary layout.
-               This isn't based on the final specification. -->
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic_compact"
             android:subtypeId="0xe49c89a1"
@@ -448,6 +448,7 @@
     />
     <!-- TODO: This kannada keyboard is a preliminary layout.
                This isn't based on the final specification. -->
+    <!--
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x8c78064f"
@@ -456,6 +457,7 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=kannada,EmojiCapable"
             android:isAsciiCapable="false"
     />
+    -->
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x2e391c04"
@@ -498,6 +500,7 @@
     />
     <!-- TODO: This malayalam keyboard is a preliminary layout.
                This isn't based on the final specification. -->
+    <!--
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0xc182ebd4"
@@ -506,6 +509,7 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=malayalam,EmojiCapable"
             android:isAsciiCapable="false"
     />
+    -->
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0xcdcfc3ab"
@@ -516,6 +520,7 @@
     />
     <!-- TODO: This marathi keyboard is a preliminary layout.
                This isn't based on the final specification. -->
+    <!--
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x747b9f03"
@@ -524,6 +529,7 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=marathi,EmojiCapable"
             android:isAsciiCapable="false"
     />
+    -->
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x84c87c61"
@@ -534,6 +540,7 @@
     />
     <!-- TODO: This Myanmar keyboard is a preliminary layout.
                This isn't based on the final specification. -->
+    <!--
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0xea266ea4"
@@ -542,6 +549,7 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=myanmar,EmojiCapable,CombiningRules=MyanmarReordering"
             android:isAsciiCapable="false"
     />
+    -->
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x3f12ee14"
@@ -624,6 +632,7 @@
     />
     <!-- TODO: This sinhala keyboard is a preliminary layout.
                This isn't based on the final specification. -->
+    <!--
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x5c6b3bde"
@@ -632,6 +641,7 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=sinhala,EmojiCapable"
             android:isAsciiCapable="false"
     />
+    -->
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x8e94d413"
@@ -692,6 +702,7 @@
     />
     <!-- TODO: This tamil keyboard is a preliminary layout.
                This isn't based on the final specification. -->
+    <!--
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x67acea2a"
@@ -700,8 +711,10 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=tamil,EmojiCapable"
             android:isAsciiCapable="false"
     />
+    -->
     <!-- TODO: This telugu keyboard is a preliminary layout.
                This isn't based on the final specification. -->
+    <!--
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x1e177389"
@@ -710,6 +723,7 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=telugu,EmojiCapable"
             android:isAsciiCapable="false"
     />
+    -->
     <subtype android:icon="@drawable/ic_ime_switcher_dark"
             android:label="@string/subtype_generic"
             android:subtypeId="0x1f94d5d4"
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index af54fb6..618d389 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -58,7 +58,9 @@
     private final String mHintLabel;
     /** Flags of the label */
     private final int mLabelFlags;
-    private static final int LABEL_FLAGS_ALIGN_LEFT_OF_CENTER = 0x08;
+    private static final int LABEL_FLAGS_ALIGN_HINT_LABEL_TO_BOTTOM = 0x02;
+    private static final int LABEL_FLAGS_ALIGN_ICON_TO_BOTTOM = 0x04;
+    private static final int LABEL_FLAGS_ALIGN_LABEL_OFF_CENTER = 0x08;
     // Font typeface specification.
     private static final int LABEL_FLAGS_FONT_MASK = 0x30;
     private static final int LABEL_FLAGS_FONT_NORMAL = 0x10;
@@ -69,7 +71,6 @@
     private static final int LABEL_FLAGS_FOLLOW_KEY_LARGE_LETTER_RATIO = 0x40;
     private static final int LABEL_FLAGS_FOLLOW_KEY_LETTER_RATIO = 0x80;
     private static final int LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO = 0xC0;
-    private static final int LABEL_FLAGS_FOLLOW_KEY_LARGE_LABEL_RATIO = 0x100;
     private static final int LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO = 0x140;
     // End of key text ratio mask enum values
     private static final int LABEL_FLAGS_HAS_POPUP_HINT = 0x200;
@@ -123,9 +124,10 @@
     public static final int BACKGROUND_TYPE_EMPTY = 0;
     public static final int BACKGROUND_TYPE_NORMAL = 1;
     public static final int BACKGROUND_TYPE_FUNCTIONAL = 2;
-    public static final int BACKGROUND_TYPE_ACTION = 3;
-    public static final int BACKGROUND_TYPE_STICKY_OFF = 4;
-    public static final int BACKGROUND_TYPE_STICKY_ON = 5;
+    public static final int BACKGROUND_TYPE_STICKY_OFF = 3;
+    public static final int BACKGROUND_TYPE_STICKY_ON = 4;
+    public static final int BACKGROUND_TYPE_ACTION = 5;
+    public static final int BACKGROUND_TYPE_CUSTOM_ACTION = 6;
 
     private final int mActionFlags;
     private static final int ACTION_FLAGS_IS_REPEATABLE = 0x01;
@@ -483,9 +485,10 @@
         case BACKGROUND_TYPE_EMPTY: return "empty";
         case BACKGROUND_TYPE_NORMAL: return "normal";
         case BACKGROUND_TYPE_FUNCTIONAL: return "functional";
-        case BACKGROUND_TYPE_ACTION: return "action";
         case BACKGROUND_TYPE_STICKY_OFF: return "stickyOff";
         case BACKGROUND_TYPE_STICKY_ON: return "stickyOn";
+        case BACKGROUND_TYPE_ACTION: return "action";
+        case BACKGROUND_TYPE_CUSTOM_ACTION: return "customAction";
         default: return null;
         }
     }
@@ -577,8 +580,6 @@
             return params.mLargeLetterSize;
         case LABEL_FLAGS_FOLLOW_KEY_LABEL_RATIO:
             return params.mLabelSize;
-        case LABEL_FLAGS_FOLLOW_KEY_LARGE_LABEL_RATIO:
-            return params.mLargeLabelSize;
         case LABEL_FLAGS_FOLLOW_KEY_HINT_LABEL_RATIO:
             return params.mHintLabelSize;
         default: // No follow key ratio flag specified.
@@ -641,8 +642,16 @@
         return Typeface.DEFAULT_BOLD;
     }
 
-    public final boolean isAlignLeftOfCenter() {
-        return (mLabelFlags & LABEL_FLAGS_ALIGN_LEFT_OF_CENTER) != 0;
+    public final boolean isAlignHintLabelToBottom(final int defaultFlags) {
+        return ((mLabelFlags | defaultFlags) & LABEL_FLAGS_ALIGN_HINT_LABEL_TO_BOTTOM) != 0;
+    }
+
+    public final boolean isAlignIconToBottom() {
+        return (mLabelFlags & LABEL_FLAGS_ALIGN_ICON_TO_BOTTOM) != 0;
+    }
+
+    public final boolean isAlignLabelOffCenter() {
+        return (mLabelFlags & LABEL_FLAGS_ALIGN_LABEL_OFF_CENTER) != 0;
     }
 
     public final boolean hasPopupHint() {
@@ -814,47 +823,37 @@
         return dx * dx + dy * dy;
     }
 
-    private final static int[] KEY_STATE_NORMAL_HIGHLIGHT_ON = {
-        android.R.attr.state_checkable,
-        android.R.attr.state_checked
-    };
+    static class KeyBackgroundState {
+        private final int[] mReleasedState;
+        private final int[] mPressedState;
 
-    private final static int[] KEY_STATE_PRESSED_HIGHLIGHT_ON = {
-        android.R.attr.state_pressed,
-        android.R.attr.state_checkable,
-        android.R.attr.state_checked
-    };
+        private KeyBackgroundState(final int ... attrs) {
+            mReleasedState = attrs;
+            mPressedState = Arrays.copyOf(attrs, attrs.length + 1);
+            mPressedState[attrs.length] = android.R.attr.state_pressed;
+        }
 
-    private final static int[] KEY_STATE_NORMAL_HIGHLIGHT_OFF = {
-        android.R.attr.state_checkable
-    };
+        public int[] getState(final boolean pressed) {
+            return pressed ? mPressedState : mReleasedState;
+        }
 
-    private final static int[] KEY_STATE_PRESSED_HIGHLIGHT_OFF = {
-        android.R.attr.state_pressed,
-        android.R.attr.state_checkable
-    };
-
-    private final static int[] KEY_STATE_NORMAL = {
-    };
-
-    private final static int[] KEY_STATE_PRESSED = {
-        android.R.attr.state_pressed
-    };
-
-    private final static int[] KEY_STATE_EMPTY = {
-        android.R.attr.state_empty
-    };
-
-    // action normal state (with properties)
-    private static final int[] KEY_STATE_ACTIVE_NORMAL = {
-            android.R.attr.state_active
-    };
-
-    // action pressed state (with properties)
-    private static final int[] KEY_STATE_ACTIVE_PRESSED = {
-            android.R.attr.state_active,
-            android.R.attr.state_pressed
-    };
+        public static final KeyBackgroundState[] STATES = {
+            // 0: BACKGROUND_TYPE_EMPTY
+            new KeyBackgroundState(android.R.attr.state_empty),
+            // 1: BACKGROUND_TYPE_NORMAL
+            new KeyBackgroundState(),
+            // 2: BACKGROUND_TYPE_FUNCTIONAL
+            new KeyBackgroundState(),
+            // 3: BACKGROUND_TYPE_STICKY_OFF
+            new KeyBackgroundState(android.R.attr.state_checkable),
+            // 4: BACKGROUND_TYPE_STICKY_ON
+            new KeyBackgroundState(android.R.attr.state_checkable, android.R.attr.state_checked),
+            // 5: BACKGROUND_TYPE_ACTION
+            new KeyBackgroundState(android.R.attr.state_active),
+            // 6: BACKGROUND_TYPE_CUSTOM_ACTION
+            new KeyBackgroundState(android.R.attr.state_active, android.R.attr.state_checked)
+        };
+    }
 
     /**
      * Returns the background drawable for the key, based on the current state and type of the key.
@@ -871,28 +870,8 @@
         } else {
             background = keyBackground;
         }
-        final int[] stateSet;
-        switch (mBackgroundType) {
-        case BACKGROUND_TYPE_ACTION:
-            stateSet = mPressed ? KEY_STATE_ACTIVE_PRESSED : KEY_STATE_ACTIVE_NORMAL;
-            break;
-        case BACKGROUND_TYPE_STICKY_OFF:
-            stateSet = mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_OFF : KEY_STATE_NORMAL_HIGHLIGHT_OFF;
-            break;
-        case BACKGROUND_TYPE_STICKY_ON:
-            stateSet = mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_ON : KEY_STATE_NORMAL_HIGHLIGHT_ON;
-            break;
-        case BACKGROUND_TYPE_EMPTY:
-            stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_EMPTY;
-            break;
-        case BACKGROUND_TYPE_FUNCTIONAL:
-            stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
-            break;
-        default: /* BACKGROUND_TYPE_NORMAL */
-            stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
-            break;
-        }
-        background.setState(stateSet);
+        final int[] state = KeyBackgroundState.STATES[mBackgroundType].getState(mPressed);
+        background.setState(state);
         return background;
     }
 
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index 5af0be6..075cd90 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -48,6 +48,7 @@
  * @attr ref R.styleable#KeyboardView_functionalKeyBackground
  * @attr ref R.styleable#KeyboardView_spacebarBackground
  * @attr ref R.styleable#KeyboardView_spacebarIconWidthRatio
+ * @attr ref R.styleable#Keyboard_Key_keyLabelFlags
  * @attr ref R.styleable#KeyboardView_keyHintLetterPadding
  * @attr ref R.styleable#KeyboardView_keyPopupHintLetter
  * @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding
@@ -62,6 +63,8 @@
  * @attr ref R.styleable#Keyboard_Key_keyHintLetterRatio
  * @attr ref R.styleable#Keyboard_Key_keyShiftedLetterHintRatio
  * @attr ref R.styleable#Keyboard_Key_keyHintLabelRatio
+ * @attr ref R.styleable#Keyboard_Key_keyLabelOffCenterRatio
+ * @attr ref R.styleable#Keyboard_Key_keyHintLabelOffCenterRatio
  * @attr ref R.styleable#Keyboard_Key_keyPreviewTextRatio
  * @attr ref R.styleable#Keyboard_Key_keyTextColor
  * @attr ref R.styleable#Keyboard_Key_keyTextColorDisabled
@@ -75,6 +78,9 @@
 public class KeyboardView extends View {
     // XML attributes
     private final KeyVisualAttributes mKeyVisualAttributes;
+    // Default keyLabelFlags from {@link KeyboardTheme}.
+    // Currently only "alignHintLabelToBottom" is supported.
+    private final int mDefaultKeyLabelFlags;
     private final float mKeyHintLetterPadding;
     private final String mKeyPopupHintLetter;
     private final float mKeyPopupHintLetterPadding;
@@ -146,6 +152,7 @@
 
         final TypedArray keyAttr = context.obtainStyledAttributes(attrs,
                 R.styleable.Keyboard_Key, defStyle, R.style.KeyboardView);
+        mDefaultKeyLabelFlags = keyAttr.getInt(R.styleable.Keyboard_Key_keyLabelFlags, 0);
         mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr);
         keyAttr.recycle();
 
@@ -357,7 +364,8 @@
 
         // Draw key label.
         final Drawable icon = key.getIcon(mKeyboard.mIconsSet, params.mAnimAlpha);
-        float positionX = centerX;
+        float labelX = centerX;
+        float labelBaseline = centerY;
         final String label = key.getLabel();
         if (label != null) {
             paint.setTypeface(key.selectTypeface(params));
@@ -366,15 +374,15 @@
             final float labelCharWidth = TypefaceUtils.getReferenceCharWidth(paint);
 
             // Vertical label text alignment.
-            final float baseline = centerY + labelCharHeight / 2.0f;
+            labelBaseline = centerY + labelCharHeight / 2.0f;
 
             // Horizontal label text alignment
-            if (key.isAlignLeftOfCenter()) {
-                // TODO: Parameterise this?
-                positionX = centerX - labelCharWidth * 7.0f / 4.0f;
+            if (key.isAlignLabelOffCenter()) {
+                // The label is placed off center of the key. Used mainly on "phone number" layout.
+                labelX = centerX + params.mLabelOffCenterRatio * labelCharWidth;
                 paint.setTextAlign(Align.LEFT);
             } else {
-                positionX = centerX;
+                labelX = centerX;
                 paint.setTextAlign(Align.CENTER);
             }
             if (key.needsAutoXScale()) {
@@ -402,7 +410,7 @@
                 paint.clearShadowLayer();
             }
             blendAlpha(paint, params.mAnimAlpha);
-            canvas.drawText(label, 0, label.length(), positionX, baseline, paint);
+            canvas.drawText(label, 0, label.length(), labelX, labelBaseline, paint);
             // Turn off drop shadow and reset x-scale.
             paint.clearShadowLayer();
             paint.setTextScaleX(1.0f);
@@ -418,22 +426,22 @@
             blendAlpha(paint, params.mAnimAlpha);
             final float labelCharHeight = TypefaceUtils.getReferenceCharHeight(paint);
             final float labelCharWidth = TypefaceUtils.getReferenceCharWidth(paint);
-            final KeyVisualAttributes visualAttr = key.getVisualAttributes();
-            final float adjustmentY = (visualAttr == null) ? 0.0f
-                    : visualAttr.mHintLabelVerticalAdjustment * labelCharHeight;
-            final float hintX, hintY;
+            final float hintX, hintBaseline;
             if (key.hasHintLabel()) {
                 // The hint label is placed just right of the key label. Used mainly on
                 // "phone number" layout.
-                // TODO: Generalize the following calculations.
-                hintX = positionX + labelCharWidth * 2.0f;
-                hintY = centerY + labelCharHeight / 2.0f;
+                hintX = labelX + params.mHintLabelOffCenterRatio * labelCharWidth;
+                if (key.isAlignHintLabelToBottom(mDefaultKeyLabelFlags)) {
+                    hintBaseline = labelBaseline;
+                } else {
+                    hintBaseline = centerY + labelCharHeight / 2.0f;
+                }
                 paint.setTextAlign(Align.LEFT);
             } else if (key.hasShiftedLetterHint()) {
                 // The hint label is placed at top-right corner of the key. Used mainly on tablet.
                 hintX = keyWidth - mKeyShiftedLetterHintPadding - labelCharWidth / 2.0f;
                 paint.getFontMetrics(mFontMetrics);
-                hintY = -mFontMetrics.top;
+                hintBaseline = -mFontMetrics.top;
                 paint.setTextAlign(Align.CENTER);
             } else { // key.hasHintLetter()
                 // The hint letter is placed at top-right corner of the key. Used mainly on phone.
@@ -441,10 +449,12 @@
                 final float hintLabelWidth = TypefaceUtils.getStringWidth(hintLabel, paint);
                 hintX = keyWidth - mKeyHintLetterPadding
                         - Math.max(hintDigitWidth, hintLabelWidth) / 2.0f;
-                hintY = -paint.ascent();
+                hintBaseline = -paint.ascent();
                 paint.setTextAlign(Align.CENTER);
             }
-            canvas.drawText(hintLabel, 0, hintLabel.length(), hintX, hintY + adjustmentY, paint);
+            final float adjustmentY = params.mHintLabelVerticalAdjustment * labelCharHeight;
+            canvas.drawText(
+                    hintLabel, 0, hintLabel.length(), hintX, hintBaseline + adjustmentY, paint);
         }
 
         // Draw key icon.
@@ -456,9 +466,13 @@
                 iconWidth = Math.min(icon.getIntrinsicWidth(), keyWidth);
             }
             final int iconHeight = icon.getIntrinsicHeight();
-            // Align center.
-            final int iconY = (keyHeight - iconHeight) / 2;
-            final int iconX = (keyWidth - iconWidth) / 2;
+            final int iconY;
+            if (key.isAlignIconToBottom()) {
+                iconY = keyHeight - iconHeight;
+            } else {
+                iconY = (keyHeight - iconHeight) / 2; // Align vertically center.
+            }
+            final int iconX = (keyWidth - iconWidth) / 2; // Align horizontally center.
             drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight);
         }
 
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java
index 07ac06b..df50efd 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyDrawParams.java
@@ -26,7 +26,6 @@
     public int mLetterSize;
     public int mLabelSize;
     public int mLargeLetterSize;
-    public int mLargeLabelSize;
     public int mHintLetterSize;
     public int mShiftedLetterHintSize;
     public int mHintLabelSize;
@@ -42,6 +41,10 @@
     public int mShiftedLetterHintActivatedColor;
     public int mPreviewTextColor;
 
+    public float mHintLabelVerticalAdjustment;
+    public float mLabelOffCenterRatio;
+    public float mHintLabelOffCenterRatio;
+
     public int mAnimAlpha;
 
     public KeyDrawParams() {}
@@ -52,7 +55,6 @@
         mLetterSize = copyFrom.mLetterSize;
         mLabelSize = copyFrom.mLabelSize;
         mLargeLetterSize = copyFrom.mLargeLetterSize;
-        mLargeLabelSize = copyFrom.mLargeLabelSize;
         mHintLetterSize = copyFrom.mHintLetterSize;
         mShiftedLetterHintSize = copyFrom.mShiftedLetterHintSize;
         mHintLabelSize = copyFrom.mHintLabelSize;
@@ -68,6 +70,10 @@
         mShiftedLetterHintActivatedColor = copyFrom.mShiftedLetterHintActivatedColor;
         mPreviewTextColor = copyFrom.mPreviewTextColor;
 
+        mHintLabelVerticalAdjustment = copyFrom.mHintLabelVerticalAdjustment;
+        mLabelOffCenterRatio = copyFrom.mLabelOffCenterRatio;
+        mHintLabelOffCenterRatio = copyFrom.mHintLabelOffCenterRatio;
+
         mAnimAlpha = copyFrom.mAnimAlpha;
     }
 
@@ -84,7 +90,6 @@
                 attr.mLetterSize, attr.mLetterRatio, mLetterSize);
         mLabelSize = selectTextSizeFromDimensionOrRatio(keyHeight,
                 attr.mLabelSize, attr.mLabelRatio, mLabelSize);
-        mLargeLabelSize = selectTextSize(keyHeight, attr.mLargeLabelRatio, mLargeLabelSize);
         mLargeLetterSize = selectTextSize(keyHeight, attr.mLargeLetterRatio, mLargeLetterSize);
         mHintLetterSize = selectTextSize(keyHeight, attr.mHintLetterRatio, mHintLetterSize);
         mShiftedLetterHintSize = selectTextSize(keyHeight,
@@ -103,6 +108,13 @@
         mShiftedLetterHintActivatedColor = selectColor(
                 attr.mShiftedLetterHintActivatedColor, mShiftedLetterHintActivatedColor);
         mPreviewTextColor = selectColor(attr.mPreviewTextColor, mPreviewTextColor);
+
+        mHintLabelVerticalAdjustment = selectFloatIfNonZero(
+                attr.mHintLabelVerticalAdjustment, mHintLabelVerticalAdjustment);
+        mLabelOffCenterRatio = selectFloatIfNonZero(
+                attr.mLabelOffCenterRatio, mLabelOffCenterRatio);
+        mHintLabelOffCenterRatio = selectFloatIfNonZero(
+                attr.mHintLabelOffCenterRatio, mHintLabelOffCenterRatio);
     }
 
     public KeyDrawParams mayCloneAndUpdateParams(final int keyHeight,
@@ -115,7 +127,7 @@
         return newParams;
     }
 
-    private static final int selectTextSizeFromDimensionOrRatio(final int keyHeight,
+    private static int selectTextSizeFromDimensionOrRatio(final int keyHeight,
             final int dimens, final float ratio, final int defaultDimens) {
         if (ResourceUtils.isValidDimensionPixelSize(dimens)) {
             return dimens;
@@ -126,7 +138,7 @@
         return defaultDimens;
     }
 
-    private static final int selectTextSize(final int keyHeight, final float ratio,
+    private static int selectTextSize(final int keyHeight, final float ratio,
             final int defaultSize) {
         if (ResourceUtils.isValidFraction(ratio)) {
             return (int)(keyHeight * ratio);
@@ -134,10 +146,17 @@
         return defaultSize;
     }
 
-    private static final int selectColor(final int attrColor, final int defaultColor) {
+    private static int selectColor(final int attrColor, final int defaultColor) {
         if (attrColor != 0) {
             return attrColor;
         }
         return defaultColor;
     }
+
+    private static float selectFloatIfNonZero(final float attrFloat, final float defaultFloat) {
+        if (attrFloat != 0) {
+            return attrFloat;
+        }
+        return defaultFloat;
+    }
 }
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java b/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java
index 133462a..c60d587 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyVisualAttributes.java
@@ -31,7 +31,6 @@
     public final float mLabelRatio;
     public final int mLabelSize;
     public final float mLargeLetterRatio;
-    public final float mLargeLabelRatio;
     public final float mHintLetterRatio;
     public final float mShiftedLetterHintRatio;
     public final float mHintLabelRatio;
@@ -48,13 +47,14 @@
     public final int mPreviewTextColor;
 
     public final float mHintLabelVerticalAdjustment;
+    public final float mLabelOffCenterRatio;
+    public final float mHintLabelOffCenterRatio;
 
     private static final int[] VISUAL_ATTRIBUTE_IDS = {
         R.styleable.Keyboard_Key_keyTypeface,
         R.styleable.Keyboard_Key_keyLetterSize,
         R.styleable.Keyboard_Key_keyLabelSize,
         R.styleable.Keyboard_Key_keyLargeLetterRatio,
-        R.styleable.Keyboard_Key_keyLargeLabelRatio,
         R.styleable.Keyboard_Key_keyHintLetterRatio,
         R.styleable.Keyboard_Key_keyShiftedLetterHintRatio,
         R.styleable.Keyboard_Key_keyHintLabelRatio,
@@ -69,6 +69,8 @@
         R.styleable.Keyboard_Key_keyShiftedLetterHintActivatedColor,
         R.styleable.Keyboard_Key_keyPreviewTextColor,
         R.styleable.Keyboard_Key_keyHintLabelVerticalAdjustment,
+        R.styleable.Keyboard_Key_keyLabelOffCenterRatio,
+        R.styleable.Keyboard_Key_keyHintLabelOffCenterRatio
     };
     private static final SparseIntArray sVisualAttributeIds = new SparseIntArray();
     private static final int ATTR_DEFINED = 1;
@@ -109,8 +111,6 @@
                 R.styleable.Keyboard_Key_keyLabelSize);
         mLargeLetterRatio = ResourceUtils.getFraction(keyAttr,
                 R.styleable.Keyboard_Key_keyLargeLetterRatio);
-        mLargeLabelRatio = ResourceUtils.getFraction(keyAttr,
-                R.styleable.Keyboard_Key_keyLargeLabelRatio);
         mHintLetterRatio = ResourceUtils.getFraction(keyAttr,
                 R.styleable.Keyboard_Key_keyHintLetterRatio);
         mShiftedLetterHintRatio = ResourceUtils.getFraction(keyAttr,
@@ -135,5 +135,9 @@
 
         mHintLabelVerticalAdjustment = ResourceUtils.getFraction(keyAttr,
                 R.styleable.Keyboard_Key_keyHintLabelVerticalAdjustment, 0.0f);
+        mLabelOffCenterRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyLabelOffCenterRatio, 0.0f);
+        mHintLabelOffCenterRatio = ResourceUtils.getFraction(keyAttr,
+                R.styleable.Keyboard_Key_keyHintLabelOffCenterRatio, 0.0f);
     }
 }
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index c7c3aaa..3a5f85d 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -295,8 +295,7 @@
             }
         }
 
-        public void postResetInputConnectionCaches(final boolean tryResumeSuggestions,
-                final int remainingTries) {
+        public void postResetCaches(final boolean tryResumeSuggestions, final int remainingTries) {
             removeMessages(MSG_RESET_CACHES);
             sendMessage(obtainMessage(MSG_RESET_CACHES, tryResumeSuggestions ? 1 : 0,
                     remainingTries, null));
@@ -753,92 +752,20 @@
         loadKeyboard();
     }
 
-    /**
-     * A class that holds information to pass from onStartInputInternal to onStartInputViewInternal
-     *
-     * OnStartInput needs to reload the settings and that will prevent onStartInputViewInternal
-     * from comparing the old settings with the new ones, so we use this memory to pass the
-     * necessary information along.
-     */
-    private static class EditorChangeInfo {
-        public final boolean mIsSameInputType;
-        public final boolean mHasSameOrientation;
-        public final boolean mCanReachInputConnection;
-        public EditorChangeInfo(final boolean isSameInputType, final boolean hasSameOrientation,
-                final boolean canReachInputConnection) {
-            mIsSameInputType = isSameInputType;
-            mHasSameOrientation = hasSameOrientation;
-            mCanReachInputConnection = canReachInputConnection;
-        }
-    }
-
-    private EditorChangeInfo mLastEditorChangeInfo;
-
     private void onStartInputInternal(final EditorInfo editorInfo, final boolean restarting) {
         super.onStartInput(editorInfo, restarting);
-        if (editorInfo == null) {
-            Log.e(TAG, "Null EditorInfo in onStartInput()");
-            return;
-        }
-        SettingsValues currentSettingsValues = mSettings.getCurrent();
-        final boolean isSameInputType = currentSettingsValues.isSameInputType(editorInfo);
-        final boolean hasSameOrientation =
-                currentSettingsValues.hasSameOrientation(getResources().getConfiguration());
-        mRichImm.clearSubtypeCaches();
-        final boolean inputTypeChanged = !isSameInputType;
-        final boolean isDifferentTextField = !restarting || inputTypeChanged;
-        if (isDifferentTextField || !hasSameOrientation) {
-            loadSettings();
-            currentSettingsValues = mSettings.getCurrent();
-        }
-
-        // Note: the following does a round-trip IPC on the main thread: be careful
-        final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
-        final Suggest suggest = mInputLogic.mSuggest;
-        if (null != currentLocale && !currentLocale.equals(suggest.getLocale())) {
-            // TODO: Do this automatically.
-            resetSuggest();
-        }
-        if (isDifferentTextField && currentSettingsValues.mAutoCorrectionEnabledPerUserSettings) {
-            suggest.setAutoCorrectionThreshold(currentSettingsValues.mAutoCorrectionThreshold);
-        }
-
-        // The app calling setText() has the effect of clearing the composing
-        // span, so we should reset our state unconditionally, even if restarting is true.
-        // We also tell the input logic about the combining rules for the current subtype, so
-        // it can adjust its combiners if needed.
-        mInputLogic.startInput(mSubtypeSwitcher.getCombiningRulesExtraValueOfCurrentSubtype());
-        // TODO[IL]: Can the following be moved to InputLogic#startInput?
-        final boolean canReachInputConnection;
-        if (!mInputLogic.mConnection.resetCachesUponCursorMoveAndReturnSuccess(
-                editorInfo.initialSelStart, editorInfo.initialSelEnd,
-                false /* shouldFinishComposition */)) {
-            // Sometimes, while rotating, for some reason the framework tells the app we are not
-            // connected to it and that means we can't refresh the cache. In this case, schedule a
-            // refresh later.
-            // We try resetting the caches up to 5 times before giving up.
-            mHandler.postResetInputConnectionCaches(isDifferentTextField || !hasSameOrientation,
-                    5 /* remainingTries */);
-            canReachInputConnection = false;
-        } else {
-            // When rotating, initialSelStart and initialSelEnd sometimes are lying. Make a best
-            // effort to work around this bug.
-            mInputLogic.mConnection.tryFixLyingCursorPosition();
-            mHandler.postResumeSuggestions(true /* shouldIncludeResumedWordInSuggestions */,
-                    true /* shouldDelay */);
-            canReachInputConnection = true;
-        }
-
-        mLastEditorChangeInfo = new EditorChangeInfo(isSameInputType, hasSameOrientation,
-                canReachInputConnection);
     }
 
     @SuppressWarnings("deprecation")
     private void onStartInputViewInternal(final EditorInfo editorInfo, final boolean restarting) {
         super.onStartInputView(editorInfo, restarting);
+        mRichImm.clearSubtypeCaches();
         final KeyboardSwitcher switcher = mKeyboardSwitcher;
         switcher.updateKeyboardTheme();
         final MainKeyboardView mainKeyboardView = switcher.getMainKeyboardView();
+        // If we are starting input in a different text field from before, we'll have to reload
+        // settings, so currentSettingsValues can't be final.
+        SettingsValues currentSettingsValues = mSettings.getCurrent();
 
         if (editorInfo == null) {
             Log.e(TAG, "Null EditorInfo in onStartInputView()");
@@ -881,7 +808,7 @@
             accessUtils.onStartInputViewInternal(mainKeyboardView, editorInfo, restarting);
         }
 
-        final boolean inputTypeChanged = !mLastEditorChangeInfo.mIsSameInputType;
+        final boolean inputTypeChanged = !currentSettingsValues.isSameInputType(editorInfo);
         final boolean isDifferentTextField = !restarting || inputTypeChanged;
         if (isDifferentTextField) {
             mSubtypeSwitcher.updateParametersOnStartInputView();
@@ -891,13 +818,57 @@
         // Note: This call should be done by InputMethodService?
         updateFullscreenMode();
 
-        final SettingsValues currentSettingsValues = mSettings.getCurrent();
+        // The app calling setText() has the effect of clearing the composing
+        // span, so we should reset our state unconditionally, even if restarting is true.
+        // We also tell the input logic about the combining rules for the current subtype, so
+        // it can adjust its combiners if needed.
+        mInputLogic.startInput(mSubtypeSwitcher.getCombiningRulesExtraValueOfCurrentSubtype());
+
+        // Note: the following does a round-trip IPC on the main thread: be careful
+        final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
+        final Suggest suggest = mInputLogic.mSuggest;
+        if (null != currentLocale && !currentLocale.equals(suggest.getLocale())) {
+            // TODO: Do this automatically.
+            resetSuggest();
+        }
+
+        // TODO[IL]: Can the following be moved to InputLogic#startInput?
+        final boolean canReachInputConnection;
+        if (!mInputLogic.mConnection.resetCachesUponCursorMoveAndReturnSuccess(
+                editorInfo.initialSelStart, editorInfo.initialSelEnd,
+                false /* shouldFinishComposition */)) {
+            // Sometimes, while rotating, for some reason the framework tells the app we are not
+            // connected to it and that means we can't refresh the cache. In this case, schedule a
+            // refresh later.
+            // We try resetting the caches up to 5 times before giving up.
+            mHandler.postResetCaches(isDifferentTextField, 5 /* remainingTries */);
+            // mLastSelection{Start,End} are reset later in this method, don't need to do it here
+            canReachInputConnection = false;
+        } else {
+            // When rotating, initialSelStart and initialSelEnd sometimes are lying. Make a best
+            // effort to work around this bug.
+            mInputLogic.mConnection.tryFixLyingCursorPosition();
+            mHandler.postResumeSuggestions(true /* shouldIncludeResumedWordInSuggestions */,
+                    true /* shouldDelay */);
+            canReachInputConnection = true;
+        }
+
+        if (isDifferentTextField ||
+                !currentSettingsValues.hasSameOrientation(getResources().getConfiguration())) {
+            loadSettings();
+        }
         if (isDifferentTextField) {
             mainKeyboardView.closing();
+            currentSettingsValues = mSettings.getCurrent();
+
+            if (currentSettingsValues.mAutoCorrectionEnabledPerUserSettings) {
+                suggest.setAutoCorrectionThreshold(
+                        currentSettingsValues.mAutoCorrectionThreshold);
+            }
 
             switcher.loadKeyboard(editorInfo, currentSettingsValues, getCurrentAutoCapsState(),
                     getCurrentRecapitalizeState());
-            if (!mLastEditorChangeInfo.mCanReachInputConnection) {
+            if (!canReachInputConnection) {
                 // If we can't reach the input connection, we will call loadKeyboard again later,
                 // so we need to save its state now. The call will be done in #retryResetCaches.
                 switcher.saveKeyboardState();
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 2be7920..418866a 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -2035,7 +2035,7 @@
                 mConnection.getExpectedSelectionStart(), mConnection.getExpectedSelectionEnd(),
                 shouldFinishComposition)) {
             if (0 < remainingTries) {
-                handler.postResetInputConnectionCaches(tryResumeSuggestions, remainingTries - 1);
+                handler.postResetCaches(tryResumeSuggestions, remainingTries - 1);
                 return false;
             }
             // If remainingTries is 0, we should stop waiting for new tries, however we'll still
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
index eb67bc1..e6f38e8 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
@@ -25,7 +25,7 @@
 
 @SmallTest
 public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase {
-    private static final int NUMBER_OF_SUBTYPES = 77;
+    private static final int NUMBER_OF_SUBTYPES = 69;
     private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 45;
     private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
 
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBengaliIN.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBengaliIN.java
index d642632..10ca3d8 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBengaliIN.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBengaliIN.java
@@ -16,7 +16,7 @@
 
 package com.android.inputmethod.keyboard.layout.tests;
 
-import android.test.suitebuilder.annotation.SmallTest;
+import android.test.suitebuilder.annotation.Suppress;
 
 import com.android.inputmethod.keyboard.layout.Bengali;
 import com.android.inputmethod.keyboard.layout.Bengali.BengaliCustomizer;
@@ -29,7 +29,7 @@
 /**
  * bn_IN: Bengali (India)/bengali
  */
-@SmallTest
+@Suppress
 public final class TestsBengaliIN extends LayoutTestsBase {
     private static final Locale LOCALE = new Locale("bn", "IN");
     private static final LayoutBase LAYOUT = new Bengali(new BengaliINCustomzier(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKannadaIN.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKannadaIN.java
index d1866e8..70ff173 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKannadaIN.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKannadaIN.java
@@ -16,7 +16,7 @@
 
 package com.android.inputmethod.keyboard.layout.tests;
 
-import android.test.suitebuilder.annotation.SmallTest;
+import android.test.suitebuilder.annotation.Suppress;
 
 import com.android.inputmethod.keyboard.layout.Kannada;
 import com.android.inputmethod.keyboard.layout.Kannada.KannadaCustomizer;
@@ -27,7 +27,7 @@
 /**
  * kn_IN: Kannada (India)/kannada
  */
-@SmallTest
+@Suppress
 public final class TestsKannadaIN extends LayoutTestsBase {
     private static final Locale LOCALE = new Locale("kn", "IN");
     private static final LayoutBase LAYOUT = new Kannada(new KannadaCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMalayalamIN.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMalayalamIN.java
index f937de8..60c9e90 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMalayalamIN.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMalayalamIN.java
@@ -16,7 +16,7 @@
 
 package com.android.inputmethod.keyboard.layout.tests;
 
-import android.test.suitebuilder.annotation.SmallTest;
+import android.test.suitebuilder.annotation.Suppress;
 
 import com.android.inputmethod.keyboard.layout.LayoutBase;
 import com.android.inputmethod.keyboard.layout.Malayalam;
@@ -25,9 +25,9 @@
 import java.util.Locale;
 
 /**
- * ta_IN: Malayalam (India)/malayalam
+ * ml_IN: Malayalam (India)/malayalam
  */
-@SmallTest
+@Suppress
 public final class TestsMalayalamIN extends LayoutTestsBase {
     private static final Locale LOCALE = new Locale("ml", "IN");
     private static final LayoutBase LAYOUT = new Malayalam(new MalayalamCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMarathiIN.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMarathiIN.java
index b937629..d45d99d 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMarathiIN.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMarathiIN.java
@@ -16,7 +16,7 @@
 
 package com.android.inputmethod.keyboard.layout.tests;
 
-import android.test.suitebuilder.annotation.SmallTest;
+import android.test.suitebuilder.annotation.Suppress;
 
 import com.android.inputmethod.keyboard.layout.LayoutBase;
 import com.android.inputmethod.keyboard.layout.Marathi;
@@ -27,7 +27,7 @@
 /**
  * mr_IN: Marathi (India)/marathi
  */
-@SmallTest
+@Suppress
 public final class TestsMarathiIN extends LayoutTestsBase {
     private static final Locale LOCALE = new Locale("mr", "IN");
     private static final LayoutBase LAYOUT = new Marathi(new MarathiCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMyanmarMM.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMyanmarMM.java
index e6d3b3b..a0bd50c 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMyanmarMM.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMyanmarMM.java
@@ -16,7 +16,7 @@
 
 package com.android.inputmethod.keyboard.layout.tests;
 
-import android.test.suitebuilder.annotation.SmallTest;
+import android.test.suitebuilder.annotation.Suppress;
 
 import com.android.inputmethod.keyboard.layout.LayoutBase;
 import com.android.inputmethod.keyboard.layout.Myanmar;
@@ -27,7 +27,7 @@
 /**
  * my_MM: Myanmar (Myanmar)/myanmar
  */
-@SmallTest
+@Suppress
 public final class TestsMyanmarMM extends LayoutTestsBase {
     private static final Locale LOCALE = new Locale("my", "MM");
     private static final LayoutBase LAYOUT = new Myanmar(new MyanmarCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java
index 1cea497..8b86135 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java
@@ -16,7 +16,7 @@
 
 package com.android.inputmethod.keyboard.layout.tests;
 
-import android.test.suitebuilder.annotation.SmallTest;
+import android.test.suitebuilder.annotation.Suppress;
 
 import com.android.inputmethod.keyboard.layout.LayoutBase;
 import com.android.inputmethod.keyboard.layout.Sinhala;
@@ -27,7 +27,7 @@
 /**
  * si_LK: Sinhala (Sri Lanka)/sinhala
  */
-@SmallTest
+@Suppress
 public final class TestsSinhalaLK extends LayoutTestsBase {
     private static final Locale LOCALE = new Locale("si", "LK");
     private static final LayoutBase LAYOUT = new Sinhala(new SinhalaCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTamilIN.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTamilIN.java
index 5b3649d..23d8778 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTamilIN.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTamilIN.java
@@ -16,7 +16,7 @@
 
 package com.android.inputmethod.keyboard.layout.tests;
 
-import android.test.suitebuilder.annotation.SmallTest;
+import android.test.suitebuilder.annotation.Suppress;
 
 import com.android.inputmethod.keyboard.layout.LayoutBase;
 import com.android.inputmethod.keyboard.layout.Tamil;
@@ -27,7 +27,7 @@
 /**
  * ta_IN: Tamil (India)/tamil
  */
-@SmallTest
+@Suppress
 public final class TestsTamilIN extends LayoutTestsBase {
     private static final Locale LOCALE = new Locale("ta", "IN");
     private static final LayoutBase LAYOUT = new Tamil(new TamilCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTeluguIN.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTeluguIN.java
index 04996d9..82046a5 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTeluguIN.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTeluguIN.java
@@ -16,7 +16,7 @@
 
 package com.android.inputmethod.keyboard.layout.tests;
 
-import android.test.suitebuilder.annotation.SmallTest;
+import android.test.suitebuilder.annotation.Suppress;
 
 import com.android.inputmethod.keyboard.layout.LayoutBase;
 import com.android.inputmethod.keyboard.layout.Telugu;
@@ -27,7 +27,7 @@
 /**
  * te_IN: Telugu (India)/telugu
  */
-@SmallTest
+@Suppress
 public final class TestsTeluguIN extends LayoutTestsBase {
     private static final Locale LOCALE = new Locale("te", "IN");
     private static final LayoutBase LAYOUT = new Telugu(new TeluguCustomizer(LOCALE));
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java
index 61eae4e..ab69c85 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsReorderingMyanmar.java
@@ -17,6 +17,7 @@
 package com.android.inputmethod.latin;
 
 import android.test.suitebuilder.annotation.LargeTest;
+import android.test.suitebuilder.annotation.Suppress;
 import android.util.Pair;
 
 /*
@@ -77,6 +78,8 @@
  */
 
 @LargeTest
+// These tests are inactive until the combining code for Myanmar Reordering is sorted out.
+@Suppress
 @SuppressWarnings("rawtypes")
 public class InputLogicTestsReorderingMyanmar extends InputTestsBase {
     // The tests are formatted as follows.
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java
index 0843719..eabd8d7 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictEncoderUtils.java
@@ -802,20 +802,13 @@
         }
 
         MakedictLog.i("Statistics:\n"
-                + "  total file size " + size + "\n"
+                + "  Total file size " + size + "\n"
                 + "  " + ptNodeArrays.size() + " node arrays\n"
                 + "  " + ptNodes + " PtNodes (" + ((float)ptNodes / ptNodeArrays.size())
                         + " PtNodes per node)\n"
-                + "  first terminal at " + firstTerminalAddress + "\n"
-                + "  last terminal at " + lastTerminalAddress + "\n"
+                + "  First terminal at " + firstTerminalAddress + "\n"
+                + "  Last terminal at " + lastTerminalAddress + "\n"
                 + "  PtNode stats : max = " + maxNodes);
-        for (int i = 0; i < ptNodeCounts.length; ++i) {
-            MakedictLog.i("    " + i + " : " + ptNodeCounts[i]);
-        }
-        MakedictLog.i("  Character run stats : max = " + maxRuns);
-        for (int i = 0; i < runCounts.length; ++i) {
-            MakedictLog.i("    " + i + " : " + runCounts[i]);
-        }
     }
 
     /**