Merge "Revert "Fix Emoji key feedback""
diff --git a/java/res/xml-sw600dp/key_space_3kw.xml b/java/res/xml-sw600dp/key_space_3kw.xml
index 9932d34..8cc3a38 100644
--- a/java/res/xml-sw600dp/key_space_3kw.xml
+++ b/java/res/xml-sw600dp/key_space_3kw.xml
@@ -22,12 +22,8 @@
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
     <switch>
-        <!-- fa: Perisan
-             kn: Kannada
-             ne: Nepali
-             te: Telugu -->
         <case
-            latin:languageCode="fa|kn|ne|te"
+            latin:keyboardLayoutSet="bengali_akkhor|farsi|kannada|nepali_romanized|nepali_traditional|telugu"
             latin:languageSwitchKeyEnabled="true"
         >
             <Key
@@ -39,7 +35,7 @@
                 latin:keyStyle="zwnjKeyStyle" />
         </case>
         <case
-            latin:languageCode="fa|kn|ne|te"
+            latin:keyboardLayoutSet="bengali_akkhor|farsi|kannada|nepali_romanized|nepali_traditional|telugu"
             latin:languageSwitchKeyEnabled="false"
         >
             <Key
diff --git a/java/res/xml-sw600dp/key_space_7kw.xml b/java/res/xml-sw600dp/key_space_7kw.xml
index 3311f81..61e0765 100644
--- a/java/res/xml-sw600dp/key_space_7kw.xml
+++ b/java/res/xml-sw600dp/key_space_7kw.xml
@@ -22,12 +22,8 @@
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
     <switch>
-        <!-- fa: Perisan
-             kn: Kannada
-             ne: Nepali
-             te: Telugu -->
         <case
-            latin:languageCode="fa|kn|ne|te"
+            latin:keyboardLayoutSet="bengali_akkhor|farsi|kannada|nepali_romanized|nepali_traditional|telugu"
             latin:languageSwitchKeyEnabled="true"
         >
             <Key
@@ -39,7 +35,7 @@
                 latin:keyStyle="zwnjKeyStyle" />
         </case>
         <case
-            latin:languageCode="fa|kn|ne|te"
+            latin:keyboardLayoutSet="bengali_akkhor|farsi|kannada|nepali_romanized|nepali_traditional|telugu"
             latin:languageSwitchKeyEnabled="false"
         >
             <Key
diff --git a/java/res/xml-sw600dp/rows_number_normal.xml b/java/res/xml-sw600dp/rows_number_normal.xml
index 7a4700d..e6fdf73 100644
--- a/java/res/xml-sw600dp/rows_number_normal.xml
+++ b/java/res/xml-sw600dp/rows_number_normal.xml
@@ -24,17 +24,17 @@
     <Row>
         <Key
             latin:keySpec="-"
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
             latin:keySpec="+"
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
             latin:keySpec="."
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
@@ -53,13 +53,15 @@
             latin:keyWidth="fillRight" />
     </Row>
     <Row>
+        <!-- U+FF0A: "*" FULLWIDTH ASTERISK -->
         <Key
-            latin:keyStyle="numStarKeyStyle"
+            latin:keySpec="&#xFF0A;|*"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
             latin:keySpec="/"
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <switch>
@@ -70,14 +72,14 @@
                     latin:keySpec=","
                     latin:keyLabelFlags="hasPopupHint"
                     latin:moreKeys="!text/morekeys_am_pm"
-                    latin:keyStyle="numKeyStyle"
+                    latin:keyStyle="numSymbolKeyStyle"
                     latin:keyWidth="10%p"
                     latin:backgroundType="functional" />
             </case>
             <default>
                 <Key
                     latin:keySpec=","
-                    latin:keyStyle="numKeyStyle"
+                    latin:keyStyle="numSymbolKeyStyle"
                     latin:keyWidth="10%p"
                     latin:backgroundType="functional" />
             </default>
@@ -100,12 +102,12 @@
     <Row>
         <Key
             latin:keySpec="("
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
             latin:keySpec=")"
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <switch>
@@ -114,14 +116,14 @@
             >
                 <Key
                     latin:keySpec=":"
-                    latin:keyStyle="numKeyStyle"
+                    latin:keyStyle="numSymbolKeyStyle"
                     latin:keyWidth="10%p"
                     latin:backgroundType="functional" />
             </case>
             <default>
                 <Key
                     latin:keySpec="="
-                    latin:keyStyle="numKeyStyle"
+                    latin:keyStyle="numSymbolKeyStyle"
                     latin:keyWidth="10%p"
                     latin:backgroundType="functional" />
             </default>
@@ -143,8 +145,10 @@
         <Key
             latin:keyStyle="tabletNumSpaceKeyStyle"
             latin:keyWidth="30%p" />
+        <!-- U+FF0A: "*" FULLWIDTH ASTERISK -->
         <Key
-            latin:keyStyle="numStarKeyStyle"
+            latin:keySpec="&#xFF0A;|*"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyXPos="31%p" />
         <Key
             latin:keySpec="0"
diff --git a/java/res/xml-sw600dp/rows_phone.xml b/java/res/xml-sw600dp/rows_phone.xml
index e598c96..fc86a76 100644
--- a/java/res/xml-sw600dp/rows_phone.xml
+++ b/java/res/xml-sw600dp/rows_phone.xml
@@ -28,16 +28,18 @@
     <Row>
         <Key
             latin:keySpec="-"
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
             latin:keySpec="+"
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
-            latin:keyStyle="numPauseKeyStyle"
+            latin:keySpec="!string/label_pause_key|,"
+            latin:keyLabelFlags="followKeyLabelRatio|autoXScale"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
@@ -55,16 +57,18 @@
     <Row>
         <Key
             latin:keySpec=","
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
             latin:keySpec="."
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
-            latin:keyStyle="numWaitKeyStyle"
+            latin:keySpec="!string/label_wait_key|;"
+            latin:keyLabelFlags="followKeyLabelRatio|autoXScale"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
@@ -82,17 +86,17 @@
     <Row>
         <Key
             latin:keySpec="("
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
             latin:keySpec=")"
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
             latin:keySpec="N"
-            latin:keyStyle="numKeyStyle"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyWidth="10%p"
             latin:backgroundType="functional" />
         <Key
@@ -109,14 +113,16 @@
         <Key
             latin:keyStyle="tabletNumSpaceKeyStyle"
             latin:keyWidth="30%p" />
+        <!-- U+FF0A: "*" FULLWIDTH ASTERISK -->
         <Key
-            latin:keyStyle="numStarKeyStyle"
+            latin:keySpec="&#xFF0A;|*"
+            latin:keyStyle="numSymbolKeyStyle"
             latin:keyXPos="31%p" />
         <Key
             latin:keyStyle="num0KeyStyle"
             latin:keyHintLabel="+" />
         <Key
             latin:keySpec="\#"
-            latin:keyStyle="numKeyStyle" />
+            latin:keyStyle="numSymbolKeyStyle" />
     </Row>
 </merge>
diff --git a/java/res/xml/key_space_5kw.xml b/java/res/xml/key_space_5kw.xml
index b1fe0bb..692c245 100644
--- a/java/res/xml/key_space_5kw.xml
+++ b/java/res/xml/key_space_5kw.xml
@@ -22,12 +22,8 @@
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
     <switch>
-        <!-- fa: Perisan
-             kn: Kannada
-             ne: Nepali
-             te: Telugu -->
         <case
-            latin:languageCode="fa|kn|ne|te"
+            latin:keyboardLayoutSet="bengali_akkhor|farsi|kannada|nepali_romanized|nepali_traditional|telugu"
             latin:languageSwitchKeyEnabled="true"
         >
             <Key
@@ -39,7 +35,7 @@
                 latin:keyStyle="zwnjKeyStyle" />
         </case>
         <case
-            latin:languageCode="fa|kn|ne|te"
+            latin:keyboardLayoutSet="bengali_akkhor|farsi|kannada|nepali_romanized|nepali_traditional|telugu"
             latin:languageSwitchKeyEnabled="false"
         >
             <Key
diff --git a/java/res/xml/key_styles_number.xml b/java/res/xml/key_styles_number.xml
index aac0976..911c276 100644
--- a/java/res/xml/key_styles_number.xml
+++ b/java/res/xml/key_styles_number.xml
@@ -33,9 +33,7 @@
         latin:keyLabelFlags="fontNormal|followKeyLetterRatio|followFunctionalTextColor"
         latin:parentStyle="numKeyBaseStyle" />
     <key-style
-        latin:styleName="numFunctionalKeyStyle"
-        latin:keyLabelFlags="followKeyLargeLetterRatio"
-        latin:backgroundType="functional"
+        latin:styleName="numSymbolKeyStyle"
         latin:parentStyle="numKeyBaseStyle" />
     <key-style
         latin:styleName="numberKeyStyle"
@@ -89,11 +87,6 @@
         latin:keySpec="9"
         latin:keyHintLabel="WXYZ"
         latin:parentStyle="numberKeyStyle" />
-    <!-- U+FF0A: "*" FULLWIDTH ASTERISK -->
-    <key-style
-        latin:styleName="numStarKeyStyle"
-        latin:keySpec="&#xFF0A;|*"
-        latin:parentStyle="numKeyStyle" />
     <!-- Only for non-tablet device -->
     <key-style
         latin:styleName="numPhoneToSymbolKeyStyle"
@@ -104,16 +97,6 @@
         latin:keySpec="!text/keylabel_to_phone_numeric|!code/key_switch_alpha_symbol"
         latin:parentStyle="numModeKeyStyle" />
     <key-style
-        latin:styleName="numPauseKeyStyle"
-        latin:keySpec="!text/label_pause_key|,"
-        latin:keyLabelFlags="followKeyLabelRatio|autoXScale"
-        latin:parentStyle="numKeyBaseStyle" />
-    <key-style
-        latin:styleName="numWaitKeyStyle"
-        latin:keySpec="!text/label_wait_key|;"
-        latin:keyLabelFlags="followKeyLabelRatio|autoXScale"
-        latin:parentStyle="numKeyBaseStyle" />
-    <key-style
         latin:styleName="numTabKeyStyle"
         latin:keyActionFlags="noKeyPreview"
         latin:parentStyle="tabKeyStyle" />
diff --git a/java/res/xml/keyboard_layout_set_bengali_akkhor.xml b/java/res/xml/keyboard_layout_set_bengali_akkhor.xml
index b2b09b2..267064d 100644
--- a/java/res/xml/keyboard_layout_set_bengali_akkhor.xml
+++ b/java/res/xml/keyboard_layout_set_bengali_akkhor.xml
@@ -19,7 +19,7 @@
 -->
 
 <KeyboardLayoutSet xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" >
-    <Feature latin:supportedScript="devanagari" />
+    <Feature latin:supportedScript="bengali" />
     <Element
         latin:elementKeyboard="@xml/kbd_bengali_akkhor"
         latin:elementName="alphabet"
diff --git a/java/res/xml/rows_number_normal.xml b/java/res/xml/rows_number_normal.xml
index d8d1508..0f92ac6 100644
--- a/java/res/xml/rows_number_normal.xml
+++ b/java/res/xml/rows_number_normal.xml
@@ -35,7 +35,8 @@
             latin:keySpec="-"
             latin:moreKeys="+"
             latin:keyLabelFlags="hasPopupHint"
-            latin:keyStyle="numFunctionalKeyStyle"
+            latin:keyStyle="numKeyStyle"
+            latin:backgroundType="functional"
             latin:keyWidth="fillRight" />
     </Row>
     <Row>
@@ -54,7 +55,8 @@
             >
                 <Key
                     latin:keySpec="."
-                    latin:keyStyle="numFunctionalKeyStyle"
+                    latin:keyStyle="numKeyStyle"
+                    latin:backgroundType="functional"
                     latin:keyWidth="fillRight" />
             </case>
             <case
@@ -62,15 +64,17 @@
             >
                 <Key
                     latin:keySpec="."
-                    latin:keyLabelFlags="hasPopupHint"
                     latin:moreKeys="!text/morekeys_am_pm"
-                    latin:keyStyle="numFunctionalKeyStyle"
+                    latin:keyLabelFlags="hasPopupHint"
+                    latin:keyStyle="numKeyStyle"
+                    latin:backgroundType="functional"
                     latin:keyWidth="fillRight" />
             </case>
             <default>
                 <Key
                     latin:keySpec=","
-                    latin:keyStyle="numFunctionalKeyStyle"
+                    latin:keyStyle="numKeyStyle"
+                    latin:backgroundType="functional"
                     latin:keyWidth="fillRight" />
             </default>
         </switch>
diff --git a/java/res/xml/rows_phone.xml b/java/res/xml/rows_phone.xml
index 03e4541..bb5590d 100644
--- a/java/res/xml/rows_phone.xml
+++ b/java/res/xml/rows_phone.xml
@@ -36,7 +36,8 @@
             latin:keySpec="-"
             latin:moreKeys="+"
             latin:keyLabelFlags="hasPopupHint"
-            latin:keyStyle="numFunctionalKeyStyle"
+            latin:keyStyle="numKeyStyle"
+            latin:backgroundType="functional"
             latin:keyWidth="fillRight" />
     </Row>
     <Row>
@@ -48,7 +49,8 @@
             latin:keyStyle="num6KeyStyle" />
         <Key
             latin:keySpec="."
-            latin:keyStyle="numFunctionalKeyStyle"
+            latin:keyStyle="numKeyStyle"
+            latin:backgroundType="functional"
             latin:keyWidth="fillRight" />
     </Row>
     <Row>
diff --git a/java/res/xml/rows_phone_symbols.xml b/java/res/xml/rows_phone_symbols.xml
index 983bfb5..195a183 100644
--- a/java/res/xml/rows_phone_symbols.xml
+++ b/java/res/xml/rows_phone_symbols.xml
@@ -28,45 +28,53 @@
     <Row>
         <Key
             latin:keySpec="("
-            latin:keyStyle="numKeyStyle" />
+            latin:keyStyle="numSymbolKeyStyle" />
         <Key
             latin:keySpec="/"
-            latin:keyStyle="numKeyStyle" />
+            latin:keyStyle="numSymbolKeyStyle" />
         <Key
             latin:keySpec=")"
-            latin:keyStyle="numKeyStyle" />
+            latin:keyStyle="numSymbolKeyStyle" />
         <Key
             latin:keySpec="-"
             latin:moreKeys="+"
             latin:keyLabelFlags="hasPopupHint"
-            latin:keyStyle="numFunctionalKeyStyle"
+            latin:keyStyle="numKeyStyle"
+            latin:backgroundType="functional"
             latin:keyWidth="fillRight" />
     </Row>
     <Row>
         <Key
             latin:keySpec="N"
-            latin:keyStyle="numKeyBaseStyle" />
+            latin:keyStyle="numSymbolKeyStyle" />
         <!-- Pause is a comma. Check PhoneNumberUtils.java to see if this
             has changed. -->
         <Key
-            latin:keyStyle="numPauseKeyStyle" />
+            latin:keySpec="!string/label_pause_key|,"
+            latin:keyLabelFlags="followKeyLabelRatio|autoXScale"
+            latin:keyStyle="numSymbolKeyStyle" />
         <Key
             latin:keySpec=","
-            latin:keyStyle="numKeyStyle" />
+            latin:keyStyle="numSymbolKeyStyle" />
         <Key
             latin:keySpec="."
-            latin:keyStyle="numFunctionalKeyStyle"
+            latin:keyStyle="numKeyStyle"
+            latin:backgroundType="functional"
             latin:keyWidth="fillRight" />
     </Row>
     <Row>
+        <!-- U+FF0A: "*" FULLWIDTH ASTERISK -->
         <Key
-            latin:keyStyle="numStarKeyStyle" />
+            latin:keySpec="&#xFF0A;|*"
+            latin:keyStyle="numSymbolKeyStyle" />
         <!-- Wait is a semicolon. -->
         <Key
-            latin:keyStyle="numWaitKeyStyle" />
+            latin:keySpec="!string/label_wait_key|;"
+            latin:keyLabelFlags="followKeyLabelRatio|autoXScale"
+            latin:keyStyle="numSymbolKeyStyle" />
         <Key
             latin:keySpec="\#"
-            latin:keyStyle="numKeyStyle" />
+            latin:keyStyle="numSymbolKeyStyle" />
         <Key
             latin:keyStyle="deleteKeyStyle"
             latin:keyWidth="fillRight" />
@@ -76,7 +84,7 @@
             latin:keyStyle="numPhoneToNumericKeyStyle" />
         <Key
             latin:keySpec="+"
-            latin:keyStyle="numKeyStyle" />
+            latin:keyStyle="numSymbolKeyStyle" />
         <Key
             latin:keyStyle="numSpaceKeyStyle" />
         <Key
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index af24ac4..c2862f5 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -258,8 +258,12 @@
     }
 
     private void setMainKeyboardFrame(final SettingsValues settingsValues) {
-        mMainKeyboardFrame.setVisibility(
-                settingsValues.mHasHardwareKeyboard ? View.GONE : View.VISIBLE);
+        final int visibility = settingsValues.mHasHardwareKeyboard ? View.GONE : View.VISIBLE;
+        mKeyboardView.setVisibility(visibility);
+        // The visibility of {@link #mKeyboardView} must be aligned with {@link #MainKeyboardFrame}.
+        // @see #getVisibleKeyboardView() and
+        // @see LatinIME#onComputeInset(android.inputmethodservice.InputMethodService.Insets)
+        mMainKeyboardFrame.setVisibility(visibility);
         mEmojiPalettesView.setVisibility(View.GONE);
         mEmojiPalettesView.stopEmojiPalettes();
     }
@@ -272,6 +276,10 @@
         }
         final Keyboard keyboard = mKeyboardLayoutSet.getKeyboard(KeyboardId.ELEMENT_ALPHABET);
         mMainKeyboardFrame.setVisibility(View.GONE);
+        // The visibility of {@link #mKeyboardView} must be aligned with {@link #MainKeyboardFrame}.
+        // @see #getVisibleKeyboardView() and
+        // @see LatinIME#onComputeInset(android.inputmethodservice.InputMethodService.Insets)
+        mKeyboardView.setVisibility(View.GONE);
         mEmojiPalettesView.startEmojiPalettes(
                 mKeyboardTextsSet.getText(KeyboardTextsSet.SWITCH_TO_ALPHA_KEY_LABEL),
                 mKeyboardView.getKeyVisualAttribute(), keyboard.mIconsSet);
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index cd09bf6..c86d2b8 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1194,7 +1194,7 @@
         if (hasHardwareKeyboard && visibleKeyboardView.getVisibility() == View.GONE) {
             // If there is a hardware keyboard and a visible software keyboard view has been hidden,
             // no visual element will be shown on the screen.
-            outInsets.touchableInsets = inputHeight;
+            outInsets.contentTopInsets = inputHeight;
             outInsets.visibleTopInsets = inputHeight;
             mInsetsUpdater.setInsets(outInsets);
             return;
@@ -1204,7 +1204,7 @@
                 ? mSuggestionStripView.getHeight() : 0;
         final int visibleTopY = inputHeight - visibleKeyboardView.getHeight() - suggestionsHeight;
         mSuggestionStripView.setMoreSuggestionsHeight(visibleTopY);
-        // Need to set touchable region only if a keyboard view is being shown.
+        // Need to set expanded touchable region only if a keyboard view is being shown.
         if (visibleKeyboardView.isShown()) {
             final int touchLeft = 0;
             final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBengaliBD.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBengaliBD.java
index 6262589..2d38c87 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBengaliBD.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBengaliBD.java
@@ -46,6 +46,11 @@
         }
 
         @Override
+        public ExpectedKey[] getSpaceKeys(final boolean isPhone) {
+            return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY));
+        }
+
+        @Override
         public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; }
 
         // U+09F3: "৳" BENGALI RUPEE SIGN