Merge commit 'goog/master'

Conflicts:
	java/res/values-de/strings.xml
	java/res/values-it/strings.xml
diff --git a/java/Android.mk b/java/Android.mk
index 4bb8986..9b2e47d 100755
--- a/java/Android.mk
+++ b/java/Android.mk
@@ -5,15 +5,18 @@
 
 LOCAL_SRC_FILES := $(call all-subdir-java-files)
 
-LOCAL_PACKAGE_NAME := LatinIME
+LOCAL_PACKAGE_NAME := LatinIme2Google
 
 LOCAL_CERTIFICATE := shared
 
-LOCAL_JNI_SHARED_LIBRARIES := libjni_latinime
+LOCAL_JNI_SHARED_LIBRARIES := libjni_latinime2
 
 LOCAL_STATIC_JAVA_LIBRARIES := android-common
 
 #LOCAL_AAPT_FLAGS := -0 .dict
+# The following flag is required because we use a different package name
+# com.google.android.inputmethod.latin in the LatinIME sandbox.
+LOCAL_AAPT_FLAGS := --custom-package com.android.inputmethod.latin
 
 LOCAL_SDK_VERSION := current
 
diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml
index e229bc7..baa82a1 100755
--- a/java/AndroidManifest.xml
+++ b/java/AndroidManifest.xml
@@ -1,5 +1,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="com.android.inputmethod.latin">
+        package="com.google.android.inputmethod.latin"
+        android:versionCode="9"
+        android:versionName="0.1">
 
     <original-package android:name="com.android.inputmethod.latin" />
 
@@ -10,10 +12,10 @@
     <uses-permission android:name="android.permission.READ_CONTACTS" />
 
     <application android:label="@string/english_ime_name"
-            android:backupAgent="LatinIMEBackupAgent"
+            android:backupAgent="com.android.inputmethod.latin.LatinIMEBackupAgent"
             android:killAfterRestore="false">
 
-        <service android:name="LatinIME"
+        <service android:name="com.android.inputmethod.latin.LatinIME"
                 android:label="@string/english_ime_name"
                 android:permission="android.permission.BIND_INPUT_METHOD">
             <intent-filter>
@@ -22,13 +24,13 @@
             <meta-data android:name="android.view.im" android:resource="@xml/method" />
         </service>
 
-        <activity android:name="LatinIMESettings" android:label="@string/english_ime_settings">
+        <activity android:name="com.android.inputmethod.latin.LatinIMESettings" android:label="@string/english_ime_settings">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
             </intent-filter>
         </activity>
 
-        <activity android:name="InputLanguageSelection"
+        <activity android:name="com.android.inputmethod.latin.InputLanguageSelection"
                 android:label="@string/language_selection_title">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
diff --git a/java/res/drawable/btn_keyboard_key2.xml b/java/res/drawable/btn_keyboard_key2.xml
new file mode 100644
index 0000000..bd745b7
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_key2.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <!-- Toggle keys. Use checkable/checked state. -->
+
+    <item android:state_checkable="true" android:state_checked="true"
+          android:state_pressed="true"
+          android:drawable="@drawable/btn_keyboard_key_pressed_on" />
+    <item android:state_checkable="true" android:state_pressed="true"
+          android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
+    <item android:state_checkable="true" android:state_checked="true"
+          android:drawable="@drawable/btn_keyboard_key_normal_on" />
+    <item android:state_checkable="true"
+          android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" />
+
+    <!-- Normal keys -->
+
+    <item android:state_pressed="true"
+          android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
+    <item android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" />
+</selector>
diff --git a/java/res/drawable/btn_keyboard_key3.xml b/java/res/drawable/btn_keyboard_key3.xml
new file mode 100644
index 0000000..dbe82d5
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_key3.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <!-- Toggle keys. Use checkable/checked state. -->
+
+    <item android:state_checkable="true" android:state_checked="true"
+          android:state_pressed="true"
+          android:drawable="@drawable/btn_keyboard_key_pressed_on" />
+    <item android:state_checkable="true" android:state_pressed="true"
+          android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" />
+    <item android:state_checkable="true" android:state_checked="true"
+          android:drawable="@drawable/btn_keyboard_key_normal_on" />
+    <item android:state_checkable="true"
+          android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
+
+    <!-- Normal keys -->
+
+    <item android:state_pressed="true"
+          android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" />
+    <item android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
+</selector>
diff --git a/java/res/drawable/btn_keyboard_toggle_off.png b/java/res/drawable/btn_keyboard_toggle_off.png
new file mode 100644
index 0000000..21399a4
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_toggle_off.png
Binary files differ
diff --git a/java/res/drawable/btn_keyboard_toggle_on.png b/java/res/drawable/btn_keyboard_toggle_on.png
new file mode 100644
index 0000000..22d5683
--- /dev/null
+++ b/java/res/drawable/btn_keyboard_toggle_on.png
Binary files differ
diff --git a/java/res/drawable/keyboard_background_2.jpg b/java/res/drawable/keyboard_background_2.jpg
new file mode 100644
index 0000000..400aa27
--- /dev/null
+++ b/java/res/drawable/keyboard_background_2.jpg
Binary files differ
diff --git a/java/res/drawable/keyboard_background_3.jpg b/java/res/drawable/keyboard_background_3.jpg
new file mode 100644
index 0000000..4e64844
--- /dev/null
+++ b/java/res/drawable/keyboard_background_3.jpg
Binary files differ
diff --git a/java/res/drawable/keyboard_background_4.jpg b/java/res/drawable/keyboard_background_4.jpg
new file mode 100755
index 0000000..5998f48
--- /dev/null
+++ b/java/res/drawable/keyboard_background_4.jpg
Binary files differ
diff --git a/java/res/drawable/keyboard_background_5.jpg b/java/res/drawable/keyboard_background_5.jpg
new file mode 100644
index 0000000..2fe7c5f
--- /dev/null
+++ b/java/res/drawable/keyboard_background_5.jpg
Binary files differ
diff --git a/java/res/layout/input2.xml b/java/res/layout/input2.xml
new file mode 100755
index 0000000..2e90c2c
--- /dev/null
+++ b/java/res/layout/input2.xml
@@ -0,0 +1,29 @@
+<?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.
+*/
+-->
+
+<com.android.inputmethod.latin.LatinKeyboardView
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@android:id/keyboardView"
+        android:layout_alignParentBottom="true"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:keyBackground="@drawable/btn_keyboard_key3"
+        android:background="@android:color/black"
+        />
diff --git a/java/res/layout/input3.xml b/java/res/layout/input3.xml
new file mode 100755
index 0000000..a27d09a
--- /dev/null
+++ b/java/res/layout/input3.xml
@@ -0,0 +1,29 @@
+<?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.
+*/
+-->
+
+<com.android.inputmethod.latin.LatinKeyboardView
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@android:id/keyboardView"
+        android:layout_alignParentBottom="true"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:keyBackground="@drawable/btn_keyboard_key2"
+        android:background="@drawable/keyboard_background_4"
+        />
diff --git a/java/res/layout/input4.xml b/java/res/layout/input4.xml
new file mode 100755
index 0000000..58dd51e
--- /dev/null
+++ b/java/res/layout/input4.xml
@@ -0,0 +1,29 @@
+<?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.
+*/
+-->
+
+<com.android.inputmethod.latin.LatinKeyboardView
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@android:id/keyboardView"
+        android:layout_alignParentBottom="true"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:keyBackground="@drawable/btn_keyboard_key3"
+        android:background="@drawable/keyboard_background_4"
+        />
diff --git a/java/res/layout/input5.xml b/java/res/layout/input5.xml
new file mode 100755
index 0000000..5cd0b8d
--- /dev/null
+++ b/java/res/layout/input5.xml
@@ -0,0 +1,29 @@
+<?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.
+*/
+-->
+
+<com.android.inputmethod.latin.LatinKeyboardView
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@android:id/keyboardView"
+        android:layout_alignParentBottom="true"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:keyBackground="@drawable/btn_keyboard_key2"
+        android:background="@drawable/keyboard_background_5"
+        />
diff --git a/java/res/layout/input6.xml b/java/res/layout/input6.xml
new file mode 100755
index 0000000..19197e1
--- /dev/null
+++ b/java/res/layout/input6.xml
@@ -0,0 +1,29 @@
+<?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.
+*/
+-->
+
+<com.android.inputmethod.latin.LatinKeyboardView
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@android:id/keyboardView"
+        android:layout_alignParentBottom="true"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:keyBackground="@drawable/btn_keyboard_key3"
+        android:background="@drawable/keyboard_background_5"
+        />
diff --git a/java/res/values-cs/strings.xml b/java/res/values-cs/strings.xml
index 4bc1f55..e063c8a 100644
--- a/java/res/values-cs/strings.xml
+++ b/java/res/values-cs/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Klávesnice Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Nastavení klávesnice Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Klávesnice Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Nastavení klávesnice Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Při stisku klávesy vibrovat"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Zvuk při stisku klávesy"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Opravovat překlepy"</string>
diff --git a/java/res/values-da/strings.xml b/java/res/values-da/strings.xml
index 750d67b..09cb8c9 100644
--- a/java/res/values-da/strings.xml
+++ b/java/res/values-da/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Android-tastatur"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Indstillinger for Android-tastatur"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Android-tastatur 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Indstillinger for Android-tastatur 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibration ved tastetryk"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Lyd ved tastetryk"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Ret stavefejl"</string>
diff --git a/java/res/values-de/strings.xml b/java/res/values-de/strings.xml
index ed6408d..02ed5a6 100644
--- a/java/res/values-de/strings.xml
+++ b/java/res/values-de/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Android-Tastatur"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Android-Tastatureinstellungen"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Android-Tastatur 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Android-Tastatur2einstellungen"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibrieren b. Tastendruck"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Ton bei Tastendruck"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Eingabefehler korrigieren"</string>
diff --git a/java/res/values-el/strings.xml b/java/res/values-el/strings.xml
index c4a5077..fbe705f 100644
--- a/java/res/values-el/strings.xml
+++ b/java/res/values-el/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Πληκτρολόγιο Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Ρυθμίσεις πληκτρολογίου Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Πληκτρολόγιο Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Ρυθμίσεις πληκτρολογίου Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Δόνηση κατά το πάτημα πλήκτρων"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Ήχος κατά το πάτημα πλήκτρων"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Διόρθωση σφαλμάτων πληκτρολόγησης"</string>
diff --git a/java/res/values-es-rUS/strings.xml b/java/res/values-es-rUS/strings.xml
index cd17dba..150ff75 100644
--- a/java/res/values-es-rUS/strings.xml
+++ b/java/res/values-es-rUS/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Teclado de Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Configuración de teclado de Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Teclado de Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Configuración de teclado de Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibrar al pulsar teclas"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Sonar al pulsar las teclas"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Corregir errores de escritura"</string>
diff --git a/java/res/values-es/strings.xml b/java/res/values-es/strings.xml
index fbe3ad3..4ef3eac 100644
--- a/java/res/values-es/strings.xml
+++ b/java/res/values-es/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Teclado de Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Ajustes del teclado de Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Teclado de Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Ajustes del teclado de Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibrar al pulsar tecla"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Sonido al pulsar tecla"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Corregir errores de escritura"</string>
diff --git a/java/res/values-fr-rCA/strings.xml b/java/res/values-fr-rCA/strings.xml
index b56463e..e0d456d 100644
--- a/java/res/values-fr-rCA/strings.xml
+++ b/java/res/values-fr-rCA/strings.xml
@@ -15,5 +15,5 @@
 -->
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Clavier Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Clavier Android 2"</string>
 </resources>
diff --git a/java/res/values-fr/strings.xml b/java/res/values-fr/strings.xml
index 2cabe40..d4ec878 100644
--- a/java/res/values-fr/strings.xml
+++ b/java/res/values-fr/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Clavier Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Paramètres du clavier Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Clavier Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Paramètres du clavier Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibrer à chaque touche"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Son à chaque touche"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Corriger les fautes de frappe"</string>
diff --git a/java/res/values-it/strings.xml b/java/res/values-it/strings.xml
index 8100175..297ea5c 100644
--- a/java/res/values-it/strings.xml
+++ b/java/res/values-it/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Tastiera Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Impostazioni tastiera Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Tastiera Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Impostazioni tastiera Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibrazione tasti"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Suono tasti"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Correggi errori di digitazione"</string>
diff --git a/java/res/values-ja/strings.xml b/java/res/values-ja/strings.xml
index 7867684..f77cb21 100644
--- a/java/res/values-ja/strings.xml
+++ b/java/res/values-ja/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Androidキーボード"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Androidキーボードの設定"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Androidキーボード 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Androidキーボード 2 の設定"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"キー操作バイブ"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"キー操作音"</string>
     <string name="hit_correction" msgid="4855351009261318389">"入力ミス補正"</string>
diff --git a/java/res/values-ko/strings.xml b/java/res/values-ko/strings.xml
index 3509579..fbfdd4c 100644
--- a/java/res/values-ko/strings.xml
+++ b/java/res/values-ko/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Android 키보드"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Android 키보드 설정"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Android 키보드 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Android 키보드 2 설정"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"키를 누를 때 진동 발생"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"버튼을 누를 때 소리 발생"</string>
     <string name="hit_correction" msgid="4855351009261318389">"입력 오류 수정"</string>
diff --git a/java/res/values-nb/strings.xml b/java/res/values-nb/strings.xml
index 041d07e..5c1bbf1 100644
--- a/java/res/values-nb/strings.xml
+++ b/java/res/values-nb/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Skjermtastatur"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Innstillinger for skjermtastatur"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Skjermtastatur 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Innstillinger for skjermtastatur 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibrer ved tastetrykk"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Lyd ved tastetrykk"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Rett opp skrivefeil"</string>
diff --git a/java/res/values-nl/strings.xml b/java/res/values-nl/strings.xml
index 00b197b..c5771c8 100644
--- a/java/res/values-nl/strings.xml
+++ b/java/res/values-nl/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Android-toetsenbord"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Instellingen voor Android-toetsenbord"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Android-toetsenbord 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Instellingen voor Android-toetsenbord 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Trillen bij druk op toets"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Geluid bij druk op een toets"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Typefouten corrigeren"</string>
diff --git a/java/res/values-pl/strings.xml b/java/res/values-pl/strings.xml
index 0c72727..561191d 100644
--- a/java/res/values-pl/strings.xml
+++ b/java/res/values-pl/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Klawiatura Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Ustawienia klawiatury Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Klawiatura Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Ustawienia klawiatury Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Wibracja przy naciśnięciu"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Dźwięk przy naciśnięciu"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Popraw błędy pisowni"</string>
diff --git a/java/res/values-pt-rPT/strings.xml b/java/res/values-pt-rPT/strings.xml
index 35a9cb7..39007c1 100644
--- a/java/res/values-pt-rPT/strings.xml
+++ b/java/res/values-pt-rPT/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Teclado do Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Definições de teclado do Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Teclado do Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Definições de teclado do Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibrar ao primir as teclas"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Som ao premir as teclas"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Corrigir erros de escrita"</string>
diff --git a/java/res/values-pt/strings.xml b/java/res/values-pt/strings.xml
index 235fd65..38890d8 100644
--- a/java/res/values-pt/strings.xml
+++ b/java/res/values-pt/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Teclado Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Configurações de teclado Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Teclado Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Configurações de teclado Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibrar ao tocar a tecla"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Som ao tocar a tecla"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Corrigir erros de digitação"</string>
diff --git a/java/res/values-ru/strings.xml b/java/res/values-ru/strings.xml
index e27402c..f1a8a1c 100644
--- a/java/res/values-ru/strings.xml
+++ b/java/res/values-ru/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Клавиатура Android"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Настройки клавиатуры Android"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Клавиатура Android 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Настройки клавиатуры Android 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Виброотклик клавиш"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Звук клавиш"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Исправлять опечатки"</string>
diff --git a/java/res/values-sv/strings.xml b/java/res/values-sv/strings.xml
index 9c6c221..8970a05 100644
--- a/java/res/values-sv/strings.xml
+++ b/java/res/values-sv/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Androids tangentbord"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Inställningar för Androids tangentbord"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Androids tangentbord 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Inställningar för Androids tangentbord 2"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Vibrera vid tangenttryck"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Knappljud"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Rätta skrivfel"</string>
diff --git a/java/res/values-tr/strings.xml b/java/res/values-tr/strings.xml
index 0fbdc7d..86d9569 100644
--- a/java/res/values-tr/strings.xml
+++ b/java/res/values-tr/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Android klavyesi"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Android klavye ayarları"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Android klavyesi 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Android klavye 2 ayarları"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"Tuşa basıldığında titret"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"Tuşa basıldığında ses çıkar"</string>
     <string name="hit_correction" msgid="4855351009261318389">"Yazım hatalarını düzelt"</string>
diff --git a/java/res/values-zh-rCN/strings.xml b/java/res/values-zh-rCN/strings.xml
index 9c9b257..b0a0781 100644
--- a/java/res/values-zh-rCN/strings.xml
+++ b/java/res/values-zh-rCN/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Android 键盘"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Android 键盘设置"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Android 键盘 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Android 键盘 2 设置"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"按键时振动"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"按键时播放音效"</string>
     <string name="hit_correction" msgid="4855351009261318389">"纠正输入错误"</string>
diff --git a/java/res/values-zh-rTW/strings.xml b/java/res/values-zh-rTW/strings.xml
index 4f83be4..89b2eac 100644
--- a/java/res/values-zh-rTW/strings.xml
+++ b/java/res/values-zh-rTW/strings.xml
@@ -20,8 +20,8 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-    <string name="english_ime_name" msgid="7252517407088836577">"Android 鍵盤"</string>
-    <string name="english_ime_settings" msgid="6661589557206947774">"Android 鍵盤設定"</string>
+    <string name="english_ime_name" msgid="7252517407088836577">"Android 鍵盤 2"</string>
+    <string name="english_ime_settings" msgid="6661589557206947774">"Android 鍵盤 2 設定"</string>
     <string name="vibrate_on_keypress" msgid="5258079494276955460">"按鍵時震動"</string>
     <string name="sound_on_keypress" msgid="6093592297198243644">"按鍵時播放音效"</string>
     <string name="hit_correction" msgid="4855351009261318389">"修正輸入錯誤"</string>
diff --git a/java/res/values/colors.xml b/java/res/values/colors.xml
index d4bb138..6eb362b 100644
--- a/java/res/values/colors.xml
+++ b/java/res/values/colors.xml
@@ -26,4 +26,4 @@
     <color name="latinkeyboard_bar_language_text">#FF808080</color>
     <color name="latinkeyboard_extension_background">#A0000000</color>
     <color name="latinkeyboard_text_color">#FF000000</color>
-</resources>
\ No newline at end of file
+</resources>
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index 35dd3e0..a1b4810 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -19,15 +19,16 @@
 -->
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <!-- Title for Latin keyboard  -->
-    <string name="english_ime_name">Android keyboard</string>
+    <string name="english_ime_name">Android keyboard 2</string>
     <!-- Title for Latin keyboard settings activity / dialog -->
-    <string name="english_ime_settings">Android keyboard settings</string>
+    <string name="english_ime_settings">Android keyboard 2 settings</string>
 
     <!-- Option to provide vibrate/haptic feedback on keypress -->
     <string name="vibrate_on_keypress">Vibrate on keypress</string>
+
     <!-- Option to play back sound on keypress in soft keyboard -->
     <string name="sound_on_keypress">Sound on keypress</string>
-    
+
     <!-- Option to enable using nearby keys when correcting/predicting -->
     <string name="hit_correction">Correct typing errors</string>
     
@@ -322,4 +323,38 @@
     
     <!-- Inform the user that a particular language has an available dictionary -->
     <string name="has_dictionary">Dictionary available</string>
+
+    <!-- Option to send logs -->
+    <string name="prefs_enable_log">Enable user feedback</string>
+    <!-- Description for sending logs -->
+    <string name="prefs_description_log">Help improve this input method editor by automatically sending usage statistics and crash reports to Google.</string>
+
+    <string name="keyboard_layout">Keyboard Theme</string>
+    <string name="layout_basic" translatable="false">Basic</string>
+    <string name="layout_high_contrast" translatable="false">Basic (High Contrast)</string>
+    <string name="layout_blue_ribbon"  translatable="false">Blue Ribbon</string>
+    <string name="layout_dazzle"  translatable="false">Dazzle</string>
+    <string name="layout_blue_ribbon_high"  translatable="false">Blue Ribbon (High Contrast)</string>
+    <string name="layout_dazzle_high"  translatable="false">Dazzle (High Contrast)</string>
+
+    <string-array name="keyboard_layout_modes" translatable="false">
+        <item>@string/layout_basic</item>
+        <item>@string/layout_high_contrast</item>
+        <item>@string/layout_blue_ribbon</item>
+        <item>@string/layout_blue_ribbon_high</item>
+        <item>@string/layout_dazzle</item>
+        <item>@string/layout_dazzle_high</item>
+    </string-array>
+
+    <string-array name="keyboard_layout_modes_values" translatable="false">
+        <item>0</item>
+        <item>1</item>
+        <item>2</item>
+        <item>3</item>
+        <item>4</item>
+        <item>5</item>
+    </string-array>
+
+    <string name="prefs_debug_mode">Debug (Temporary)</string>
+
 </resources>
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index 535b63f..8b44dd9 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -37,6 +37,14 @@
             android:defaultValue="true"
             />
 
+    <CheckBoxPreference
+            android:key="enable_logging"
+            android:title="@string/prefs_enable_log"
+            android:summary="@string/prefs_description_log"
+            android:persistent="true"
+            android:defaultValue="true"
+            />
+
     <ListPreference
             android:key="voice_mode"
             android:title="@string/voice_input"
@@ -46,6 +54,15 @@
             android:defaultValue="@string/voice_mode_main"
             />
 
+    <ListPreference
+            android:key="keyboard_layout"
+            android:title="@string/keyboard_layout"
+            android:persistent="true"
+            android:entryValues="@array/keyboard_layout_modes_values"
+            android:entries="@array/keyboard_layout_modes"
+            android:defaultValue="3"
+            />
+
     <PreferenceScreen
             android:title="@string/language_selection_title"
             android:summary="@string/language_selection_summary">
@@ -82,5 +99,13 @@
             android:dependency="show_suggestions"
             />
             
-    </PreferenceCategory>            
+    </PreferenceCategory>
+
+    <CheckBoxPreference
+            android:key="debug_mode"
+            android:title="@string/prefs_debug_mode"
+            android:persistent="true"
+            android:defaultValue="false"
+            />
+
 </PreferenceScreen>
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 6473f45..5d3df4e 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -51,9 +51,9 @@
 
     static {
         try {
-            System.loadLibrary("jni_latinime");
+            System.loadLibrary("jni_latinime2");
         } catch (UnsatisfiedLinkError ule) {
-            Log.e("BinaryDictionary", "Could not load native library jni_latinime");
+            Log.e("BinaryDictionary", "Could not load native library jni_latinime2");
         }
     }
 
diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java
index ae45001..3234e24 100755
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -167,7 +167,7 @@
                 if (scrollX < 0) {
                     scrollX = 0;
                 }
-                if (distanceX > 0 && scrollX + width > mTotalWidth) {                    
+                if (distanceX > 0 && scrollX + width > mTotalWidth) {
                     scrollX -= (int) distanceX;
                 }
                 mTargetScrollX = scrollX;
@@ -412,7 +412,11 @@
             if (y <= 0) {
                 // Fling up!?
                 if (mSelectedString != null) {
+                    // If there are completions from the application, we don't change the state to
+                    // STATE_PICKED_SUGGESTION
                     if (!mShowingCompletions) {
+                        // This "acceptedSuggestion" will not be counted as a word because
+                        // it will be counted in pickSuggestion instead.
                         TextEntryState.acceptedSuggestion(mSuggestions.get(0),
                                 mSelectedString);
                     }
diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
index 1a19644..5a271f2 100644
--- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
@@ -21,11 +21,12 @@
 import java.util.Map;
 
 import android.content.Context;
+import android.content.SharedPreferences;
 import android.content.res.Configuration;
 import android.content.res.Resources;
-import android.inputmethodservice.InputMethodService;
+import android.preference.PreferenceManager;
 
-public class KeyboardSwitcher {
+public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener {
 
     public static final int MODE_TEXT = 1;
     public static final int MODE_SYMBOLS = 2;
@@ -45,6 +46,13 @@
     public static final int KEYBOARDMODE_IM = R.id.mode_im;
     public static final int KEYBOARDMODE_WEB = R.id.mode_webentry;
 
+    public static final String DEFAULT_LAYOUT_ID = "3";
+    public static final String PREF_KEYBOARD_LAYOUT = "keyboard_layout";
+    private static final int[] LAYOUTS = new int [] {
+        R.layout.input, R.layout.input2, R.layout.input3, R.layout.input4, R.layout.input5,
+        R.layout.input6
+    };
+
     private static final int SYMBOLS_MODE_STATE_NONE = 0;
     private static final int SYMBOLS_MODE_STATE_BEGIN = 1;
     private static final int SYMBOLS_MODE_STATE_SYMBOL = 2;
@@ -57,9 +65,8 @@
         KEYBOARDMODE_IM,
         KEYBOARDMODE_WEB};
 
-    //LatinIME mContext;
     Context mContext;
-    InputMethodService mInputMethodService;
+    LatinIME mInputMethodService;
     
     private KeyboardId mSymbolsId;
     private KeyboardId mSymbolsShiftedId;
@@ -79,14 +86,20 @@
     private int mLastDisplayWidth;
     private LanguageSwitcher mLanguageSwitcher;
     private Locale mInputLocale;
-    private boolean mEnableMultipleLanguages;
 
-    KeyboardSwitcher(Context context, InputMethodService ims) {
+    private int mLayoutId;
+
+    KeyboardSwitcher(Context context, LatinIME ims) {
         mContext = context;
         mKeyboards = new HashMap<KeyboardId, LatinKeyboard>();
         mSymbolsId = new KeyboardId(R.xml.kbd_symbols, false);
         mSymbolsShiftedId = new KeyboardId(R.xml.kbd_symbols_shift, false);
         mInputMethodService = ims;
+
+        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ims);
+        int mLayoutId = Integer.valueOf(prefs.getString(PREF_KEYBOARD_LAYOUT, DEFAULT_LAYOUT_ID));
+        prefs.registerOnSharedPreferenceChangeListener(this);
+        changeLatinKeyboardView(mLayoutId, false);
     }
 
     /**
@@ -98,13 +111,12 @@
     void setLanguageSwitcher(LanguageSwitcher languageSwitcher) {
         mLanguageSwitcher = languageSwitcher;
         mInputLocale = mLanguageSwitcher.getInputLocale();
-        mEnableMultipleLanguages = mLanguageSwitcher.getLocaleCount() > 1;
     }
 
     void setInputView(LatinKeyboardView inputView) {
         mInputView = inputView;
     }
-    
+
     void makeKeyboards(boolean forceCreate) {
         if (forceCreate) mKeyboards.clear();
         // Configuration change is coming after the keyboard gets recreated. So don't rely on that.
@@ -140,6 +152,7 @@
             this(xml, 0, false, hasVoice);
         }
 
+        @Override
         public boolean equals(Object other) {
             return other instanceof KeyboardId && equals((KeyboardId) other);
         }
@@ -150,6 +163,7 @@
               && other.mEnableShiftLock == this.mEnableShiftLock;
         }
 
+        @Override
         public int hashCode() {
             return (mXml + 1) * (mKeyboardMode + 1) * (mEnableShiftLock ? 2 : 1)
                     * (mHasVoice ? 4 : 8);
@@ -348,4 +362,38 @@
         }
         return false;
     }
+
+    public LatinKeyboardView getInputView() {
+        return mInputView;
+    }
+
+    public void recreateInputView() {
+        changeLatinKeyboardView(mLayoutId, true);
+    }
+
+    private void changeLatinKeyboardView(int newLayout, boolean forceReset) {
+        if (mLayoutId != newLayout || mInputView == null || forceReset) {
+            if (LAYOUTS.length <= newLayout) {
+                newLayout = Integer.valueOf(DEFAULT_LAYOUT_ID);
+            }
+            mInputView = (LatinKeyboardView) mInputMethodService.getLayoutInflater().inflate(
+                    LAYOUTS[newLayout], null);
+            mInputView.setOnKeyboardActionListener(mInputMethodService);
+            mLayoutId = newLayout;
+        }
+        mInputMethodService.mHandler.post(new Runnable() {
+            public void run() {
+                if (mInputView != null) {
+                    mInputMethodService.setInputView(mInputView);
+                }
+                mInputMethodService.updateInputViewShown();
+            }});
+    }
+
+    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+        if (PREF_KEYBOARD_LAYOUT.equals(key)) {
+            changeLatinKeyboardView(
+                    Integer.valueOf(sharedPreferences.getString(key, DEFAULT_LAYOUT_ID)), false);
+        }
+    }
 }
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index db0a822..a02a59e 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -146,7 +146,7 @@
     private static final int POS_SETTINGS = 0;
     private static final int POS_METHOD = 1;
 
-    private LatinKeyboardView mInputView;
+    //private LatinKeyboardView mInputView;
     private CandidateViewContainer mCandidateViewContainer;
     private CandidateView mCandidateView;
     private Suggest mSuggest;
@@ -249,8 +249,9 @@
                     break;
                 case MSG_START_TUTORIAL:
                     if (mTutorial == null) {
-                        if (mInputView.isShown()) {
-                            mTutorial = new Tutorial(LatinIME.this, mInputView);
+                        if (mKeyboardSwitcher.getInputView().isShown()) {
+                            mTutorial = new Tutorial(
+                                    LatinIME.this, mKeyboardSwitcher.getInputView());
                             mTutorial.start();
                         } else {
                             // Try again soon if the view is not yet showing
@@ -309,6 +310,7 @@
               });
         }
         prefs.registerOnSharedPreferenceChangeListener(this);
+        LatinImeLogger.init(this);
     }
 
     private void initSuggest(String locale) {
@@ -354,6 +356,7 @@
         if (VOICE_INSTALLED) {
             mVoiceInput.destroy();
         }
+        LatinImeLogger.commit();
         super.onDestroy();
     }
 
@@ -393,15 +396,12 @@
 
     @Override
     public View onCreateInputView() {
-        mInputView = (LatinKeyboardView) getLayoutInflater().inflate(
-                R.layout.input, null);
-        mKeyboardSwitcher.setInputView(mInputView);
+        mKeyboardSwitcher.recreateInputView();
         mKeyboardSwitcher.makeKeyboards(true);
-        mInputView.setOnKeyboardActionListener(this);
         mKeyboardSwitcher.setKeyboardMode(
                 KeyboardSwitcher.MODE_TEXT, 0,
                 shouldShowVoiceButton(makeFieldContext(), getCurrentInputEditorInfo()));
-        return mInputView;
+        return mKeyboardSwitcher.getInputView();
     }
 
     @Override
@@ -418,8 +418,9 @@
 
     @Override
     public void onStartInputView(EditorInfo attribute, boolean restarting) {
+        LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
         // In landscape mode, this method gets called without the input view being created.
-        if (mInputView == null) {
+        if (inputView == null) {
             return;
         }
 
@@ -528,7 +529,7 @@
                         attribute.imeOptions, enableVoiceButton);
                 updateShiftKeyState(attribute);
         }
-        mInputView.closing();
+        inputView.closing();
         mComposing.setLength(0);
         mPredicting = false;
         mDeleteCount = 0;
@@ -544,7 +545,7 @@
 
         updateCorrectionMode();
 
-        mInputView.setProximityCorrectionEnabled(true);
+        inputView.setProximityCorrectionEnabled(true);
         mPredictionOn = mPredictionOn && (mCorrectionMode > 0 || mShowSuggestions);
         checkTutorial(attribute.privateImeOptions);
         if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
@@ -554,6 +555,8 @@
     public void onFinishInput() {
         super.onFinishInput();
 
+        LatinImeLogger.commit();
+
         if (VOICE_INSTALLED && !mConfigurationChanging) {
             if (mAfterVoiceInput) {
                 mVoiceInput.flushAllTextModificationCounters();
@@ -562,8 +565,8 @@
             mVoiceInput.flushLogs();
             mVoiceInput.cancel();
         }
-        if (mInputView != null) {
-            mInputView.closing();
+        if (mKeyboardSwitcher.getInputView() != null) {
+            mKeyboardSwitcher.getInputView().closing();
         }
         if (mAutoDictionary != null) mAutoDictionary.flushPendingWrites();
     }
@@ -655,6 +658,8 @@
 
     @Override
     public void hideWindow() {
+        LatinImeLogger.commit();
+
         if (TRACE) Debug.stopMethodTracing();
         if (mOptionsDialog != null && mOptionsDialog.isShowing()) {
             mOptionsDialog.dismiss();
@@ -695,7 +700,7 @@
                 CompletionInfo ci = completions[i];
                 if (ci != null) stringList.add(ci.getText());
             }
-            //CharSequence typedWord = mWord.getTypedWord();
+            // When in fullscreen mode, show completions generated by the application
             setSuggestions(stringList, true, true, true);
             mBestWord = null;
             setCandidatesViewShown(isCandidateStripVisible() || mCompletionOn);
@@ -707,7 +712,8 @@
         // TODO: Remove this if we support candidates with hard keyboard
         if (onEvaluateInputViewShown()) {
             // Show the candidates view only if input view is showing
-            super.setCandidatesViewShown(shown && mInputView != null && mInputView.isShown());
+            super.setCandidatesViewShown(shown && mKeyboardSwitcher.getInputView() != null
+                    && mKeyboardSwitcher.getInputView().isShown());
         }
     }
 
@@ -736,8 +742,8 @@
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         switch (keyCode) {
             case KeyEvent.KEYCODE_BACK:
-                if (event.getRepeatCount() == 0 && mInputView != null) {
-                    if (mInputView.handleBack()) {
+                if (event.getRepeatCount() == 0 && mKeyboardSwitcher.getInputView() != null) {
+                    if (mKeyboardSwitcher.getInputView().handleBack()) {
                         return true;
                     } else if (mTutorial != null) {
                         mTutorial.close();
@@ -769,8 +775,10 @@
                 if (mTutorial != null) {
                     return true;
                 }
+                LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
                 // Enable shift key and DPAD to do selections
-                if (mInputView != null && mInputView.isShown() && mInputView.isShifted()) {
+                if (inputView != null && inputView.isShown()
+                        && inputView.isShifted()) {
                     event = new KeyEvent(event.getDownTime(), event.getEventTime(),
                             event.getAction(), event.getKeyCode(), event.getRepeatCount(),
                             event.getDeviceId(), event.getScanCode(),
@@ -803,7 +811,7 @@
             mKeyboardSwitcher = new KeyboardSwitcher(this, this);
         }
         mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher);
-        if (mInputView != null) {
+        if (mKeyboardSwitcher.getInputView() != null) {
             mKeyboardSwitcher.setVoiceMode(mEnableVoice && mEnableVoiceButton, mVoiceOnPrimary);
         }
         mKeyboardSwitcher.makeKeyboards(true);
@@ -831,9 +839,10 @@
 
     public void updateShiftKeyState(EditorInfo attr) {
         InputConnection ic = getCurrentInputConnection();
-        if (attr != null && mInputView != null && mKeyboardSwitcher.isAlphabetMode()
-                && ic != null) {
-            mInputView.setShifted(mCapsLock || getCursorCapsMode(ic, attr) != 0);
+        if (attr != null && mKeyboardSwitcher.getInputView() != null
+                && mKeyboardSwitcher.isAlphabetMode() && ic != null) {
+            mKeyboardSwitcher.getInputView().setShifted(
+                    mCapsLock || getCursorCapsMode(ic, attr) != 0);
         }
     }
 
@@ -946,6 +955,7 @@
             case Keyboard.KEYCODE_DELETE:
                 handleBackspace();
                 mDeleteCount++;
+                LatinImeLogger.logOnDelete(1);
                 break;
             case Keyboard.KEYCODE_SHIFT:
                 handleShift();
@@ -991,6 +1001,7 @@
                 } else {
                     handleCharacter(primaryCode, keyCodes);
                 }
+                LatinImeLogger.logOnInputChar(1);
                 // Cancel the just reverted state
                 mJustRevertedSeparator = null;
         }
@@ -1080,7 +1091,8 @@
         if (mKeyboardSwitcher.isAlphabetMode()) {
             // Alphabet keyboard
             checkToggleCapsLock();
-            mInputView.setShifted(mCapsLock || !mInputView.isShifted());
+            mKeyboardSwitcher.getInputView().setShifted(mCapsLock
+                    || !mKeyboardSwitcher.getInputView().isShifted());
         } else {
             mKeyboardSwitcher.toggleShift();
         }
@@ -1103,7 +1115,7 @@
                 mWord.reset();
             }
         }
-        if (mInputView.isShifted()) {
+        if (mKeyboardSwitcher.getInputView().isShifted()) {
             // TODO: This doesn't work with ß, need to fix it in the next release.
             if (keyCodes == null || keyCodes[0] < Character.MIN_CODE_POINT
                     || keyCodes[0] > Character.MAX_CODE_POINT) {
@@ -1112,7 +1124,7 @@
             primaryCode = new String(keyCodes, 0, 1).toUpperCase().charAt(0);
         }
         if (mPredicting) {
-            if (mInputView.isShifted() && mComposing.length() == 0) {
+            if (mKeyboardSwitcher.getInputView().isShifted() && mComposing.length() == 0) {
                 mWord.setCapitalized(true);
             }
             mComposing.append((char) primaryCode);
@@ -1207,12 +1219,12 @@
             mVoiceInput.cancel();
         }
         requestHideSelf(0);
-        mInputView.closing();
+        mKeyboardSwitcher.getInputView().closing();
         TextEntryState.endSession();
     }
 
     private void checkToggleCapsLock() {
-        if (mInputView.getKeyboard().isShifted()) {
+        if (mKeyboardSwitcher.getInputView().getKeyboard().isShifted()) {
             toggleCapsLock();
         }
     }
@@ -1220,7 +1232,8 @@
     private void toggleCapsLock() {
         mCapsLock = !mCapsLock;
         if (mKeyboardSwitcher.isAlphabetMode()) {
-            ((LatinKeyboard) mInputView.getKeyboard()).setShiftLocked(mCapsLock);
+            ((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).setShiftLocked(
+                    mCapsLock);
         }
     }
 
@@ -1248,8 +1261,8 @@
       mHandler.post(new Runnable() {
           public void run() {
               mRecognizing = false;
-              if (mInputView != null) {
-                setInputView(mInputView);
+              if (mKeyboardSwitcher.getInputView() != null) {
+                setInputView(mKeyboardSwitcher.getInputView());
               }
               updateInputViewShown();
           }});
@@ -1348,7 +1361,7 @@
 
         Window window = mVoiceWarningDialog.getWindow();
         WindowManager.LayoutParams lp = window.getAttributes();
-        lp.token = mInputView.getWindowToken();
+        lp.token = mKeyboardSwitcher.getInputView().getWindowToken();
         lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
         window.setAttributes(lp);
         window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
@@ -1384,7 +1397,8 @@
 
         final List<CharSequence> nBest = new ArrayList<CharSequence>();
         boolean capitalizeFirstWord = preferCapitalization()
-                || (mKeyboardSwitcher.isAlphabetMode() && mInputView.isShifted());
+                || (mKeyboardSwitcher.isAlphabetMode()
+                        && mKeyboardSwitcher.getInputView().isShifted());
         for (String c : mVoiceResults.candidates) {
             if (capitalizeFirstWord) {
                 c = Character.toUpperCase(c.charAt(0)) + c.substring(1, c.length());
@@ -1442,7 +1456,8 @@
     private void updateSuggestions() {
         mSuggestionShouldReplaceCurrentWord = false;
 
-        ((LatinKeyboard) mInputView.getKeyboard()).setPreferredLetters(null);
+        LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
+        ((LatinKeyboard) inputView.getKeyboard()).setPreferredLetters(null);
 
         // Check if we have a suggestion engine attached.
         if ((mSuggest == null || !isPredictionOn()) && !mVoiceInputHighlighted) {
@@ -1454,17 +1469,20 @@
             return;
         }
 
-        List<CharSequence> stringList = mSuggest.getSuggestions(mInputView, mWord, false);
+        List<CharSequence> stringList = mSuggest.getSuggestions(inputView,
+                mWord, false);
         int[] nextLettersFrequencies = mSuggest.getNextLettersFrequencies();
 
-        ((LatinKeyboard) mInputView.getKeyboard()).setPreferredLetters(nextLettersFrequencies);
+        ((LatinKeyboard) inputView.getKeyboard()).setPreferredLetters(
+                nextLettersFrequencies);
 
         boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasMinimalCorrection();
         //|| mCorrectionMode == mSuggest.CORRECTION_FULL;
         CharSequence typedWord = mWord.getTypedWord();
         // If we're in basic correct
         boolean typedWordValid = mSuggest.isValidWord(typedWord) ||
-                (preferCapitalization() && mSuggest.isValidWord(typedWord.toString().toLowerCase()));
+                (preferCapitalization()
+                        && mSuggest.isValidWord(typedWord.toString().toLowerCase()));
         if (mCorrectionMode == Suggest.CORRECTION_FULL) {
             correctionAvailable |= typedWordValid;
         }
@@ -1531,6 +1549,10 @@
 
         // If this is a punctuation, apply it through the normal key press
         if (suggestion.length() == 1 && isWordSeparator(suggestion.charAt(0))) {
+            // Word separators are suggested before the user inputs something.
+            // So, LatinImeLogger logs suggestion.charAt(0) as a user's input.
+            LatinImeLogger.logOnClickSuggestion(
+                    suggestion.toString(), suggestion.toString(), index);
             onKey(suggestion.charAt(0), null);
             if (ic != null) {
                 ic.endBatchEdit();
@@ -1543,6 +1565,8 @@
         if (index == 0) {
             checkAddToDictionary(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED);
         }
+        LatinImeLogger.logOnClickSuggestion(
+                mComposing.toString(), suggestion.toString(), index);
         TextEntryState.acceptedSuggestion(mComposing.toString(), suggestion);
         // Follow it with a space
         if (mAutoSpace) {
@@ -1560,10 +1584,12 @@
     }
 
     private void pickSuggestion(CharSequence suggestion) {
+        LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
         if (mCapsLock) {
             suggestion = suggestion.toString().toUpperCase();
         } else if (preferCapitalization()
-                || (mKeyboardSwitcher.isAlphabetMode() && mInputView.isShifted())) {
+                || (mKeyboardSwitcher.isAlphabetMode()
+                        && inputView.isShifted())) {
             suggestion = suggestion.toString().toUpperCase().charAt(0)
                     + suggestion.subSequence(1, suggestion.length()).toString();
         }
@@ -1578,7 +1604,7 @@
         }
         mPredicting = false;
         mCommittedLength = suggestion.length();
-        ((LatinKeyboard) mInputView.getKeyboard()).setPreferredLetters(null);
+        ((LatinKeyboard) inputView.getKeyboard()).setPreferredLetters(null);
         setNextSuggestions();
         updateShiftKeyState(getCurrentInputEditorInfo());
     }
@@ -1678,7 +1704,7 @@
             ClipboardManager cm = ((ClipboardManager)getSystemService(CLIPBOARD_SERVICE));
             CharSequence text = cm.getText();
             if (!TextUtils.isEmpty(text)) {
-                mInputView.startPlaying(text.toString());
+                mKeyboardSwitcher.getInputView().startPlaying(text.toString());
             }
         }
     }
@@ -1729,7 +1755,7 @@
 
     public void onRelease(int primaryCode) {
         // Reset any drag flags in the keyboard
-        ((LatinKeyboard) mInputView.getKeyboard()).keyReleased();
+        ((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).keyReleased();
         //vibrate();
     }
 
@@ -1781,7 +1807,7 @@
         // if mAudioManager is null, we don't have the ringer state yet
         // mAudioManager will be set by updateRingerMode
         if (mAudioManager == null) {
-            if (mInputView != null) {
+            if (mKeyboardSwitcher.getInputView() != null) {
                 updateRingerMode();
             }
         }
@@ -1808,8 +1834,9 @@
         if (!mVibrateOn) {
             return;
         }
-        if (mInputView != null) {
-            mInputView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP,
+        if (mKeyboardSwitcher.getInputView() != null) {
+            mKeyboardSwitcher.getInputView().performHapticFeedback(
+                    HapticFeedbackConstants.KEYBOARD_TAP,
                     HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
         }
     }
@@ -1960,7 +1987,7 @@
         mOptionsDialog = builder.create();
         Window window = mOptionsDialog.getWindow();
         WindowManager.LayoutParams lp = window.getAttributes();
-        lp.token = mInputView.getWindowToken();
+        lp.token = mKeyboardSwitcher.getInputView().getWindowToken();
         lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
         window.setAttributes(lp);
         window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
@@ -1970,7 +1997,8 @@
     private void changeKeyboardMode() {
         mKeyboardSwitcher.toggleSymbols();
         if (mCapsLock && mKeyboardSwitcher.isAlphabetMode()) {
-            ((LatinKeyboard) mInputView.getKeyboard()).setShiftLocked(mCapsLock);
+            ((LatinKeyboard) mKeyboardSwitcher.getInputView().getKeyboard()).setShiftLocked(
+                    mCapsLock);
         }
 
         updateShiftKeyState(getCurrentInputEditorInfo());
diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
new file mode 100644
index 0000000..dcd1962
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
@@ -0,0 +1,393 @@
+/*
+ * Copyright (C) 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.
+ */
+
+package com.android.inputmethod.latin;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.DropBoxManager;
+import android.preference.PreferenceManager;
+import android.text.TextUtils;
+import android.text.format.DateUtils;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChangeListener {
+    private static final String TAG = "LatinIMELogs";
+    private static boolean sDBG = false;
+    // DEFAULT_LOG_ENABLED should be false when released to public.
+    private static final boolean DEFAULT_LOG_ENABLED = true;
+
+    private static final long MINIMUMSENDINTERVAL = 300 * DateUtils.SECOND_IN_MILLIS; // 300 sec
+    private static final long MINIMUMCOUNTINTERVAL = 20 * DateUtils.SECOND_IN_MILLIS; // 20 sec
+    private static final char SEPARATER = ';';
+    private static final int ID_CLICKSUGGESTION = 0;
+    private static final int ID_AUTOSUGGESTION = 1;
+    private static final int ID_AUTOSUGGESTIONCANCELED = 2;
+    private static final int ID_INPUT_COUNT = 3;
+    private static final int ID_DELETE_COUNT = 4;
+    private static final int ID_WORD_COUNT = 5;
+    private static final int ID_ACTUAL_CHAR_COUNT = 6;
+    private static final int ID_THEME_ID = 7;
+
+    private static final String PREF_ENABLE_LOG = "enable_logging";
+    private static final String PREF_DEBUG_MODE = "debug_mode";
+
+    public static boolean sLogEnabled = true;
+    private static LatinImeLogger sLatinImeLogger = new LatinImeLogger();
+    // Store the last auto suggested word.
+    // This is required for a cancellation log of auto suggestion of that word.
+    private static String sLastAutoSuggestBefore;
+    private static String sLastAutoSuggestAfter;
+
+    private ArrayList<LogEntry> mLogBuffer = null;
+    private ArrayList<LogEntry> mPrivacyLogBuffer = null;
+    private Context mContext = null;
+    private DropBoxManager mDropBox = null;
+    private long mLastTimeActive;
+    private long mLastTimeSend;
+    private long mLastTimeCountEntry;
+
+    private String mThemeId;
+    private int mDeleteCount;
+    private int mInputCount;
+    private int mWordCount;
+    // ActualCharCount includes all characters that were completed.
+    private int mActualCharCount;
+
+    private static class LogEntry implements Comparable<LogEntry> {
+        public final int mTag;
+        public final String[] mData;
+        public long mTime;
+
+        public LogEntry (long time, int tag, String[] data) {
+            mTag = tag;
+            mTime = time;
+            mData = data;
+        }
+
+        public int compareTo(LogEntry log2) {
+            if (mData.length == 0 && log2.mData.length == 0) {
+                return 0;
+            } else if (mData.length == 0) {
+                return 1;
+            } else if (log2.mData.length == 0) {
+                return -1;
+            }
+            return log2.mData[0].compareTo(mData[0]);
+        }
+    }
+
+    private void initInternal(Context context) {
+        mContext = context;
+        mDropBox = (DropBoxManager) mContext.getSystemService(Context.DROPBOX_SERVICE);
+        mLastTimeSend = System.currentTimeMillis();
+        mLastTimeActive = mLastTimeSend;
+        mLastTimeCountEntry = mLastTimeSend;
+        mDeleteCount = 0;
+        mInputCount = 0;
+        mWordCount = 0;
+        mActualCharCount = 0;
+        mLogBuffer = new ArrayList<LogEntry>();
+        mPrivacyLogBuffer = new ArrayList<LogEntry>();
+        final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+        sLogEnabled = prefs.getBoolean(PREF_ENABLE_LOG, DEFAULT_LOG_ENABLED);
+        mThemeId = prefs.getString(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT,
+                KeyboardSwitcher.DEFAULT_LAYOUT_ID);
+        sDBG = prefs.getBoolean(PREF_DEBUG_MODE, sDBG);
+        prefs.registerOnSharedPreferenceChangeListener(this);
+    }
+
+    /**
+     * Clear all logged data
+     */
+    private void reset() {
+        mDeleteCount = 0;
+        mInputCount = 0;
+        mWordCount = 0;
+        mActualCharCount = 0;
+        mLogBuffer.clear();
+        mPrivacyLogBuffer.clear();
+    }
+
+    /**
+     * Check if the input string is safe as an entry or not.
+     */
+    private static boolean checkStringDataSafe(String s) {
+        if (sDBG) {
+            Log.d(TAG, "Check String safety: " + s);
+        }
+        for (int i = 0; i < s.length(); ++i) {
+            if (!Character.isDigit(s.charAt(i))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private void addCountEntry(long time) {
+        if (sDBG) {
+            Log.d(TAG, "Log counts. (4)");
+        }
+        mLogBuffer.add(new LogEntry (time, ID_DELETE_COUNT,
+                new String[] {String.valueOf(mDeleteCount)}));
+        mLogBuffer.add(new LogEntry (time, ID_INPUT_COUNT,
+                new String[] {String.valueOf(mInputCount)}));
+        mLogBuffer.add(new LogEntry (time, ID_WORD_COUNT,
+                new String[] {String.valueOf(mWordCount)}));
+        mLogBuffer.add(new LogEntry (time, ID_ACTUAL_CHAR_COUNT,
+                new String[] {String.valueOf(mActualCharCount)}));
+        mDeleteCount = 0;
+        mInputCount = 0;
+        mWordCount = 0;
+        mActualCharCount = 0;
+        mLastTimeCountEntry = time;
+    }
+
+    private void addThemeIdEntry(long time) {
+        if (sDBG) {
+            Log.d(TAG, "Log theme Id. (1)");
+        }
+        mLogBuffer.add(new LogEntry (time, ID_THEME_ID,
+                new String[] {mThemeId}));
+    }
+
+    private void flushPrivacyLogSafely() {
+        if (sDBG) {
+            Log.d(TAG, "Log theme Id. (" + mPrivacyLogBuffer.size() + ")");
+        }
+        long now = System.currentTimeMillis();
+        Collections.sort(mPrivacyLogBuffer);
+        for (LogEntry l: mPrivacyLogBuffer) {
+            l.mTime = now;
+            mLogBuffer.add(l);
+        }
+        mPrivacyLogBuffer.clear();
+    }
+
+    /**
+     * Add an entry
+     * @param tag
+     * @param data
+     */
+    private void addData(int tag, Object data) {
+        switch (tag) {
+            case ID_DELETE_COUNT:
+                if (((mLastTimeActive - mLastTimeCountEntry) > MINIMUMCOUNTINTERVAL)
+                        || (mDeleteCount == 0 && mInputCount == 0)) {
+                    addCountEntry(mLastTimeActive);
+                    addThemeIdEntry(mLastTimeActive);
+                }
+                mDeleteCount += (Integer)data;
+                break;
+            case ID_INPUT_COUNT:
+                if (((mLastTimeActive - mLastTimeCountEntry) > MINIMUMCOUNTINTERVAL)
+                        || (mDeleteCount == 0 && mInputCount == 0)) {
+                    addCountEntry(mLastTimeActive);
+                    addThemeIdEntry(mLastTimeActive);
+                }
+                mInputCount += (Integer)data;
+                break;
+            case ID_CLICKSUGGESTION:
+            case ID_AUTOSUGGESTION:
+                ++mWordCount;
+                String[] dataStrings = (String[]) data;
+                if (dataStrings.length < 2) {
+                    if (sDBG) {
+                        Log.e(TAG, "The length of logged string array is invalid.");
+                    }
+                    break;
+                }
+                mActualCharCount += dataStrings[1].length();
+                if (checkStringDataSafe(dataStrings[0]) && checkStringDataSafe(dataStrings[1])) {
+                    mPrivacyLogBuffer.add(
+                            new LogEntry (System.currentTimeMillis(), tag, dataStrings));
+                } else {
+                    if (sDBG) {
+                        Log.d(TAG, "Skipped to add an entry because data is unsafe.");
+                    }
+                }
+                break;
+            case ID_AUTOSUGGESTIONCANCELED:
+                --mWordCount;
+                dataStrings = (String[]) data;
+                if (dataStrings.length < 2) {
+                    if (sDBG) {
+                        Log.e(TAG, "The length of logged string array is invalid.");
+                    }
+                    break;
+                }
+                mActualCharCount -= dataStrings[1].length();
+                if (checkStringDataSafe(dataStrings[0]) && checkStringDataSafe(dataStrings[1])) {
+                    mPrivacyLogBuffer.add(
+                            new LogEntry (System.currentTimeMillis(), tag, dataStrings));
+                } else {
+                    if (sDBG) {
+                        Log.d(TAG, "Skipped to add an entry because data is unsafe.");
+                    }
+                }
+                break;
+            default:
+                if (sDBG) {
+                    Log.e(TAG, "Log Tag is not entried.");
+                }
+                break;
+        }
+    }
+
+    private void commitInternal() {
+        if (sDBG) {
+            Log.d(TAG, "Commit (" + mLogBuffer.size() + ")");
+        }
+        flushPrivacyLogSafely();
+        long now = System.currentTimeMillis();
+        addCountEntry(now);
+        addThemeIdEntry(now);
+        String s = LogSerializer.createStringFromEntries(mLogBuffer);
+        if (!TextUtils.isEmpty(s)) {
+            if (sDBG) {
+                Log.d(TAG, "Commit log: " + s);
+            }
+            mDropBox.addText(TAG, s);
+        }
+        reset();
+        mLastTimeSend = now;
+    }
+
+    private synchronized void sendLogToDropBox(int tag, Object s) {
+        long now = System.currentTimeMillis();
+        if (sDBG) {
+            String out = "";
+            if (s instanceof String[]) {
+                for (String str: ((String[]) s)) {
+                    out += str + ",";
+                }
+            } else if (s instanceof Integer) {
+                out += (Integer) s;
+            }
+            Log.d(TAG, "SendLog: " + tag + ";" + out + ", will be sent after "
+                    + (- (now - mLastTimeSend - MINIMUMSENDINTERVAL) / 1000) + " sec.");
+        }
+        if (now - mLastTimeActive > MINIMUMSENDINTERVAL) {
+            // Send a log before adding an log entry if the last data is too old.
+            commitInternal();
+            addData(tag, s);
+        } else if (now - mLastTimeSend > MINIMUMSENDINTERVAL) {
+            // Send a log after adding an log entry.
+            addData(tag, s);
+            commitInternal();
+        } else {
+            addData(tag, s);
+        }
+        mLastTimeActive = now;
+    }
+
+    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+        if (PREF_ENABLE_LOG.equals(key)) {
+            if (sharedPreferences.getBoolean(key, DEFAULT_LOG_ENABLED)) {
+                sLogEnabled = (mContext != null);
+            } else {
+                sLogEnabled = false;
+            }
+        } else if (KeyboardSwitcher.PREF_KEYBOARD_LAYOUT.equals(key)) {
+            mThemeId = sharedPreferences.getString(KeyboardSwitcher.PREF_KEYBOARD_LAYOUT,
+                    KeyboardSwitcher.DEFAULT_LAYOUT_ID);
+        } else if (PREF_DEBUG_MODE.equals(key)) {
+            sDBG = sharedPreferences.getBoolean(PREF_DEBUG_MODE, sDBG);
+        }
+    }
+
+    public static void init(Context context) {
+        sLatinImeLogger.initInternal(context);
+    }
+
+    public static void commit() {
+        if (sLogEnabled) {
+            sLatinImeLogger.commitInternal();
+        }
+    }
+
+    // TODO: Handle CharSequence instead of String
+    public static void logOnClickSuggestion(String before, String after, int position) {
+        if (sLogEnabled) {
+            String[] strings = new String[] {before, after, String.valueOf(position)};
+            sLatinImeLogger.sendLogToDropBox(ID_CLICKSUGGESTION, strings);
+        }
+    }
+
+    public static void logOnAutoSuggestion(String before, String after) {
+        if (sLogEnabled) {
+            String[] strings = new String[] {before, after};
+            synchronized (LatinImeLogger.class) {
+                sLastAutoSuggestBefore = before;
+                sLastAutoSuggestAfter = after;
+            }
+            sLatinImeLogger.sendLogToDropBox(ID_AUTOSUGGESTIONCANCELED, strings);
+        }
+    }
+
+    public static void logOnAutoSuggestionCanceled() {
+        if (sLogEnabled) {
+            if (sLastAutoSuggestBefore != null && sLastAutoSuggestAfter != null) {
+                String[] strings = new String[] {sLastAutoSuggestBefore, sLastAutoSuggestAfter};
+                sLatinImeLogger.sendLogToDropBox(ID_AUTOSUGGESTION, strings);
+            }
+        }
+    }
+
+    public static void logOnDelete(int length) {
+        if (sLogEnabled) {
+            sLatinImeLogger.sendLogToDropBox(ID_DELETE_COUNT, length);
+        }
+    }
+
+    public static void logOnInputChar(int length) {
+        if (sLogEnabled) {
+            sLatinImeLogger.sendLogToDropBox(ID_INPUT_COUNT, length);
+        }
+    }
+
+    private static class LogSerializer {
+        private static void appendWithLength(StringBuffer sb, String data) {
+            sb.append(data.length());
+            sb.append(SEPARATER);
+            sb.append(data);
+            sb.append(SEPARATER);
+        }
+
+        private static void appendLogEntry(StringBuffer sb, String time, String tag,
+                String[] data) {
+            if (data.length > 0) {
+                appendWithLength(sb, String.valueOf(data.length + 2));
+                appendWithLength(sb, time);
+                appendWithLength(sb, tag);
+                for (String s: data) {
+                    appendWithLength(sb, s);
+                }
+            }
+        }
+
+        public static String createStringFromEntries(ArrayList<LogEntry> logs) {
+            StringBuffer sb = new StringBuffer();
+            for (LogEntry log: logs) {
+                appendLogEntry(sb, String.valueOf(log.mTime), String.valueOf(log.mTag), log.mData);
+            }
+            return sb.toString();
+        }
+    }
+}
diff --git a/java/src/com/android/inputmethod/latin/TextEntryState.java b/java/src/com/android/inputmethod/latin/TextEntryState.java
index d056ceb..d291af6 100644
--- a/java/src/com/android/inputmethod/latin/TextEntryState.java
+++ b/java/src/com/android/inputmethod/latin/TextEntryState.java
@@ -130,6 +130,7 @@
         sTypedChars += typedWord.length();
         sActualChars += actualWord.length();
         sState = STATE_ACCEPTED_DEFAULT;
+        LatinImeLogger.logOnAutoSuggestion(typedWord.toString(), actualWord.toString());
     }
     
     public static void acceptedTyped(CharSequence typedWord) {
@@ -199,6 +200,7 @@
         if (sState == STATE_ACCEPTED_DEFAULT) {
             sState = STATE_UNDO_COMMIT;
             sAutoSuggestUndoneCount++;
+            LatinImeLogger.logOnAutoSuggestionCanceled();
         } else if (sState == STATE_UNDO_COMMIT) {
             sState = STATE_IN_WORD;
         }
diff --git a/native/Android.mk b/native/Android.mk
index 0df74c7..5755109 100644
--- a/native/Android.mk
+++ b/native/Android.mk
@@ -11,8 +11,10 @@
 LOCAL_C_INCLUDES += \
 	$(JNI_H_INCLUDE)
 
-LOCAL_MODULE := libjni_latinime
+LOCAL_PRELINK_MODULE := false
 
-LOCAL_MODULE_TAGS := user
+LOCAL_MODULE := libjni_latinime2
+
+LOCAL_MODULE_TAGS := optional
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/Android.mk b/tests/Android.mk
index fba7a8d..e72587d 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -12,6 +12,6 @@
 
 LOCAL_PACKAGE_NAME := LatinIMETests
 
-LOCAL_INSTRUMENTATION_FOR := LatinIME
+LOCAL_INSTRUMENTATION_FOR := LatinIme2Google
 
 include $(BUILD_PACKAGE)