Input language switching. Bug: 2331173

New feature to enable fast switching between input languages for
multilingual users. Keyboard settings lets you select a bunch of
languages to switch between from the Latin IME.

Use the Globe icon to toggle between languages.

Needs more work and some layout changes in specialized keyboards.

Also added a Russian keyboard (needs some pixel TLC at the right edge).
diff --git a/res/drawable-hdpi/sym_keyboard_globe.png b/res/drawable-hdpi/sym_keyboard_globe.png
new file mode 100644
index 0000000..fa74764
--- /dev/null
+++ b/res/drawable-hdpi/sym_keyboard_globe.png
Binary files differ
diff --git a/res/values/keycodes.xml b/res/values/keycodes.xml
new file mode 100644
index 0000000..e46e4bc
--- /dev/null
+++ b/res/values/keycodes.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* 
+**
+** Copyright 2009, 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>
+    <!-- Keycode for F1 (function) key. This one switches between language switch & comma/.com -->
+    <integer name="key_f1">-102</integer>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 753d0dc..3b3965e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -208,4 +208,7 @@
     <string name="popular_domain_3">".gov"</string>
     <!-- popular web domains for the locale - item 4, displayed in the popup -->
     <string name="popular_domain_4">".edu"</string>
+    
+    <!-- Title for input language selection screen -->
+    <string name="language_selection_title">Select input languages</string>
 </resources>
diff --git a/res/xml-de/kbd_qwerty.xml b/res/xml-de/kbd_qwerty.xml
index 56113e2..2da609c 100755
--- a/res/xml-de/kbd_qwerty.xml
+++ b/res/xml-de/kbd_qwerty.xml
@@ -100,7 +100,8 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters="_"
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="," android:keyWidth="10%p" />
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="10%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
                 android:keyWidth="40%p" android:isRepeatable="true"/>
@@ -116,9 +117,7 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters="_"
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="@string/popular_domain_0"
-                android:keyOutputText="@string/popular_domain_0"
-                android:popupKeyboard="@xml/popup_domains"
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
                 android:keyWidth="15%p"/>
         <Key android:keyLabel="/" android:keyWidth="15%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
@@ -136,11 +135,9 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters="_"
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="\@" android:keyWidth="15%p"/>
-        <Key android:keyLabel="@string/popular_domain_0"
-                android:keyOutputText="@string/popular_domain_0"
-                android:popupKeyboard="@xml/popup_domains"
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
                 android:keyWidth="15%p"/>
+        <Key android:keyLabel="\@" android:keyWidth="15%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" 
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
                 android:keyWidth="15%p" android:isRepeatable="true"/>
@@ -156,7 +153,8 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters="_"
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="," android:keyWidth="10%p"/>
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="10%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
                 android:keyWidth="40%p" android:isRepeatable="true"/>
diff --git a/res/xml-fr/kbd_qwerty.xml b/res/xml-fr/kbd_qwerty.xml
index d47042e..7c1b24b 100644
--- a/res/xml-fr/kbd_qwerty.xml
+++ b/res/xml-fr/kbd_qwerty.xml
@@ -102,7 +102,8 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters=""
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="," android:keyWidth="10%p" />
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="10%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" 
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
                 android:keyWidth="40%p" android:isRepeatable="true"/>
@@ -118,9 +119,7 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters=""
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="@string/popular_domain_0"
-                android:keyOutputText="@string/popular_domain_0"
-                android:popupKeyboard="@xml/popup_domains"
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
                 android:keyWidth="15%p"/>
         <Key android:keyLabel="/" android:keyWidth="15%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" 
@@ -138,11 +137,9 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters=""
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="\@" android:keyWidth="15%p"/>
-        <Key android:keyLabel="@string/popular_domain_0"
-                android:keyOutputText="@string/popular_domain_0"
-                android:popupKeyboard="@xml/popup_domains"
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
                 android:keyWidth="15%p"/>
+        <Key android:keyLabel="\@" android:keyWidth="15%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" 
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
                 android:keyWidth="15%p" android:isRepeatable="true"/>
@@ -158,7 +155,8 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters=""
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="," android:keyWidth="10%p"/>
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="10%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
                 android:keyWidth="40%p" android:isRepeatable="true"/>
diff --git a/res/xml-ru/kbd_qwerty.xml b/res/xml-ru/kbd_qwerty.xml
new file mode 100755
index 0000000..c0afbd7
--- /dev/null
+++ b/res/xml-ru/kbd_qwerty.xml
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* 
+**
+** Copyright 2008, 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.
+*/
+-->
+
+<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
+    android:keyWidth="9.09%p"
+    android:horizontalGap="0px"
+    android:verticalGap="0px"
+    android:keyHeight="@dimen/key_height"
+    >
+
+    <Row>
+        <Key android:keyLabel="й"
+                android:keyEdgeFlags="left"/>
+        <Key android:keyLabel="ц"/>
+        <Key android:keyLabel="у"/>
+        <Key android:keyLabel="к"/>
+        <Key android:keyLabel="е"/>
+        <Key android:keyLabel="н"/>
+        <Key android:keyLabel="г"/>
+        <Key android:keyLabel="ш"/>
+        <Key android:keyLabel="щ"/>
+        <Key android:keyLabel="з"/>
+        <Key android:keyLabel="х"
+                android:keyEdgeFlags="right"/>
+    </Row>
+    
+    <Row>
+        <Key android:keyLabel="ф"
+                android:keyEdgeFlags="left"/>
+        <Key android:keyLabel="ы"/>
+        <Key android:keyLabel="в"/>
+        <Key android:keyLabel="а"/>
+        <Key android:keyLabel="п"/>
+        <Key android:keyLabel="р"/>
+        <Key android:keyLabel="о"/>
+        <Key android:keyLabel="л"/>
+        <Key android:keyLabel="д"/>
+        <Key android:keyLabel="ж"/>
+        <Key android:keyLabel="э"
+                android:keyEdgeFlags="right"/>
+    </Row>
+    
+    <Row android:keyWidth="8.5%p">
+        <Key android:codes="-1" android:keyIcon="@drawable/sym_keyboard_shift" 
+                android:keyWidth="11.75%p" android:isModifier="true"
+                android:iconPreview="@drawable/sym_keyboard_feedback_shift"
+                android:isSticky="true" android:keyEdgeFlags="left"/>
+        <Key android:keyLabel="я"/>
+        <Key android:keyLabel="ч"/>
+        <Key android:keyLabel="с"/>
+        <Key android:keyLabel="м"/>
+        <Key android:keyLabel="и"/>
+        <Key android:keyLabel="т"/>
+        <Key android:keyLabel="ь"/>
+        <Key android:keyLabel="б"/>
+        <Key android:keyLabel="ю"/>
+        <Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
+                android:keyWidth="11.75%p" android:keyEdgeFlags="right"
+                android:iconPreview="@drawable/sym_keyboard_feedback_delete"
+                android:isRepeatable="true"/>
+    </Row>
+
+    <Row android:keyboardMode="@+id/mode_normal" android:rowEdgeFlags="bottom">
+        <Key android:codes="-2" android:keyLabel="@string/label_symbol_key" 
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="_"
+                android:keyWidth="20%p" android:keyEdgeFlags="left"/>
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="10%p"/>
+        <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
+                android:iconPreview="@drawable/sym_keyboard_feedback_space"
+                android:keyWidth="40%p" android:isRepeatable="true"/>
+        <Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation" 
+                android:keyWidth="10%p"/>
+        <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
+                android:iconPreview="@drawable/sym_keyboard_feedback_return"
+                android:keyWidth="20%p" android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row android:keyboardMode="@+id/mode_url" android:rowEdgeFlags="bottom">
+        <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="_"
+                android:keyWidth="20%p" android:keyEdgeFlags="left"/>
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="15%p"/>
+        <Key android:keyLabel="/" android:keyWidth="15%p"/>
+        <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
+                android:iconPreview="@drawable/sym_keyboard_feedback_space"
+                android:keyWidth="15%p" android:isRepeatable="true"/>
+        <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
+                android:keyWidth="15%p"/>
+        <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
+                android:iconPreview="@drawable/sym_keyboard_feedback_return"
+                android:keyWidth="20%p" android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom">
+        <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="_"
+                android:keyWidth="20%p" android:keyEdgeFlags="left"/>
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="15%p"/>
+        <Key android:keyLabel="\@" android:keyWidth="15%p"/>
+        <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
+                android:iconPreview="@drawable/sym_keyboard_feedback_space"
+                android:keyWidth="15%p" android:isRepeatable="true"/>
+        <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
+                android:keyWidth="15%p"/>
+        <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
+                android:iconPreview="@drawable/sym_keyboard_feedback_return"
+                android:keyWidth="20%p" android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom">
+        <Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="_"
+                android:keyWidth="20%p" android:keyEdgeFlags="left"/>
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="10%p"/>
+        <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
+                android:iconPreview="@drawable/sym_keyboard_feedback_space"
+                android:keyWidth="40%p" android:isRepeatable="true"/>
+        <Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation" 
+                android:keyWidth="10%p"/>
+        <Key android:keyLabel=":-)" android:keyOutputText=":-) "
+                android:popupKeyboard="@xml/popup_smileys"
+                android:keyWidth="20%p" android:keyEdgeFlags="right"/>
+    </Row>
+</Keyboard>
+    
diff --git a/res/xml/kbd_qwerty.xml b/res/xml/kbd_qwerty.xml
index 0493b99..d914f46 100755
--- a/res/xml/kbd_qwerty.xml
+++ b/res/xml/kbd_qwerty.xml
@@ -114,7 +114,8 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters="_"
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="," android:keyWidth="10%p" />
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="10%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
                 android:keyWidth="40%p" android:isRepeatable="true"/>
@@ -130,10 +131,12 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters="_"
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="@string/popular_domain_0"
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="15%p"/>
+        <!--Key android:keyLabel="@string/popular_domain_0"
                 android:keyOutputText="@string/popular_domain_0"
                 android:popupKeyboard="@xml/popup_domains"
-                android:keyWidth="15%p"/>
+                android:keyWidth="15%p"/-->
         <Key android:keyLabel="/" android:keyWidth="15%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
@@ -150,11 +153,13 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters="_"
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="15%p"/>
         <Key android:keyLabel="\@" android:keyWidth="15%p"/>
-        <Key android:keyLabel="@string/popular_domain_0"
+        <!--Key android:keyLabel="@string/popular_domain_0"
                 android:keyOutputText="@string/popular_domain_0"
                 android:popupKeyboard="@xml/popup_domains"
-                android:keyWidth="15%p"/>
+                android:keyWidth="15%p"/-->
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
                 android:keyWidth="15%p" android:isRepeatable="true"/>
@@ -170,7 +175,8 @@
                 android:popupKeyboard="@xml/kbd_popup_template"
                 android:popupCharacters="_"
                 android:keyWidth="20%p" android:keyEdgeFlags="left"/>
-        <Key android:keyLabel="," android:keyWidth="10%p"/>
+        <Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_globe"
+                android:keyWidth="10%p"/>
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
                 android:iconPreview="@drawable/sym_keyboard_feedback_space"
                 android:keyWidth="40%p" android:isRepeatable="true"/>
@@ -181,4 +187,4 @@
                 android:keyWidth="20%p" android:keyEdgeFlags="right"/>
     </Row>
 </Keyboard>
-    
+
diff --git a/res/xml/kbd_symbols.xml b/res/xml/kbd_symbols.xml
index b1b75c6..5a30c7b 100755
--- a/res/xml/kbd_symbols.xml
+++ b/res/xml/kbd_symbols.xml
@@ -120,7 +120,7 @@
                 android:iconPreview="@drawable/sym_keyboard_feedback_delete"
                 android:isRepeatable="true"/>
     </Row>
-    
+
     <Row  android:rowEdgeFlags="bottom">
         <Key android:codes="-2" android:keyLabel="@string/label_alpha_key"
                 android:popupKeyboard="@xml/kbd_popup_template"
diff --git a/res/xml/language_prefs.xml b/res/xml/language_prefs.xml
new file mode 100644
index 0000000..b7a4c07
--- /dev/null
+++ b/res/xml/language_prefs.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+        android:title="@string/language_selection_title">
+</PreferenceScreen>
diff --git a/res/xml/prefs.xml b/res/xml/prefs.xml
index 2fc82aa..d5075c5 100644
--- a/res/xml/prefs.xml
+++ b/res/xml/prefs.xml
@@ -37,6 +37,14 @@
             android:defaultValue="true"
             />
 
+    <PreferenceScreen
+            android:title="@string/language_selection_title">
+        <intent
+                android:action="android.intent.action.MAIN"
+                android:targetPackage="com.android.inputmethod.latin"
+                android:targetClass="com.android.inputmethod.latin.InputLanguageSelection" />
+    </PreferenceScreen>
+
     <PreferenceCategory
             android:title="@string/prediction_category"
             android:key="prediction_settings">