Fix "Show settings key" option on 7" device

Cherry-pic I993ac772 from Honeycomb-MR2.

Bug: 4586882
Change-Id: Ie74138523a3ae7958c7bec674c49aa0ab1a72d05
diff --git a/java/res/xml-sw600dp/kbd_key_styles.xml b/java/res/xml-sw600dp/kbd_key_styles.xml
index dbff293..e8e80ac 100644
--- a/java/res/xml-sw600dp/kbd_key_styles.xml
+++ b/java/res/xml-sw600dp/kbd_key_styles.xml
@@ -25,6 +25,23 @@
     <key-style
         latin:styleName="functionalKeyStyle"
         latin:isFunctional="true" />
+    <!-- Base key style for the key which may have settings key as popup key -->
+    <switch>
+        <case
+            latin:clobberSettingsKey="true"
+        >
+            <key-style
+                latin:styleName="settingsPopupStyle"
+                latin:parentStyle="functionalKeyStyle" />
+        </case>
+        <default>
+            <key-style
+                latin:styleName="settingsPopupStyle"
+                latin:keyLabelOption="popupHint"
+                latin:popupCharacters="\@icon/5|\@integer/key_settings"
+                latin:parentStyle="functionalKeyStyle" />
+        </default>
+    </switch>
     <!-- Functional key styles -->
     <key-style
         latin:styleName="shiftKeyStyle"
@@ -59,28 +76,18 @@
         latin:keyLabelOption="popupHint"
         latin:popupCharacters="@string/alternates_for_smiley"
         latin:maxPopupKeyboardColumn="5" />
-    <switch>
-        <case
-            latin:voiceKeyEnabled="true"
-        >
-            <key-style
-                latin:styleName="shortcutOrSettingsKeyStyle"
-                latin:code="@integer/key_shortcut"
-                latin:keyIcon="iconShortcutKey"
-                latin:keyIconPreview="iconPreviewShortcutKey"
-                latin:keyLabelOption="popupHint"
-                latin:popupCharacters="\@icon/5|\@integer/key_settings"
-                latin:parentStyle="functionalKeyStyle" />
-        </case>
-        <default>
-            <key-style
-                latin:styleName="shortcutOrSettingsKeyStyle"
-                latin:code="@integer/key_settings"
-                latin:keyIcon="iconSettingsKey"
-                latin:keyIconPreview="iconPreviewSettingsKey"
-                latin:parentStyle="functionalKeyStyle" />
-        </default>
-    </switch>
+    <key-style
+        latin:styleName="shortcutKeyStyle"
+        latin:code="@integer/key_shortcut"
+        latin:keyIcon="iconShortcutKey"
+        latin:keyIconPreview="iconPreviewShortcutKey"
+        latin:parentStyle="settingsPopupStyle" />
+    <key-style
+        latin:styleName="settingsKeyStyle"
+        latin:code="@integer/key_settings"
+        latin:keyIcon="iconSettingsKey"
+        latin:keyIconPreview="iconPreviewSettingsKey"
+        latin:parentStyle="functionalKeyStyle" />
     <key-style
         latin:styleName="tabKeyStyle"
         latin:code="@integer/key_tab"
diff --git a/java/res/xml-sw600dp/kbd_number.xml b/java/res/xml-sw600dp/kbd_number.xml
index 42d7d07..2c7af0a 100644
--- a/java/res/xml-sw600dp/kbd_number.xml
+++ b/java/res/xml-sw600dp/kbd_number.xml
@@ -78,12 +78,11 @@
                     latin:keyXPos="24.875%p" />
                 <Key
                     latin:keyStyle="num0KeyStyle" />
-                <Spacer />
-                <Key
-                    latin:keyStyle="shortcutOrSettingsKeyStyle"
+                <Spacer
                     latin:keyXPos="-11.00%p"
-                    latin:keyWidth="fillRight"
-                    latin:keyEdgeFlags="right" />
+                    latin:keyWidth="0%p" />
+                <include
+                    latin:keyboardLayout="@xml/kbd_qwerty_f2" />
             </Row>
         </case>
         <!-- latin:passwordInput="false" -->
@@ -185,11 +184,11 @@
                 <Key
                     latin:keyLabel="#"
                     latin:keyStyle="numLabelStyle" />
-                <Key
-                    latin:keyStyle="shortcutOrSettingsKeyStyle"
+                <Spacer
                     latin:keyXPos="-11.00%p"
-                    latin:keyWidth="fillBoth"
-                    latin:keyEdgeFlags="right" />
+                    latin:keyWidth="0%p" />
+                <include
+                    latin:keyboardLayout="@xml/kbd_qwerty_f2" />
             </Row>
         </default>
     </switch>
diff --git a/java/res/xml-sw600dp/kbd_phone.xml b/java/res/xml-sw600dp/kbd_phone.xml
index 017d003..4dee882 100644
--- a/java/res/xml-sw600dp/kbd_phone.xml
+++ b/java/res/xml-sw600dp/kbd_phone.xml
@@ -115,10 +115,10 @@
         <Key
             latin:keyLabel="#"
             latin:keyStyle="numLabelStyle" />
-        <Key
-            latin:keyStyle="shortcutOrSettingsKeyStyle"
+        <Spacer
             latin:keyXPos="-11.00%p"
-            latin:keyWidth="fillBoth"
-            latin:keyEdgeFlags="right" />
+            latin:keyWidth="0%p" />
+        <include
+            latin:keyboardLayout="@xml/kbd_qwerty_f2" />
     </Row>
 </Keyboard>
diff --git a/java/res/xml-sw600dp/kbd_phone_symbols.xml b/java/res/xml-sw600dp/kbd_phone_symbols.xml
index 168e6b1..87de880 100644
--- a/java/res/xml-sw600dp/kbd_phone_symbols.xml
+++ b/java/res/xml-sw600dp/kbd_phone_symbols.xml
@@ -125,10 +125,10 @@
         <Key
             latin:keyLabel="#"
             latin:keyStyle="numLabelStyle" />
-        <Key
-            latin:keyStyle="shortcutOrSettingsKeyStyle"
+        <Spacer
             latin:keyXPos="-11.00%p"
-            latin:keyWidth="fillBoth"
-            latin:keyEdgeFlags="right" />
+            latin:keyWidth="0%p" />
+        <include
+            latin:keyboardLayout="@xml/kbd_qwerty_f2" />
     </Row>
 </Keyboard>
diff --git a/java/res/xml-sw600dp/kbd_qwerty_f2.xml b/java/res/xml-sw600dp/kbd_qwerty_f2.xml
new file mode 100644
index 0000000..2724755
--- /dev/null
+++ b/java/res/xml-sw600dp/kbd_qwerty_f2.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <switch>
+        <case
+            latin:f2KeyMode="settings"
+        >
+            <Key
+                latin:keyStyle="settingsKeyStyle"
+                latin:keyWidth="fillBoth"
+                latin:keyEdgeFlags="right" />
+        </case>
+        <case
+            latin:f2KeyMode="shortcutIme"
+        >
+            <switch>
+                <case
+                    latin:voiceKeyEnabled="true"
+                >
+                    <Key
+                        latin:keyStyle="micKeyStyle"
+                        latin:keyWidth="fillBoth"
+                        latin:keyEdgeFlags="right" />
+                </case>
+                <!-- voiceKeyEnabled="false" -->
+                <default>
+                    <Spacer />
+                </default>
+            </switch>
+        </case>
+        <case
+            latin:f2KeyMode="shortcutImeOrSettings"
+        >
+            <switch>
+                <case
+                    latin:voiceKeyEnabled="true"
+                >
+                    <Key
+                        latin:keyStyle="micKeyStyle"
+                        latin:keyWidth="fillBoth"
+                        latin:keyEdgeFlags="right" />
+                </case>
+                <!-- voiceKeyEnabled="false" -->
+                <default>
+                    <Key
+                        latin:keyStyle="settingsKeyStyle"
+                        latin:keyWidth="fillBoth"
+                        latin:keyEdgeFlags="right" />
+                </default>
+            </switch>
+        </case>
+        <!-- f2KeyMode="none" -->
+        <default>
+            <Spacer />
+        </default>
+    </switch>
+</merge>
diff --git a/java/res/xml-sw600dp/kbd_qwerty_row4.xml b/java/res/xml-sw600dp/kbd_qwerty_row4.xml
index 958a7ed..8fd65fe 100644
--- a/java/res/xml-sw600dp/kbd_qwerty_row4.xml
+++ b/java/res/xml-sw600dp/kbd_qwerty_row4.xml
@@ -154,10 +154,10 @@
                 </switch>
             </default>
         </switch>
-        <Key
-            latin:keyStyle="shortcutOrSettingsKeyStyle"
-            latin:keyXPos="-10.0%p"
-            latin:keyWidth="fillBoth"
-            latin:keyEdgeFlags="right" />
+        <Spacer
+            latin:keyXPos="-10.00%p"
+            latin:keyWidth="0%p" />
+        <include
+            latin:keyboardLayout="@xml/kbd_qwerty_f2" />
     </Row>
 </merge>
diff --git a/java/res/xml-sw600dp/kbd_symbols.xml b/java/res/xml-sw600dp/kbd_symbols.xml
index fca97c7..77849f6 100644
--- a/java/res/xml-sw600dp/kbd_symbols.xml
+++ b/java/res/xml-sw600dp/kbd_symbols.xml
@@ -209,10 +209,10 @@
                     latin:keyWidth="9.750%p" />
             </default>
         </switch>
-        <Key
-            latin:keyStyle="shortcutOrSettingsKeyStyle"
-            latin:keyXPos="-10.0%p"
-            latin:keyWidth="fillBoth"
-            latin:keyEdgeFlags="right" />
+        <Spacer
+            latin:keyXPos="-10.00%p"
+            latin:keyWidth="0%p" />
+        <include
+            latin:keyboardLayout="@xml/kbd_qwerty_f2" />
     </Row>
 </Keyboard>
diff --git a/java/res/xml-sw600dp/kbd_symbols_shift.xml b/java/res/xml-sw600dp/kbd_symbols_shift.xml
index c23681d..b25292f 100644
--- a/java/res/xml-sw600dp/kbd_symbols_shift.xml
+++ b/java/res/xml-sw600dp/kbd_symbols_shift.xml
@@ -147,10 +147,10 @@
             latin:keyStyle="spaceKeyStyle"
             latin:keyXPos="30.750%p"
             latin:keyWidth="39.750%p" />
-        <Key
-            latin:keyStyle="shortcutOrSettingsKeyStyle"
-            latin:keyXPos="-10.0%p"
-            latin:keyWidth="fillRight"
-            latin:keyEdgeFlags="right" />
+        <Spacer
+            latin:keyXPos="-10.00%p"
+            latin:keyWidth="0%p" />
+        <include
+            latin:keyboardLayout="@xml/kbd_qwerty_f2" />
     </Row>
 </Keyboard>