Merge "Add a logging code to send Bigram data"
diff --git a/java/Android.mk b/java/Android.mk
index c89e1c6..0d5a93d 100755
--- a/java/Android.mk
+++ b/java/Android.mk
@@ -23,4 +23,11 @@
 
 LOCAL_PROGUARD_FLAGS := -include $(LOCAL_PATH)/proguard.flags
 
+# Define LOCAL_DICTIONARY_RESOURCE_DIR in order to overlay dictionaries.
+# The overlay dictionary resource directory should have dictionary files such
+# as raw-en/main.dict, raw-es/main.dict per locale.
+ifneq ($(strip $(LOCAL_DICTIONARY_RESOURCE_DIR)),)
+LOCAL_RESOURCE_DIR := $(LOCAL_DICTIONARY_RESOURCE_DIR) $(LOCAL_PATH)/res
+endif
+
 include $(BUILD_PACKAGE)
diff --git a/java/res/drawable/btn_keyboard_key_normal_off_ginger.9.png b/java/res/drawable/btn_keyboard_key_normal_off_stone.9.png
similarity index 100%
rename from java/res/drawable/btn_keyboard_key_normal_off_ginger.9.png
rename to java/res/drawable/btn_keyboard_key_normal_off_stone.9.png
Binary files differ
diff --git a/java/res/drawable/btn_keyboard_key_normal_on_ginger.9.png b/java/res/drawable/btn_keyboard_key_normal_on_stone.9.png
similarity index 100%
rename from java/res/drawable/btn_keyboard_key_normal_on_ginger.9.png
rename to java/res/drawable/btn_keyboard_key_normal_on_stone.9.png
Binary files differ
diff --git a/java/res/drawable/btn_keyboard_key_normal_ginger.9.png b/java/res/drawable/btn_keyboard_key_normal_stone.9.png
similarity index 100%
rename from java/res/drawable/btn_keyboard_key_normal_ginger.9.png
rename to java/res/drawable/btn_keyboard_key_normal_stone.9.png
Binary files differ
diff --git a/java/res/drawable/btn_keyboard_key_ginger.xml b/java/res/drawable/btn_keyboard_key_stone.xml
similarity index 92%
rename from java/res/drawable/btn_keyboard_key_ginger.xml
rename to java/res/drawable/btn_keyboard_key_stone.xml
index 7477037..a6040a0 100644
--- a/java/res/drawable/btn_keyboard_key_ginger.xml
+++ b/java/res/drawable/btn_keyboard_key_stone.xml
@@ -20,17 +20,17 @@
 
     <item android:state_checkable="true" android:state_checked="true"
           android:state_pressed="true"
-          android:drawable="@drawable/btn_keyboard_key_normal_on_ginger" />
+          android:drawable="@drawable/btn_keyboard_key_normal_on_stone" />
     <item android:state_checkable="true" android:state_pressed="true"
-          android:drawable="@drawable/btn_keyboard_key_normal_off_ginger" />
+          android:drawable="@drawable/btn_keyboard_key_normal_off_stone" />
     <item android:state_checkable="true" android:state_checked="true"
-          android:drawable="@drawable/btn_keyboard_key_normal_on_ginger" />
+          android:drawable="@drawable/btn_keyboard_key_normal_on_stone" />
     <item android:state_checkable="true"
-          android:drawable="@drawable/btn_keyboard_key_normal_off_ginger" />
+          android:drawable="@drawable/btn_keyboard_key_normal_off_stone" />
 
     <!-- Normal keys -->
 
     <item android:state_pressed="true"
           android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
-    <item android:drawable="@drawable/btn_keyboard_key_normal_ginger" />
+    <item android:drawable="@drawable/btn_keyboard_key_normal_stone" />
 </selector>
diff --git a/java/res/layout-xlarge/input.xml b/java/res/layout-xlarge/input.xml
deleted file mode 100644
index 6b0bb12..0000000
--- a/java/res/layout-xlarge/input.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-
-<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:background="@drawable/keyboard_background"
-        android:keyBackground="@drawable/btn_keyboard_key"
-        android:keyTextSize="32sp"
-        android:verticalCorrection="0dip"
-        />
diff --git a/java/res/layout-xlarge/input_trans.xml b/java/res/layout-xlarge/input_trans.xml
deleted file mode 100755
index 1dfdc15..0000000
--- a/java/res/layout-xlarge/input_trans.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-**
-** Copyright 2010, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-
-<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:background="@color/latinkeyboard_extension_background"
-        android:verticalCorrection="0dip"
-        android:keyTextSize="32sp"
-        android:keyBackground="@drawable/btn_keyboard_key_fulltrans"
-        />
diff --git a/java/res/layout/input_stone_bold.xml b/java/res/layout/input_stone_bold.xml
index 8cc082b..d6c03cc 100755
--- a/java/res/layout/input_stone_bold.xml
+++ b/java/res/layout/input_stone_bold.xml
@@ -28,8 +28,7 @@
         android:background="@drawable/keyboard_background"
         android:textStyle="bold"
 
-        latin:keyBackground="@drawable/btn_keyboard_key_ginger"
-        latin:keyTextSize="22dip"
+        latin:keyBackground="@drawable/btn_keyboard_key_stone"
         latin:keyTextColor="@color/latinkeyboard_key_color_black"
         latin:shadowColor="@color/latinkeyboard_key_color_white"
         latin:keyTextStyle="bold"
diff --git a/java/res/layout/input_stone_normal.xml b/java/res/layout/input_stone_normal.xml
index 5169350..2c39bb1 100755
--- a/java/res/layout/input_stone_normal.xml
+++ b/java/res/layout/input_stone_normal.xml
@@ -27,8 +27,7 @@
         android:layout_height="wrap_content"
         android:background="@drawable/keyboard_background"
 
-        latin:keyBackground="@drawable/btn_keyboard_key_ginger"
-        latin:keyTextSize="22dip"
+        latin:keyBackground="@drawable/btn_keyboard_key_stone"
         latin:keyTextColor="@color/latinkeyboard_key_color_black"
         latin:shadowColor="@color/latinkeyboard_key_color_white"
         latin:symbolColorScheme="black"
diff --git a/java/res/layout/input_stone_popup.xml b/java/res/layout/input_stone_popup.xml
index e6eae5d..b6894b6 100755
--- a/java/res/layout/input_stone_popup.xml
+++ b/java/res/layout/input_stone_popup.xml
@@ -33,10 +33,9 @@
             android:layout_height="wrap_content"
             android:background="@drawable/keyboard_background"
 
-            latin:keyBackground="@drawable/btn_keyboard_key_ginger"
+            latin:keyBackground="@drawable/btn_keyboard_key_stone"
             latin:keyTextColor="@color/latinkeyboard_key_color_black"
             latin:shadowColor="@color/latinkeyboard_key_color_white"
-            latin:keyTextSize="22dip"
             latin:popupLayout="@layout/input_stone_popup"
         />
     <ImageButton android:id="@+id/closeButton"
@@ -48,4 +47,4 @@
         android:layout_marginLeft="8dp"
         android:clickable="true"
         />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/java/res/layout/keyboard_popup_keyboard.xml b/java/res/layout/keyboard_popup_keyboard.xml
index e6b3a41..5f8a03d 100644
--- a/java/res/layout/keyboard_popup_keyboard.xml
+++ b/java/res/layout/keyboard_popup_keyboard.xml
@@ -33,7 +33,6 @@
             android:background="@android:color/transparent"
 
             latin:keyPreviewLayout="@layout/keyboard_key_preview"
-            latin:keyTextSize="22sp"
             latin:popupLayout="@layout/keyboard_popup_keyboard"
             />
     <ImageButton android:id="@+id/closeButton"
@@ -45,4 +44,4 @@
         android:layout_marginLeft="8dp"
         android:clickable="true"
         />
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/java/res/values-sr/strings.xml b/java/res/values-sr/strings.xml
index 64f5af1..f706ebc 100644
--- a/java/res/values-sr/strings.xml
+++ b/java/res/values-sr/strings.xml
@@ -93,13 +93,6 @@
         <item>Напредно</item>
     </string-array>
 
-    <!-- Don't translate -->
-    <string name="prediction_none" translatable="false">0</string>
-    <!-- Don't translate -->
-    <string name="prediction_basic" translatable="false">1</string>
-    <!-- Don't translate -->
-    <string name="prediction_full"  translatable="false">2</string>
-
     <string-array name="prediction_modes_values" translatable="false">
         <item>@string/prediction_none</item>
         <item>@string/prediction_basic</item>
@@ -249,13 +242,6 @@
         <item>Искључен</item>
     </string-array>
 
-    <!-- Don't translate -->
-    <string name="voice_mode_main" translatable="false">0</string>
-    <!-- Don't translate -->
-    <string name="voice_mode_symbols" translatable="false">1</string>
-    <!-- Don't translate -->
-    <string name="voice_mode_off"  translatable="false">2</string>
-
     <string-array name="voice_input_modes_values" translatable="false">
         <item>@string/voice_mode_main</item>
         <item>@string/voice_mode_symbols</item>
diff --git a/java/res/values-xlarge/dimens.xml b/java/res/values-xlarge/dimens.xml
index 4331762..c823488 100644
--- a/java/res/values-xlarge/dimens.xml
+++ b/java/res/values-xlarge/dimens.xml
@@ -22,4 +22,5 @@
     <dimen name="key_height">72dip</dimen>
     <dimen name="candidate_strip_height">46dip</dimen>
     <dimen name="spacebar_vertical_correction">0dip</dimen>
+    <dimen name="key_text_size">32sp</dimen>
 </resources>
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index f057c16..81ae64e 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -26,4 +26,5 @@
     <!-- If the screen height in landscape is larger than the below value, then the keyboard
          will not go into extract (fullscreen) mode. -->
     <dimen name="max_height_for_fullscreen">2.5in</dimen>
-</resources>
\ No newline at end of file
+    <dimen name="key_text_size">22sp</dimen>
+</resources>
diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml
index 1433550..24fee02 100644
--- a/java/res/values/styles.xml
+++ b/java/res/values/styles.xml
@@ -19,7 +19,7 @@
         <item name="android:background">@drawable/keyboard_background</item>
 
         <item name="keyBackground">@drawable/btn_keyboard_key</item>
-        <item name="keyTextSize">22sp</item>
+        <item name="keyTextSize">@dimen/key_text_size</item>
         <item name="keyTextColor">#FFFFFFFF</item>
         <item name="keyPreviewLayout">@layout/keyboard_key_preview</item>
         <item name="keyPreviewOffset">-12dip</item>
diff --git a/java/res/xml-da/kbd_qwerty.xml b/java/res/xml-da/kbd_qwerty.xml
new file mode 100644
index 0000000..472f8be
--- /dev/null
+++ b/java/res/xml-da/kbd_qwerty.xml
@@ -0,0 +1,213 @@
+<?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.
+*/
+-->
+
+<!--
+    Danish Keyboard Layout
+
+    Just a copy of the Norwegian layout, with æ/ø switched.
+-->
+
+<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:codes="113" android:keyLabel="q"
+                android:keyWidth="8.75%p" android:keyEdgeFlags="left"/>
+        <Key android:codes="119" android:keyLabel="w"/>
+        <Key android:codes="101" android:keyLabel="e"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="éèêëę€"/>
+        <Key android:codes="114" android:keyLabel="r"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ř"/>
+        <Key android:codes="116" android:keyLabel="t"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ťþ"/>
+        <Key android:codes="121" android:keyLabel="y"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ýÿü"/>
+        <Key android:codes="117" android:keyLabel="u"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="úùûū"/>
+        <Key android:codes="105" android:keyLabel="i"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="íìîï"/>
+        <Key android:codes="111" android:keyLabel="o"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="óòôõ"/>
+        <Key android:codes="112" android:keyLabel="p"/>
+        <Key android:keyLabel="å"
+                android:keyWidth="8.75%p" android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row>
+        <Key android:codes="97" android:keyLabel="a"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="áàâąã"
+                android:keyWidth="8.75%p" android:keyEdgeFlags="left"/>
+        <Key android:codes="115" android:keyLabel="s"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="śšşß"/>
+        <Key android:codes="100" android:keyLabel="d"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ðď"/>
+        <Key android:codes="102" android:keyLabel="f"/>
+        <Key android:codes="103" android:keyLabel="g"/>
+        <Key android:codes="104" android:keyLabel="h"/>
+        <Key android:codes="106" android:keyLabel="j"/>
+        <Key android:codes="107" android:keyLabel="k"/>
+        <Key android:codes="108" android:keyLabel="l"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ł"/>
+        <Key android:keyLabel="æ"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ä"/>
+        <Key android:keyLabel="ø"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="öœ"
+                android:keyWidth="8.75%p" android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row android:keyWidth="10%p">
+        <Key android:codes="-1" android:keyIcon="@drawable/sym_keyboard_shift"
+                android:keyWidth="15%p" android:isModifier="true"
+                android:iconPreview="@drawable/sym_keyboard_feedback_shift"
+                android:isSticky="true" android:keyEdgeFlags="left"/>
+        <Key android:codes="122" android:keyLabel="z"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="źžż"/>
+        <Key android:codes="120" android:keyLabel="x"/>
+        <Key android:codes="99" android:keyLabel="c"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="çćč"/>
+        <Key android:codes="118" android:keyLabel="v"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="w"/>
+        <Key android:codes="98" android:keyLabel="b"/>
+        <Key android:codes="110" android:keyLabel="n"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ńñň"/>
+        <Key android:codes="109" android:keyLabel="m"/>
+        <Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
+                android:keyWidth="15%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_mic"
+                android:iconPreview="@drawable/sym_keyboard_feedback_mic"
+                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:keyLabel="/" 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:keyLabel="@string/popular_domain_0"
+                android:keyOutputText="@string/popular_domain_0"
+                android:popupKeyboard="@xml/popup_domains"
+                android:keyWidth="20%p"/-->
+        <Key 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_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:keyLabel="\@"/>
+        <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:keyLabel="@string/popular_domain_0"
+                android:keyOutputText="@string/popular_domain_0"
+                android:popupKeyboard="@xml/popup_domains"
+                android:keyWidth="20%p"/-->
+        <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
+        <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_mic"
+                android:iconPreview="@drawable/sym_keyboard_feedback_mic"
+                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>
+
+    <Row android:keyboardMode="@+id/mode_webentry" 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_mic"
+                android:iconPreview="@drawable/sym_keyboard_feedback_mic"
+                android:keyWidth="10%p"/>
+        <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
+                android:iconPreview="@drawable/sym_keyboard_feedback_space"
+                android:keyWidth="20%p" android:isRepeatable="true"/>
+        <Key android:codes="9" android:keyIcon="@drawable/sym_keyboard_tab"
+                android:iconPreview="@drawable/sym_keyboard_feedback_tab"
+                android:keyWidth="20%p"/>
+        <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
+        <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>
+
+</Keyboard>
diff --git a/java/res/xml-nb/kbd_qwerty.xml b/java/res/xml-nb/kbd_qwerty.xml
new file mode 100644
index 0000000..554bb00
--- /dev/null
+++ b/java/res/xml-nb/kbd_qwerty.xml
@@ -0,0 +1,213 @@
+<?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.
+*/
+-->
+
+<!--
+    Norwegian Keyboard Layout
+
+    Just a copy of the Swedish layout, with ä/æ and ö/ø switched.
+-->
+
+<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:codes="113" android:keyLabel="q"
+                android:keyWidth="8.75%p" android:keyEdgeFlags="left"/>
+        <Key android:codes="119" android:keyLabel="w"/>
+        <Key android:codes="101" android:keyLabel="e"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="éèêëę€"/>
+        <Key android:codes="114" android:keyLabel="r"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ř"/>
+        <Key android:codes="116" android:keyLabel="t"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ťþ"/>
+        <Key android:codes="121" android:keyLabel="y"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ýÿü"/>
+        <Key android:codes="117" android:keyLabel="u"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="úùûū"/>
+        <Key android:codes="105" android:keyLabel="i"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="íìîï"/>
+        <Key android:codes="111" android:keyLabel="o"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="óòôõ"/>
+        <Key android:codes="112" android:keyLabel="p"/>
+        <Key android:keyLabel="å"
+                android:keyWidth="8.75%p" android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row>
+        <Key android:codes="97" android:keyLabel="a"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="áàâąã"
+                android:keyWidth="8.75%p" android:keyEdgeFlags="left"/>
+        <Key android:codes="115" android:keyLabel="s"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="śšşß"/>
+        <Key android:codes="100" android:keyLabel="d"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ðď"/>
+        <Key android:codes="102" android:keyLabel="f"/>
+        <Key android:codes="103" android:keyLabel="g"/>
+        <Key android:codes="104" android:keyLabel="h"/>
+        <Key android:codes="106" android:keyLabel="j"/>
+        <Key android:codes="107" android:keyLabel="k"/>
+        <Key android:codes="108" android:keyLabel="l"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ł"/>
+        <Key android:keyLabel="ø"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="öœ"/>
+        <Key android:keyLabel="æ"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ä"
+                android:keyWidth="8.75%p" android:keyEdgeFlags="right"/>
+    </Row>
+
+    <Row android:keyWidth="10%p">
+        <Key android:codes="-1" android:keyIcon="@drawable/sym_keyboard_shift"
+                android:keyWidth="15%p" android:isModifier="true"
+                android:iconPreview="@drawable/sym_keyboard_feedback_shift"
+                android:isSticky="true" android:keyEdgeFlags="left"/>
+        <Key android:codes="122" android:keyLabel="z"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="źžż"/>
+        <Key android:codes="120" android:keyLabel="x"/>
+        <Key android:codes="99" android:keyLabel="c"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="çćč"/>
+        <Key android:codes="118" android:keyLabel="v"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="w"/>
+        <Key android:codes="98" android:keyLabel="b"/>
+        <Key android:codes="110" android:keyLabel="n"
+                android:popupKeyboard="@xml/kbd_popup_template"
+                android:popupCharacters="ńñň"/>
+        <Key android:codes="109" android:keyLabel="m"/>
+        <Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
+                android:keyWidth="15%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_mic"
+                android:iconPreview="@drawable/sym_keyboard_feedback_mic"
+                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:keyLabel="/" 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:keyLabel="@string/popular_domain_0"
+                android:keyOutputText="@string/popular_domain_0"
+                android:popupKeyboard="@xml/popup_domains"
+                android:keyWidth="20%p"/-->
+        <Key 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_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:keyLabel="\@"/>
+        <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:keyLabel="@string/popular_domain_0"
+                android:keyOutputText="@string/popular_domain_0"
+                android:popupKeyboard="@xml/popup_domains"
+                android:keyWidth="20%p"/-->
+        <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
+        <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_mic"
+                android:iconPreview="@drawable/sym_keyboard_feedback_mic"
+                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>
+
+    <Row android:keyboardMode="@+id/mode_webentry" 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_mic"
+                android:iconPreview="@drawable/sym_keyboard_feedback_mic"
+                android:keyWidth="10%p"/>
+        <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
+                android:iconPreview="@drawable/sym_keyboard_feedback_space"
+                android:keyWidth="20%p" android:isRepeatable="true"/>
+        <Key android:codes="9" android:keyIcon="@drawable/sym_keyboard_tab"
+                android:iconPreview="@drawable/sym_keyboard_feedback_tab"
+                android:keyWidth="20%p"/>
+        <Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
+        <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>
+
+</Keyboard>
diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
index bbde232..95068e6 100644
--- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
@@ -129,6 +129,9 @@
     }
 
     void makeKeyboards(boolean forceCreate) {
+        mSymbolsId = makeSymbolsId(mHasVoice && !mVoiceOnPrimary);
+        mSymbolsShiftedId = makeSymbolsShiftedId(mHasVoice && !mVoiceOnPrimary);
+
         if (forceCreate) mKeyboards.clear();
         // Configuration change is coming after the keyboard gets recreated. So don't rely on that.
         // If keyboards have already been made, check if we have a screen width change and 
@@ -137,8 +140,6 @@
         if (displayWidth == mLastDisplayWidth) return;
         mLastDisplayWidth = displayWidth;
         if (!forceCreate) mKeyboards.clear();
-        mSymbolsId = makeSymbolsId(mHasVoice && !mVoiceOnPrimary);
-        mSymbolsShiftedId = makeSymbolsShiftedId(mHasVoice && !mVoiceOnPrimary);
     }
 
     /**
@@ -338,7 +339,7 @@
             LatinKeyboard symbolsShiftedKeyboard = getKeyboard(mSymbolsShiftedId);
             symbolsShiftedKeyboard.setShifted(false);
             mCurrentId = mSymbolsId;
-            mInputView.setKeyboard(getKeyboard(mSymbolsId));
+            mInputView.setKeyboard(symbolsKeyboard);
             symbolsKeyboard.setShifted(false);
             symbolsKeyboard.setImeOptions(mContext.getResources(), mMode, mImeOptions);
         }
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
index 4205aad..0a3e4a7 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardBaseView.java
@@ -171,11 +171,6 @@
     /** Listener for {@link OnKeyboardActionListener}. */
     private OnKeyboardActionListener mKeyboardActionListener;
 
-    private static final int MSG_SHOW_PREVIEW = 1;
-    private static final int MSG_REMOVE_PREVIEW = 2;
-    private static final int MSG_REPEAT = 3;
-    private static final int MSG_LONGPRESS = 4;
-
     private static final int DELAY_BEFORE_PREVIEW = 0;
     private static final int DELAY_AFTER_PREVIEW = 70;
     private static final int DEBOUNCE_TIME = 70;
@@ -258,27 +253,79 @@
     /** The canvas for the above mutable keyboard bitmap */
     private Canvas mCanvas;
 
-    Handler mHandler = new Handler() {
+    UIHandler mHandler = new UIHandler();
+
+    class UIHandler extends Handler {
+        private static final int MSG_POPUP_PREVIEW = 1;
+        private static final int MSG_DISMISS_PREVIEW = 2;
+        private static final int MSG_REPEAT_KEY = 3;
+        private static final int MSG_LOGPRESS_KEY = 4;
+
         @Override
         public void handleMessage(Message msg) {
             switch (msg.what) {
-                case MSG_SHOW_PREVIEW:
+                case MSG_POPUP_PREVIEW:
                     showKey(msg.arg1);
                     break;
-                case MSG_REMOVE_PREVIEW:
+                case MSG_DISMISS_PREVIEW:
                     mPreviewText.setVisibility(INVISIBLE);
                     break;
-                case MSG_REPEAT:
+                case MSG_REPEAT_KEY:
                     if (repeatKey()) {
-                        Message repeat = Message.obtain(this, MSG_REPEAT);
-                        sendMessageDelayed(repeat, REPEAT_INTERVAL);
+                        startKeyRepeatTimer(REPEAT_INTERVAL);
                     }
                     break;
-                case MSG_LONGPRESS:
+                case MSG_LOGPRESS_KEY:
                     openPopupIfRequired((MotionEvent) msg.obj);
                     break;
             }
         }
+
+        public void popupPreview(int keyIndex, long delay) {
+            sendMessageDelayed(obtainMessage(MSG_POPUP_PREVIEW, keyIndex, 0), delay);
+        }
+
+        public void cancelPopupPreview() {
+            removeMessages(MSG_POPUP_PREVIEW);
+        }
+
+        public void dismissPreview(long delay) {
+            sendMessageDelayed(obtainMessage(MSG_DISMISS_PREVIEW), delay);
+        }
+
+        public void cancelDismissPreview() {
+            removeMessages(MSG_DISMISS_PREVIEW);
+        }
+
+        public void startKeyRepeatTimer(long delay) {
+            sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY), delay);
+        }
+
+        public void startLongPressTimer(MotionEvent me, long delay) {
+            sendMessageDelayed(obtainMessage(MSG_LOGPRESS_KEY, me), delay);
+        }
+
+        public void cancelLongPressTimer() {
+            removeMessages(MSG_LOGPRESS_KEY);
+        }
+
+        public void cancelKeyTimers() {
+            removeMessages(MSG_REPEAT_KEY);
+            removeMessages(MSG_LOGPRESS_KEY);
+        }
+
+        public void cancelKeyTimersAndPopupPreview() {
+            removeMessages(MSG_REPEAT_KEY);
+            removeMessages(MSG_LOGPRESS_KEY);
+            removeMessages(MSG_POPUP_PREVIEW);
+        }
+
+        public void cancelAllMessages() {
+            removeMessages(MSG_REPEAT_KEY);
+            removeMessages(MSG_LOGPRESS_KEY);
+            removeMessages(MSG_POPUP_PREVIEW);
+            removeMessages(MSG_DISMISS_PREVIEW);
+        }
     };
 
     public LatinKeyboardBaseView(Context context, AttributeSet attrs) {
@@ -475,8 +522,8 @@
         if (mKeyboard != null) {
             showPreview(NOT_A_KEY);
         }
-        // Remove any pending messages
-        removeMessages();
+        // Remove any pending messages, except dismissing preview
+        mHandler.cancelKeyTimersAndPopupPreview();
         mKeyboard = keyboard;
         List<Key> keys = mKeyboard.getKeys();
         mKeys = keys.toArray(new Key[keys.size()]);
@@ -885,12 +932,10 @@
         }
         // If key changed and preview is on ...
         if (oldKeyIndex != mCurrentKeyIndex && mShowPreview) {
-            mHandler.removeMessages(MSG_SHOW_PREVIEW);
+            mHandler.cancelPopupPreview();
             if (previewPopup.isShowing()) {
                 if (keyIndex == NOT_A_KEY) {
-                    mHandler.sendMessageDelayed(mHandler
-                            .obtainMessage(MSG_REMOVE_PREVIEW),
-                            DELAY_AFTER_PREVIEW);
+                    mHandler.dismissPreview(DELAY_AFTER_PREVIEW);
                 }
             }
             if (keyIndex != NOT_A_KEY) {
@@ -898,9 +943,7 @@
                     // Show right away, if it's already visible and finger is moving around
                     showKey(keyIndex);
                 } else {
-                    mHandler.sendMessageDelayed(
-                            mHandler.obtainMessage(MSG_SHOW_PREVIEW, keyIndex, 0),
-                            DELAY_BEFORE_PREVIEW);
+                    mHandler.popupPreview(keyIndex, DELAY_BEFORE_PREVIEW);
                 }
             }
         }
@@ -944,7 +987,7 @@
             mPopupPreviewX = 160 - mPreviewText.getMeasuredWidth() / 2;
             mPopupPreviewY = - mPreviewText.getMeasuredHeight();
         }
-        mHandler.removeMessages(MSG_REMOVE_PREVIEW);
+        mHandler.cancelDismissPreview();
         if (mOffsetInWindow == null) {
             mOffsetInWindow = new int[2];
             getLocationInWindow(mOffsetInWindow);
@@ -1190,8 +1233,7 @@
 
         if (mGestureDetector.onTouchEvent(me)) {
             showPreview(NOT_A_KEY);
-            mHandler.removeMessages(MSG_REPEAT);
-            mHandler.removeMessages(MSG_LONGPRESS);
+            mHandler.cancelKeyTimers();
             return true;
         }
 
@@ -1220,8 +1262,7 @@
                         mKeys[keyIndex].codes[0] : 0);
                 if (mCurrentKey >= 0 && mKeys[mCurrentKey].repeatable) {
                     mRepeatKeyIndex = mCurrentKey;
-                    Message msg = mHandler.obtainMessage(MSG_REPEAT);
-                    mHandler.sendMessageDelayed(msg, REPEAT_START_DELAY);
+                    mHandler.startKeyRepeatTimer(REPEAT_START_DELAY);
                     repeatKey();
                     // Delivering the key could have caused an abort
                     if (mAbortKey) {
@@ -1230,8 +1271,7 @@
                     }
                 }
                 if (mCurrentKey != NOT_A_KEY) {
-                    Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me);
-                    mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT);
+                    mHandler.startLongPressTimer(me, LONGPRESS_TIMEOUT);
                 }
                 showPreview(keyIndex);
                 break;
@@ -1261,11 +1301,10 @@
                 }
                 if (!continueLongPress) {
                     // Cancel old longpress
-                    mHandler.removeMessages(MSG_LONGPRESS);
+                    mHandler.cancelLongPressTimer();
                     // Start new longpress if key has changed
                     if (keyIndex != NOT_A_KEY) {
-                        Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me);
-                        mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT);
+                        mHandler.startLongPressTimer(me, LONGPRESS_TIMEOUT);
                     }
                 }
                 showPreview(mCurrentKey);
@@ -1273,7 +1312,7 @@
                 break;
 
             case MotionEvent.ACTION_UP:
-                removeMessages();
+                mHandler.cancelKeyTimersAndPopupPreview();
                 if (keyIndex == mCurrentKey) {
                     mCurrentKeyTime += eventTime - mLastMoveTime;
                 } else {
@@ -1299,7 +1338,7 @@
                 mRepeatKeyIndex = NOT_A_KEY;
                 break;
             case MotionEvent.ACTION_CANCEL:
-                removeMessages();
+                mHandler.cancelKeyTimersAndPopupPreview();
                 dismissPopupKeyboard();
                 mAbortKey = true;
                 showPreview(NOT_A_KEY);
@@ -1337,7 +1376,7 @@
         if (mPreviewPopup.isShowing()) {
             mPreviewPopup.dismiss();
         }
-        removeMessages();
+        mHandler.cancelAllMessages();
 
         dismissPopupKeyboard();
         mBuffer = null;
@@ -1345,12 +1384,6 @@
         mMiniKeyboardCache.clear();
     }
 
-    private void removeMessages() {
-        mHandler.removeMessages(MSG_REPEAT);
-        mHandler.removeMessages(MSG_LONGPRESS);
-        mHandler.removeMessages(MSG_SHOW_PREVIEW);
-    }
-
     @Override
     public void onDetachedFromWindow() {
         super.onDetachedFromWindow();
diff --git a/native/Android.mk b/native/Android.mk
index 6bad9d6..b294469 100644
--- a/native/Android.mk
+++ b/native/Android.mk
@@ -8,13 +8,8 @@
 	src/dictionary.cpp \
 	src/char_utils.cpp
 
-# NDK does not support sim build.
-ifneq ($(TARGET_SIMULATOR),true)
-  LOCAL_NDK_VERSION := 4
-  LOCAL_SDK_VERSION := 8
-else
-  LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
-endif
+LOCAL_NDK_VERSION := 4
+LOCAL_SDK_VERSION := 8
 
 LOCAL_MODULE := libjni_latinime