Merge "Reorganize punctuations and diacritics of Arabic and Persian" into jb-dev
diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml
index 73aa54f..d6a68d0 100644
--- a/java/res/values/donottranslate.xml
+++ b/java/res/values/donottranslate.xml
@@ -178,6 +178,9 @@
     <string name="subtype_generic_colemak">%s (Colemak)</string>
     <string name="subtype_generic_pcqwerty">%s (PC)</string>
 
+    <!-- Description for Bulgarian (BDS) subtype. -->
+    <string name="subtype_bulgarian_bds">%s (BDS)</string>
+
     <!-- dictionary pack package name /settings activity (for shared prefs and settings) -->
     <string name="dictionary_pack_package_name">com.google.android.inputmethod.latin.dictionarypack</string>
     <string name="dictionary_pack_settings_activity">com.google.android.inputmethod.latin.dictionarypack.DictionarySettingsActivity</string>
diff --git a/java/res/xml-sw600dp/rows_bulgarian_bds.xml b/java/res/xml-sw600dp/rows_bulgarian_bds.xml
new file mode 100644
index 0000000..8632964
--- /dev/null
+++ b/java/res/xml-sw600dp/rows_bulgarian_bds.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <include
+        latin:keyboardLayout="@xml/key_styles_common" />
+    <Row
+        latin:keyWidth="7.727%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_bulgarian_bds1"
+            latin:keyLabelFlags="disableAdditionalMoreKeys|disableKeyHintLabel" />
+        <Key
+            latin:keyStyle="deleteKeyStyle"
+            latin:keyWidth="fillBoth" />
+    </Row>
+    <Row
+        latin:keyWidth="7.727%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_bulgarian_bds2" />
+        <Key
+            latin:keyStyle="enterKeyStyle"
+            latin:keyWidth="fillBoth" />
+    </Row>
+    <Row
+        latin:keyWidth="7.65%p"
+    >
+        <Key
+            latin:keyStyle="shiftKeyStyle"
+            latin:keyWidth="11.75%p" />
+        <include
+            latin:keyboardLayout="@xml/rowkeys_bulgarian_bds3" />
+        <include
+            latin:keyboardLayout="@xml/keys_comma_period" />
+    </Row>
+    <include
+        latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>
diff --git a/java/res/xml-sw768dp/rows_bulgarian_bds.xml b/java/res/xml-sw768dp/rows_bulgarian_bds.xml
new file mode 100644
index 0000000..31343d2
--- /dev/null
+++ b/java/res/xml-sw768dp/rows_bulgarian_bds.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <include
+        latin:keyboardLayout="@xml/key_styles_common" />
+    <Row
+        latin:keyWidth="7.000%p"
+    >
+        <Key
+            latin:keyStyle="tabKeyStyle"
+            latin:keyLabelFlags="alignLeft"
+            latin:keyWidth="7.969%p" />
+        <include
+            latin:keyboardLayout="@xml/rowkeys_bulgarian_bds1"
+            latin:keyLabelFlags="disableAdditionalMoreKeys|disableKeyHintLabel" />
+        <Key
+            latin:keyStyle="deleteKeyStyle"
+            latin:keyWidth="fillBoth" />
+    </Row>
+    <Row
+        latin:keyWidth="7.000%p"
+    >
+        <Key
+            latin:keyStyle="toSymbolKeyStyle"
+            latin:keyLabelFlags="alignLeft"
+            latin:keyWidth="11.172%p" />
+        <include
+            latin:keyboardLayout="@xml/rowkeys_bulgarian_bds2" />
+        <Key
+            latin:keyStyle="enterKeyStyle"
+            latin:keyWidth="fillBoth" />
+    </Row>
+    <Row
+        latin:keyWidth="7.000%p"
+    >
+        <Key
+            latin:keyStyle="shiftKeyStyle"
+            latin:keyWidth="13.829%p" />
+        <include
+            latin:keyboardLayout="@xml/rowkeys_bulgarian_bds3" />
+        <include
+            latin:keyboardLayout="@xml/keys_comma_period" />
+        <Key
+            latin:keyStyle="shiftKeyStyle"
+            latin:keyWidth="fillBoth" />
+    </Row>
+    <include
+        latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>
diff --git a/java/res/xml/kbd_bulgarian_bds.xml b/java/res/xml/kbd_bulgarian_bds.xml
new file mode 100644
index 0000000..a8d770c
--- /dev/null
+++ b/java/res/xml/kbd_bulgarian_bds.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License"):
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<Keyboard
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <include
+        latin:keyboardLayout="@xml/rows_bulgarian_bds" />
+</Keyboard>
diff --git a/java/res/xml/keyboard_layout_set_bulgarian_bds.xml b/java/res/xml/keyboard_layout_set_bulgarian_bds.xml
new file mode 100644
index 0000000..a36b3bd
--- /dev/null
+++ b/java/res/xml/keyboard_layout_set_bulgarian_bds.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, 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.
+*/
+-->
+
+<KeyboardLayoutSet
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin">
+    <Element
+        latin:elementName="alphabet"
+        latin:elementKeyboard="@xml/kbd_bulgarian_bds"
+        latin:enableProximityCharsCorrection="true" />
+    <Element
+        latin:elementName="symbols"
+        latin:elementKeyboard="@xml/kbd_symbols" />
+    <Element
+        latin:elementName="symbolsShifted"
+        latin:elementKeyboard="@xml/kbd_symbols_shift" />
+    <Element
+        latin:elementName="phone"
+        latin:elementKeyboard="@xml/kbd_phone" />
+    <Element
+        latin:elementName="phoneSymbols"
+        latin:elementKeyboard="@xml/kbd_phone_symbols" />
+    <Element
+        latin:elementName="number"
+        latin:elementKeyboard="@xml/kbd_number" />
+</KeyboardLayoutSet>
diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml
index 981f246..19b32f2 100644
--- a/java/res/xml/method.xml
+++ b/java/res/xml/method.xml
@@ -25,6 +25,7 @@
     ar: Arabic/arabic
     be: Belarusian/east_slavic
     bg: Bulgarian/bulgarian
+    bg: Bulgarian/bulgarian_bds
     cs: Czech/qwertz
     da: Danish/nordic
     de: German/qwertz
@@ -101,6 +102,12 @@
             android:imeSubtypeExtraValue="KeyboardLayoutSet=bulgarian"
     />
     <subtype android:icon="@drawable/ic_subtype_keyboard"
+            android:label="@string/subtype_bulgarian_bds"
+            android:imeSubtypeLocale="bg"
+            android:imeSubtypeMode="keyboard"
+            android:imeSubtypeExtraValue="KeyboardLayoutSet=bulgarian_bds"
+    />
+    <subtype android:icon="@drawable/ic_subtype_keyboard"
             android:label="@string/subtype_generic"
             android:imeSubtypeLocale="cs"
             android:imeSubtypeMode="keyboard"
diff --git a/java/res/xml/rowkeys_bulgarian1.xml b/java/res/xml/rowkeys_bulgarian1.xml
index adeecaf..441b079 100644
--- a/java/res/xml/rowkeys_bulgarian1.xml
+++ b/java/res/xml/rowkeys_bulgarian1.xml
@@ -21,14 +21,14 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <!-- U+0447: "ч" CYRILLIC SMALL LETTER CHE -->
+    <!-- U+044F: "я" CYRILLIC SMALL LETTER YA -->
     <Key
-        latin:keyLabel="&#x0447;"
+        latin:keyLabel="&#x044F;"
         latin:keyHintLabel="1"
         latin:additionalMoreKeys="1" />
-    <!-- U+0448: "ш" CYRILLIC SMALL LETTER SHA -->
+    <!-- U+0432: "в" CYRILLIC SMALL LETTER VE -->
     <Key
-        latin:keyLabel="&#x0448;"
+        latin:keyLabel="&#x0432;"
         latin:keyHintLabel="2"
         latin:additionalMoreKeys="2" />
     <!-- U+0435: "е" CYRILLIC SMALL LETTER IE -->
@@ -73,7 +73,7 @@
         latin:keyLabel="&#x043F;"
         latin:keyHintLabel="0"
         latin:additionalMoreKeys="0" />
-    <!-- U+044F: "я" CYRILLIC SMALL LETTER YA -->
+    <!-- U+0447: "ч" CYRILLIC SMALL LETTER CHE -->
     <Key
-        latin:keyLabel="&#x044F;" />
+        latin:keyLabel="&#x0447;" />
 </merge>
diff --git a/java/res/xml/rowkeys_bulgarian2.xml b/java/res/xml/rowkeys_bulgarian2.xml
index 599edd3..a4e93d8 100644
--- a/java/res/xml/rowkeys_bulgarian2.xml
+++ b/java/res/xml/rowkeys_bulgarian2.xml
@@ -48,10 +48,10 @@
     <!-- U+043B: "л" CYRILLIC SMALL LETTER EL -->
     <Key
         latin:keyLabel="&#x043B;" />
+    <!-- U+0448: "ш" CYRILLIC SMALL LETTER SHA -->
+    <Key
+        latin:keyLabel="&#x0448;" />
     <!-- U+0449: "щ" CYRILLIC SMALL LETTER SHCHA -->
     <Key
         latin:keyLabel="&#x0449;" />
-    <!-- U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN -->
-    <Key
-        latin:keyLabel="&#x044C;" />
 </merge>
diff --git a/java/res/xml/rowkeys_bulgarian3.xml b/java/res/xml/rowkeys_bulgarian3.xml
index 19872cd..258219c 100644
--- a/java/res/xml/rowkeys_bulgarian3.xml
+++ b/java/res/xml/rowkeys_bulgarian3.xml
@@ -24,15 +24,15 @@
     <!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
     <Key
         latin:keyLabel="&#x0437;" />
-    <!-- U+0436: "ж" CYRILLIC SMALL LETTER ZHE -->
+    <!-- U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN -->
     <Key
-        latin:keyLabel="&#x0436;" />
+        latin:keyLabel="&#x044C;" />
     <!-- U+0446: "ц" CYRILLIC SMALL LETTER TSE -->
     <Key
         latin:keyLabel="&#x0446;" />
-    <!-- U+0432: "в" CYRILLIC SMALL LETTER VE -->
+    <!-- U+0436: "ж" CYRILLIC SMALL LETTER ZHE -->
     <Key
-        latin:keyLabel="&#x0432;" />
+        latin:keyLabel="&#x0436;" />
     <!-- U+0431: "б" CYRILLIC SMALL LETTER BE -->
     <Key
         latin:keyLabel="&#x0431;" />
diff --git a/java/res/xml/rowkeys_bulgarian_bds1.xml b/java/res/xml/rowkeys_bulgarian_bds1.xml
new file mode 100644
index 0000000..eed1fcb
--- /dev/null
+++ b/java/res/xml/rowkeys_bulgarian_bds1.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <!-- U+0443: "у" CYRILLIC SMALL LETTER U -->
+    <Key
+        latin:keyLabel="&#x0443;"
+        latin:keyHintLabel="1"
+        latin:additionalMoreKeys="1" />
+    <!-- U+0435: "е" CYRILLIC SMALL LETTER IE -->
+    <Key
+        latin:keyLabel="&#x0435;"
+        latin:keyHintLabel="2"
+        latin:additionalMoreKeys="2" />
+    <!-- U+0438: "и" CYRILLIC SMALL LETTER I
+         U+045D: "ѝ" CYRILLIC SMALL LETTER I WITH GRAVE -->
+    <Key
+        latin:keyLabel="&#x0438;"
+        latin:keyHintLabel="3"
+        latin:additionalMoreKeys="3"
+        latin:moreKeys="&#x045D;" />
+    <!-- U+0448: "ш" CYRILLIC SMALL LETTER SHA -->
+    <Key
+        latin:keyLabel="&#x0448;"
+        latin:keyHintLabel="4"
+        latin:additionalMoreKeys="4" />
+    <!-- U+0449: "щ" CYRILLIC SMALL LETTER SHCHA -->
+    <Key
+        latin:keyLabel="&#x0449;"
+        latin:keyHintLabel="5"
+        latin:additionalMoreKeys="5" />
+    <!-- U+043A: "к" CYRILLIC SMALL LETTER KA -->
+    <Key
+        latin:keyLabel="&#x043A;"
+        latin:keyHintLabel="6"
+        latin:additionalMoreKeys="6" />
+    <!-- U+0441: "с" CYRILLIC SMALL LETTER ES -->
+    <Key
+        latin:keyLabel="&#x0441;"
+        latin:keyHintLabel="7"
+        latin:additionalMoreKeys="7" />
+    <!-- U+0434: "д" CYRILLIC SMALL LETTER DE -->
+    <Key
+        latin:keyLabel="&#x0434;"
+        latin:keyHintLabel="8"
+        latin:additionalMoreKeys="8" />
+    <!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
+    <Key
+        latin:keyLabel="&#x0437;"
+        latin:keyHintLabel="9"
+        latin:additionalMoreKeys="9" />
+    <!-- U+0446: "ц" CYRILLIC SMALL LETTER TSE -->
+    <Key
+        latin:keyLabel="&#x0446;"
+        latin:keyHintLabel="0"
+        latin:additionalMoreKeys="0" />
+    <!-- U+0431: "б" CYRILLIC SMALL LETTER BE -->
+    <Key
+        latin:keyLabel="&#x0431;" />
+</merge>
diff --git a/java/res/xml/rowkeys_bulgarian_bds2.xml b/java/res/xml/rowkeys_bulgarian_bds2.xml
new file mode 100644
index 0000000..ff1bff8
--- /dev/null
+++ b/java/res/xml/rowkeys_bulgarian_bds2.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <!-- U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN -->
+    <Key
+        latin:keyLabel="&#x044C;" />
+    <!-- U+044F: "я" CYRILLIC SMALL LETTER YA -->
+    <Key
+        latin:keyLabel="&#x044F;" />
+    <!-- U+0430: "а" CYRILLIC SMALL LETTER A -->
+    <Key
+        latin:keyLabel="&#x0430;" />
+    <!-- U+043E: "о" CYRILLIC SMALL LETTER O -->
+    <Key
+        latin:keyLabel="&#x043E;" />
+    <!-- U+0436: "ж" CYRILLIC SMALL LETTER ZHE -->
+    <Key
+        latin:keyLabel="&#x0436;" />
+    <!-- U+0433: "г" CYRILLIC SMALL LETTER GHE -->
+    <Key
+        latin:keyLabel="&#x0433;" />
+    <!-- U+0442: "т" CYRILLIC SMALL LETTER TE -->
+    <Key
+        latin:keyLabel="&#x0442;" />
+    <!-- U+043D: "н" CYRILLIC SMALL LETTER EN -->
+    <Key
+        latin:keyLabel="&#x043D;" />
+    <!-- U+0432: "в" CYRILLIC SMALL LETTER VE -->
+    <Key
+        latin:keyLabel="&#x0432;" />
+    <!-- U+043C: "м" CYRILLIC SMALL LETTER EM -->
+    <Key
+        latin:keyLabel="&#x043C;" />
+    <!-- U+0447: "ч" CYRILLIC SMALL LETTER CHE -->
+    <Key
+        latin:keyLabel="&#x0447;" />
+</merge>
diff --git a/java/res/xml/rowkeys_bulgarian_bds3.xml b/java/res/xml/rowkeys_bulgarian_bds3.xml
new file mode 100644
index 0000000..7bb780a
--- /dev/null
+++ b/java/res/xml/rowkeys_bulgarian_bds3.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <!-- U+044E: "ю" CYRILLIC SMALL LETTER YU -->
+    <Key
+        latin:keyLabel="&#x044E;" />
+    <!-- U+0439: "й" CYRILLIC SMALL LETTER SHORT I -->
+    <Key
+        latin:keyLabel="&#x0439;" />
+    <!-- U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN -->
+    <Key
+        latin:keyLabel="&#x044A;" />
+    <!-- U+044D: "э" CYRILLIC SMALL LETTER E -->
+    <Key
+        latin:keyLabel="&#x044D;" />
+    <!-- U+0444: "ф" CYRILLIC SMALL LETTER EF -->
+    <Key
+        latin:keyLabel="&#x0444;" />
+    <!-- U+0445: "х" CYRILLIC SMALL LETTER HA -->
+    <Key
+        latin:keyLabel="&#x0445;" />
+    <!-- U+043F: "п" CYRILLIC SMALL LETTER PE -->
+    <Key
+        latin:keyLabel="&#x043F;" />
+    <!-- U+0440: "р" CYRILLIC SMALL LETTER ER -->
+    <Key
+        latin:keyLabel="&#x0440;" />
+    <!-- U+043B: "л" CYRILLIC SMALL LETTER EL -->
+    <Key
+        latin:keyLabel="&#x043B;" />
+</merge>
diff --git a/java/res/xml/rows_bulgarian_bds.xml b/java/res/xml/rows_bulgarian_bds.xml
new file mode 100644
index 0000000..9a2f0bc
--- /dev/null
+++ b/java/res/xml/rows_bulgarian_bds.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+**     http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+    xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+    <include
+        latin:keyboardLayout="@xml/key_styles_common" />
+    <Row
+        latin:keyWidth="9.091%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_bulgarian_bds1" />
+    </Row>
+    <Row
+            latin:keyWidth="9.091%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_bulgarian_bds2" />
+    </Row>
+    <Row
+        latin:keyWidth="9.091%p"
+    >
+        <Key
+            latin:keyStyle="shiftKeyStyle"
+            latin:keyWidth="10.8%p" />
+        <include
+            latin:keyboardLayout="@xml/rowkeys_bulgarian_bds3" />
+        <Key
+            latin:keyStyle="deleteKeyStyle"
+            latin:keyWidth="fillRight" />
+    </Row>
+    <include
+        latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index 6b59a8d..90394ce 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -21,7 +21,6 @@
 
 import com.android.inputmethod.keyboard.Keyboard.Params.TouchPositionCorrection;
 import com.android.inputmethod.latin.JniUtils;
-import com.android.inputmethod.latin.spellcheck.SpellCheckerProximityInfo;
 
 import java.util.Arrays;
 import java.util.HashMap;
@@ -75,15 +74,12 @@
         return new ProximityInfo("", 1, 1, 1, 1, 1, 1, EMPTY_KEY_ARRAY, null);
     }
 
-    public static ProximityInfo createSpellCheckerProximityInfo(final int[] proximity) {
+    public static ProximityInfo createSpellCheckerProximityInfo(final int[] proximity,
+            int rowSize, int gridWidth, int gridHeight) {
         final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo();
         spellCheckerProximityInfo.mNativeProximityInfo =
                 spellCheckerProximityInfo.setProximityInfoNative("",
-                        SpellCheckerProximityInfo.ROW_SIZE,
-                        SpellCheckerProximityInfo.PROXIMITY_GRID_WIDTH,
-                        SpellCheckerProximityInfo.PROXIMITY_GRID_HEIGHT,
-                        SpellCheckerProximityInfo.PROXIMITY_GRID_WIDTH,
-                        SpellCheckerProximityInfo.PROXIMITY_GRID_HEIGHT,
+                        rowSize, gridWidth, gridHeight, gridWidth, gridHeight,
                         1, proximity, 0, null, null, null, null, null, null, null, null);
         return spellCheckerProximityInfo;
     }
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 213c0ac..011b512 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -635,6 +635,12 @@
             Log.d(TAG, "onStartInputView: editorInfo:"
                     + String.format("inputType=0x%08x imeOptions=0x%08x",
                             editorInfo.inputType, editorInfo.imeOptions));
+            Log.d(TAG, "All caps = "
+                    + ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0)
+                    + ", sentence caps = "
+                    + ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0)
+                    + ", word caps = "
+                    + ((editorInfo.inputType & InputType.TYPE_TEXT_FLAG_CAP_WORDS) != 0));
         }
         if (ProductionFlag.IS_EXPERIMENTAL) {
             ResearchLogger.latinIME_onStartInputViewInternal(editorInfo, mPrefs);
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index f416452..6f7f0c3 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -23,6 +23,7 @@
 import android.text.TextUtils;
 import android.util.Log;
 import android.util.LruCache;
+import android.view.textservice.SentenceSuggestionsInfo;
 import android.view.textservice.SuggestionsInfo;
 import android.view.textservice.TextInfo;
 
@@ -392,7 +393,10 @@
     public DictAndProximity createDictAndProximity(final Locale locale) {
         final int script = getScriptFromLocale(locale);
         final ProximityInfo proximityInfo = ProximityInfo.createSpellCheckerProximityInfo(
-                SpellCheckerProximityInfo.getProximityForScript(script));
+                SpellCheckerProximityInfo.getProximityForScript(script),
+                SpellCheckerProximityInfo.ROW_SIZE,
+                SpellCheckerProximityInfo.PROXIMITY_GRID_WIDTH,
+                SpellCheckerProximityInfo.PROXIMITY_GRID_HEIGHT);
         final DictionaryCollection dictionaryCollection =
                 DictionaryFactory.createDictionaryFromManager(this, locale,
                         true /* useFullEditDistance */);
@@ -484,6 +488,10 @@
                 }
                 mUnigramSuggestionsInfoCache.put(query, new SuggestionsParams(suggestions, flags));
             }
+
+            public void remove(String key) {
+                mUnigramSuggestionsInfoCache.remove(key);
+            }
         }
 
         AndroidSpellCheckerSession(final AndroidSpellCheckerService service) {
@@ -566,6 +574,96 @@
             return (letterCount * 4 < length * 3);
         }
 
+        private SentenceSuggestionsInfo fixWronglyInvalidatedWordWithSingleQuote(
+                TextInfo ti, SentenceSuggestionsInfo ssi) {
+            final String typedText = ti.getText();
+            if (!typedText.contains(SINGLE_QUOTE)) {
+                return null;
+            }
+            final int N = ssi.getSuggestionsCount();
+            final ArrayList<Integer> additionalOffsets = new ArrayList<Integer>();
+            final ArrayList<Integer> additionalLengths = new ArrayList<Integer>();
+            final ArrayList<SuggestionsInfo> additionalSuggestionsInfos =
+                    new ArrayList<SuggestionsInfo>();
+            for (int i = 0; i < N; ++i) {
+                final SuggestionsInfo si = ssi.getSuggestionsInfoAt(i);
+                final int flags = si.getSuggestionsAttributes();
+                if ((flags & SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY) == 0) {
+                    continue;
+                }
+                final int offset = ssi.getOffsetAt(i);
+                final int length = ssi.getLengthAt(i);
+                final String subText = typedText.substring(offset, offset + length);
+                if (!subText.contains(SINGLE_QUOTE)) {
+                    continue;
+                }
+                final String[] splitTexts = subText.split(SINGLE_QUOTE, -1);
+                if (splitTexts == null || splitTexts.length <= 1) {
+                    continue;
+                }
+                final int splitNum = splitTexts.length;
+                for (int j = 0; j < splitNum; ++j) {
+                    final String splitText = splitTexts[j];
+                    if (TextUtils.isEmpty(splitText)) {
+                        continue;
+                    }
+                    if (mSuggestionsCache.getSuggestionsFromCache(splitText) == null) {
+                        continue;
+                    }
+                    final int newLength = splitText.length();
+                    // Neither RESULT_ATTR_IN_THE_DICTIONARY nor RESULT_ATTR_LOOKS_LIKE_TYPO
+                    final int newFlags = 0;
+                    final SuggestionsInfo newSi = new SuggestionsInfo(newFlags, EMPTY_STRING_ARRAY);
+                    newSi.setCookieAndSequence(si.getCookie(), si.getSequence());
+                    if (DBG) {
+                        Log.d(TAG, "Override and remove old span over: "
+                                + splitText + ", " + offset + "," + newLength);
+                    }
+                    additionalOffsets.add(offset);
+                    additionalLengths.add(newLength);
+                    additionalSuggestionsInfos.add(newSi);
+                }
+            }
+            final int additionalSize = additionalOffsets.size();
+            if (additionalSize <= 0) {
+                return null;
+            }
+            final int suggestionsSize = N + additionalSize;
+            final int[] newOffsets = new int[suggestionsSize];
+            final int[] newLengths = new int[suggestionsSize];
+            final SuggestionsInfo[] newSuggestionsInfos = new SuggestionsInfo[suggestionsSize];
+            int i;
+            for (i = 0; i < N; ++i) {
+                newOffsets[i] = ssi.getOffsetAt(i);
+                newLengths[i] = ssi.getLengthAt(i);
+                newSuggestionsInfos[i] = ssi.getSuggestionsInfoAt(i);
+            }
+            for (; i < suggestionsSize; ++i) {
+                newOffsets[i] = additionalOffsets.get(i - N);
+                newLengths[i] = additionalLengths.get(i - N);
+                newSuggestionsInfos[i] = additionalSuggestionsInfos.get(i - N);
+            }
+            return new SentenceSuggestionsInfo(newSuggestionsInfos, newOffsets, newLengths);
+        }
+
+        @Override
+        public SentenceSuggestionsInfo[] onGetSentenceSuggestionsMultiple(
+                TextInfo[] textInfos, int suggestionsLimit) {
+            final SentenceSuggestionsInfo[] retval = super.onGetSentenceSuggestionsMultiple(
+                    textInfos, suggestionsLimit);
+            if (retval == null || retval.length != textInfos.length) {
+                return retval;
+            }
+            for (int i = 0; i < retval.length; ++i) {
+                final SentenceSuggestionsInfo tempSsi =
+                        fixWronglyInvalidatedWordWithSingleQuote(textInfos[i], retval[i]);
+                if (tempSsi != null) {
+                    retval[i] = tempSsi;
+                }
+            }
+            return retval;
+        }
+
         // Note : this must be reentrant
         /**
          * Gets a list of suggestions for a specific string. This returns a list of possible