Merge "Use ReentrantReadWriteLock in ExpandableBinaryDictionary."
diff --git a/java/res/xml-sw600dp/keys_arabic3_left.xml b/java/res/xml-sw600dp/keys_arabic3_left.xml
new file mode 100644
index 0000000..0f2ccc0
--- /dev/null
+++ b/java/res/xml-sw600dp/keys_arabic3_left.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2013, 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+0630: "ذ" ARABIC LETTER THAL -->
+    <Key
+        latin:keyLabel="&#x0630;"
+        latin:keyLabelFlags="fontNormal" />
+    <!-- U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE -->
+    <Key
+        latin:keyLabel="&#x0626;"
+        latin:keyLabelFlags="fontNormal" />
+</merge>
diff --git a/java/res/xml-sw600dp/keys_farsi3_right.xml b/java/res/xml-sw600dp/keys_farsi3_right.xml
new file mode 100644
index 0000000..3c91ae9
--- /dev/null
+++ b/java/res/xml-sw600dp/keys_farsi3_right.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2013, 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+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE -->
+    <Key
+        latin:keyLabel="&#x0622;"
+        latin:keyLabelFlags="fontNormal" />
+    <!-- U+0686: "چ" ARABIC LETTER TCHEH -->
+    <Key
+        latin:keyLabel="&#x0686;"
+        latin:keyLabelFlags="fontNormal" />
+</merge>
diff --git a/java/res/xml-sw600dp/rowkeys_arabic1.xml b/java/res/xml-sw600dp/rowkeys_arabic1.xml
deleted file mode 100644
index 3c0acf1..0000000
--- a/java/res/xml-sw600dp/rowkeys_arabic1.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-<?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+0636: "ض" ARABIC LETTER DAD
-         U+0661: "١" ARABIC-INDIC DIGIT ONE -->
-    <Key
-        latin:keyLabel="&#x0636;"
-        latin:keyHintLabel="1"
-        latin:additionalMoreKeys="1,&#x0661;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0635: "ص" ARABIC LETTER SAD
-         U+0662: "٢" ARABIC-INDIC DIGIT TWO -->
-    <Key
-        latin:keyLabel="&#x0635;"
-        latin:keyHintLabel="2"
-        latin:additionalMoreKeys="2,&#x0662;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062B: "ث" ARABIC LETTER THEH
-         U+0663: "٣" ARABIC-INDIC DIGIT THREE -->
-    <Key
-        latin:keyLabel="&#x062B;"
-        latin:keyHintLabel="3"
-        latin:additionalMoreKeys="3,&#x0663;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0642: "ق" ARABIC LETTER QAF
-         U+06A8: "ڨ" ARABIC LETTER QAF WITH THREE DOTS ABOVE
-         U+0664: "٤" ARABIC-INDIC DIGIT FOUR -->
-    <!-- TODO: DroidSansArabic lacks the glyph of U+06A8 ARABIC LETTER QAF WITH THREE DOTS ABOVE -->
-    <Key
-        latin:keyLabel="&#x0642;"
-        latin:keyHintLabel="4"
-        latin:additionalMoreKeys="4,&#x0664;"
-        latin:moreKeys="&#x06A8;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0641: "ف" ARABIC LETTER FEH
-         U+06A4: "ڤ" ARABIC LETTER VEH
-         U+06A2: "ڢ" ARABIC LETTER FEH WITH DOT MOVED BELOW
-         U+06A5: "ڥ" ARABIC LETTER FEH WITH THREE DOTS BELOW
-         U+0665: "٥" ARABIC-INDIC DIGIT FIVE -->
-    <!-- TODO: DroidSansArabic lacks the glyph of U+06A2 ARABIC LETTER FEH WITH DOT MOVED BELOW -->
-    <!-- TODO: DroidSansArabic lacks the glyph of U+06A5 ARABIC LETTER FEH WITH THREE DOTS BELOW -->
-    <Key
-        latin:keyLabel="&#x0641;"
-        latin:keyHintLabel="5"
-        latin:additionalMoreKeys="5,&#x0665;"
-        latin:moreKeys="&#x06A4;,&#x06A2;,&#x06A5;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+063A: "غ" ARABIC LETTER GHAIN
-         U+0666: "٦" ARABIC-INDIC DIGIT SIX -->
-    <Key
-        latin:keyLabel="&#x063A;"
-        latin:keyHintLabel="6"
-        latin:additionalMoreKeys="6,&#x0666;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0639: "ع" ARABIC LETTER AIN
-         U+0667: "٧" ARABIC-INDIC DIGIT SEVEN -->
-    <Key
-        latin:keyLabel="&#x0639;"
-        latin:keyHintLabel="7"
-        latin:additionalMoreKeys="7,&#x0667;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0647: "ه" ARABIC LETTER HEH
-         U+FEEB: "ﻫ" ARABIC LETTER HEH INITIAL FORM
-         U+0647 U+200D: ARABIC LETTER HEH + ZERO WIDTH JOINER
-         U+0668: "٨" ARABIC-INDIC DIGIT EIGHT -->
-    <Key
-        latin:keyLabel="&#x0647;"
-        latin:keyHintLabel="8"
-        latin:additionalMoreKeys="8,&#x0668;"
-        latin:moreKeys="&#xFEEB;|&#x0647;&#x200D;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062E: "خ" ARABIC LETTER KHAH
-         U+0669: "٩" ARABIC-INDIC DIGIT NINE -->
-    <Key
-        latin:keyLabel="&#x062E;"
-        latin:keyHintLabel="9"
-        latin:additionalMoreKeys="9,&#x0669;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062D: "ح" ARABIC LETTER HAH
-         U+0660: "٠" ARABIC-INDIC DIGIT ZERO -->
-    <Key
-        latin:keyLabel="&#x062D;"
-        latin:keyHintLabel="0"
-        latin:additionalMoreKeys="0,&#x0660;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062C: "ج" ARABIC LETTER JEEM
-         U+0686: "چ" ARABIC LETTER TCHEH -->
-    <Key
-        latin:keyLabel="&#x062C;"
-        latin:moreKeys="&#x0686;"
-        latin:keyLabelFlags="fontNormal" />
-</merge>
diff --git a/java/res/xml-sw600dp/rowkeys_arabic2.xml b/java/res/xml-sw600dp/rowkeys_arabic2.xml
deleted file mode 100644
index 00e69ac..0000000
--- a/java/res/xml-sw600dp/rowkeys_arabic2.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?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+0634: "ش" ARABIC LETTER SHEEN
-         U+069C: "ڜ" ARABIC LETTER SEEN WITH THREE DOTS BELOW AND THREE DOTS ABOVE -->
-    <!-- TODO: DroidSansArabic lacks the glyph of U+069C ARABIC LETTER SEEN WITH THREE DOTS BELOW AND THREE DOTS ABOVE -->
-    <Key
-        latin:keyLabel="&#x0634;"
-        latin:moreKeys="&#x069C;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0633: "س" ARABIC LETTER SEEN -->
-    <Key
-        latin:keyLabel="&#x0633;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+064A: "ي" ARABIC LETTER YEH
-         U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE
-         U+0649: "ى" ARABIC LETTER ALEF MAKSURA -->
-    <Key
-        latin:keyLabel="&#x064A;"
-        latin:moreKeys="&#x0626;,&#x0649;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0628: "ب" ARABIC LETTER BEH
-         U+067E: "پ" ARABIC LETTER PEH -->
-    <Key
-        latin:keyLabel="&#x0628;"
-        latin:moreKeys="&#x067E;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0644: "ل" ARABIC LETTER LAM
-         U+FEFB: "ﻻ" ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
-         U+0627: "ا" ARABIC LETTER ALEF
-         U+FEF7: "ﻷ" ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
-         U+0623: "أ" ARABIC LETTER ALEF WITH HAMZA ABOVE
-         U+FEF9: "ﻹ" ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM
-         U+0625: "إ" ARABIC LETTER ALEF WITH HAMZA BELOW
-         U+FEF5: "ﻵ" ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
-         U+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE -->
-    <Key
-        latin:keyLabel="&#x0644;"
-        latin:moreKeys="&#xFEFB;|&#x0644;&#x0627;,&#xFEF7;|&#x0644;&#x0623;,&#xFEF9;|&#x0644;&#x0625;,&#xFEF5;|&#x0644;&#x0622;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0627: "ا" ARABIC LETTER ALEF
-         U+0621: "ء" ARABIC LETTER HAMZA
-         U+0671: "ٱ" ARABIC LETTER ALEF WASLA
-         U+0623: "أ" ARABIC LETTER ALEF WITH HAMZA ABOVE
-         U+0625: "إ" ARABIC LETTER ALEF WITH HAMZA BELOW
-         U+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE -->
-    <Key
-        latin:keyLabel="&#x0627;"
-        latin:moreKeys="&#x0621;,&#x0671;,&#x0623;,&#x0625;,&#x0622;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062A: "ت" ARABIC LETTER TEH -->
-    <Key
-        latin:keyLabel="&#x062A;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0646: "ن" ARABIC LETTER NOON -->
-    <Key
-        latin:keyLabel="&#x0646;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0645: "م" ARABIC LETTER MEEM -->
-    <Key
-        latin:keyLabel="&#x0645;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0643: "ك" ARABIC LETTER KAF
-         U+06AF: "گ" ARABIC LETTER GAF
-         U+06A9: "ک" ARABIC LETTER KEHEH -->
-    <Key
-        latin:keyLabel="&#x0643;"
-        latin:moreKeys="&#x06AF;,&#x06A9;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0637: "ط" ARABIC LETTER TAH -->
-    <Key
-        latin:keyLabel="&#x0637;"
-        latin:keyLabelFlags="fontNormal" />
-</merge>
diff --git a/java/res/xml-sw600dp/rowkeys_arabic3.xml b/java/res/xml-sw600dp/rowkeys_arabic3.xml
deleted file mode 100644
index b0bcd78..0000000
--- a/java/res/xml-sw600dp/rowkeys_arabic3.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-<?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+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE -->
-    <Key
-        latin:keyLabel="&#x0626;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0621: "ء" ARABIC LETTER HAMZA -->
-    <Key
-        latin:keyLabel="&#x0621;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0624: "ؤ" ARABIC LETTER WAW WITH HAMZA ABOVE -->
-    <Key
-        latin:keyLabel="&#x0624;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0631: "ر" ARABIC LETTER REH -->
-    <Key
-        latin:keyLabel="&#x0631;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0630: "ذ" ARABIC LETTER THAL -->
-    <Key
-        latin:keyLabel="&#x0630;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0649: "ى" ARABIC LETTER ALEF MAKSURA -->
-    <Key
-        latin:keyLabel="&#x0649;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0629: "ة" ARABIC LETTER TEH MARBUTA -->
-    <Key
-        latin:keyLabel="&#x0629;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0648: "و" ARABIC LETTER WAW -->
-    <Key
-        latin:keyLabel="&#x0648;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0632: "ز" ARABIC LETTER ZAIN
-         U+0698: "ژ" ARABIC LETTER JEH -->
-    <Key
-        latin:keyLabel="&#x0632;"
-        latin:moreKeys="&#x0698;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0638: "ظ" ARABIC LETTER ZAH -->
-    <Key
-        latin:keyLabel="&#x0638;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062F: "د" ARABIC LETTER DAL -->
-    <Key
-        latin:keyLabel="&#x062F;"
-        latin:keyLabelFlags="fontNormal" />
-</merge>
diff --git a/java/res/xml-sw600dp/rowkeys_farsi1.xml b/java/res/xml-sw600dp/rowkeys_farsi1.xml
deleted file mode 100644
index 6dd9a65..0000000
--- a/java/res/xml-sw600dp/rowkeys_farsi1.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?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+0636: "ض" ARABIC LETTER DAD
-         U+06F1: "۱" EXTENDED ARABIC-INDIC DIGIT ONE -->
-    <Key
-        latin:keyLabel="&#x0636;"
-        latin:keyHintLabel="&#x06F1;"
-        latin:additionalMoreKeys="&#x06F1;,1"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0635: "ص" ARABIC LETTER SAD
-         U+06F2: "۲" EXTENDED ARABIC-INDIC DIGIT TWO -->
-    <Key
-        latin:keyLabel="&#x0635;"
-        latin:keyHintLabel="&#x06F2;"
-        latin:additionalMoreKeys="&#x06F2;,2"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062B: "ث" ARABIC LETTER THEH
-         U+06F3: "۳" EXTENDED ARABIC-INDIC DIGIT THREE -->
-    <Key
-        latin:keyLabel="&#x062B;"
-        latin:keyHintLabel="&#x06F3;"
-        latin:additionalMoreKeys="&#x06F3;,3"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0642: "ق" ARABIC LETTER QAF
-         U+06F4: "۴" EXTENDED ARABIC-INDIC DIGIT FOUR -->
-    <Key
-        latin:keyLabel="&#x0642;"
-        latin:keyHintLabel="&#x06F4;"
-        latin:additionalMoreKeys="&#x06F4;,4"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0641: "ف" ARABIC LETTER FEH
-         U+06F5: "۵" EXTENDED ARABIC-INDIC DIGIT FIVE -->
-    <Key
-        latin:keyLabel="&#x0641;"
-        latin:keyHintLabel="&#x06F5;"
-        latin:additionalMoreKeys="&#x06F5;,5"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+063A: "غ" ARABIC LETTER GHAIN
-         U+06F6: "۶" EXTENDED ARABIC-INDIC DIGIT SIX -->
-    <Key
-        latin:keyLabel="&#x063A;"
-        latin:keyHintLabel="&#x06F6;"
-        latin:additionalMoreKeys="&#x06F6;,6"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0639: "ع" ARABIC LETTER AIN
-         U+06F7: "۷" EXTENDED ARABIC-INDIC DIGIT SEVEN -->
-    <Key
-        latin:keyLabel="&#x0639;"
-        latin:keyHintLabel="&#x06F7;"
-        latin:additionalMoreKeys="&#x06F7;,7"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0647: "ه" ARABIC LETTER HEH
-         U+FEEB: "ﻫ" ARABIC LETTER HEH INITIAL FORM
-         U+0647/U+200D: ARABIC LETTER HEH + ZERO WIDTH JOINER
-         U+0647/U+0654: ARABIC LETTER HEH + ARABIC HAMZA ABOVE
-         U+0629: "ة" ARABIC LETTER TEH MARBUTA
-         U+06F8: "۸" EXTENDED ARABIC-INDIC DIGIT EIGHT -->
-    <Key
-        latin:keyLabel="&#x0647;"
-        latin:moreKeys="&#xFEEB;|&#x0647;&#x200D;,&#x0647;&#x0654;,&#x0629;,%"
-        latin:keyHintLabel="&#x06F8;"
-        latin:additionalMoreKeys="&#x06F8;,8"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062E: "خ" ARABIC LETTER KHAH
-         U+06F9: "۹" EXTENDED ARABIC-INDIC DIGIT NINE -->
-    <Key
-        latin:keyLabel="&#x062E;"
-        latin:keyHintLabel="&#x06F9;"
-        latin:additionalMoreKeys="&#x06F9;,9"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062D: "ح" ARABIC LETTER HAH
-         U+06F0: "۰" EXTENDED ARABIC-INDIC DIGIT ZERO -->
-    <Key
-        latin:keyLabel="&#x062D;"
-        latin:keyHintLabel="&#x06F0;"
-        latin:additionalMoreKeys="&#x06F0;,0"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062C: "ج" ARABIC LETTER JEEM -->
-    <Key
-        latin:keyLabel="&#x062C;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0686: "چ" ARABIC LETTER TCHEH -->
-    <Key
-        latin:keyLabel="&#x0686;"
-        latin:keyLabelFlags="fontNormal" />
-</merge>
diff --git a/java/res/xml-sw600dp/rowkeys_farsi2.xml b/java/res/xml-sw600dp/rowkeys_farsi2.xml
deleted file mode 100644
index 3b759b6..0000000
--- a/java/res/xml-sw600dp/rowkeys_farsi2.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-<?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+0634: "ش" ARABIC LETTER SHEEN -->
-    <Key
-        latin:keyLabel="&#x0634;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0633: "س" ARABIC LETTER SEEN -->
-    <Key
-        latin:keyLabel="&#x0633;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+06CC: "ی" ARABIC LETTER FARSI YEH
-         U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE
-         U+064A: "ي" ARABIC LETTER YEH
-         U+FBE8: "ﯨ" ARABIC LETTER UIGHUR KAZAKH KIRGHIZ ALEF MAKSURA INITIAL FORM
-         U+0649: "ى" ARABIC LETTER ALEF MAKSURA -->
-    <Key
-        latin:keyLabel="&#x06CC;"
-        latin:moreKeys="&#x0626;,&#x064A;,&#xFBE8;|&#x0649;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0628: "ب" ARABIC LETTER BEH -->
-    <Key
-        latin:keyLabel="&#x0628;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0644: "ل" ARABIC LETTER LAM -->
-    <Key
-        latin:keyLabel="&#x0644;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0627: "ا" ARABIC LETTER ALEF
-         U+0621: "ء" ARABIC LETTER HAMZA
-         U+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE
-         U+0623: "أ" ARABIC LETTER ALEF WITH HAMZA ABOVE
-         U+0671: "ٱ" ARABIC LETTER ALEF WASLA
-         U+0625: "إ" ARABIC LETTER ALEF WITH HAMZA BELOW -->
-    <Key
-        latin:keyLabel="&#x0627;"
-        latin:moreKeys="&#x0621;,&#x0622;,&#x0623;,&#x0671;,&#x0625;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062A: "ت" ARABIC LETTER TEH
-         U+062B: "ﺙ" ARABIC LETTER THEH
-         U+0629: "ة": ARABIC LETTER TEH MARBUTA -->
-    <Key
-        latin:keyLabel="&#x062A;"
-        latin:moreKeys="&#x062B;,&#x0629;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0646: "ن" ARABIC LETTER NOON -->
-    <Key
-        latin:keyLabel="&#x0646;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0645: "م" ARABIC LETTER MEEM -->
-    <Key
-        latin:keyLabel="&#x0645;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+06A9: "ک" ARABIC LETTER KEHEH
-         U+0643: "ك" ARABIC LETTER KAF -->
-    <Key
-        latin:keyLabel="&#x06A9;"
-        latin:moreKeys="&#x0643;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+06AF: "گ" ARABIC LETTER GAF -->
-    <Key
-        latin:keyLabel="&#x06AF;"
-        latin:keyLabelFlags="fontNormal" />
-</merge>
diff --git a/java/res/xml-sw600dp/rowkeys_farsi3.xml b/java/res/xml-sw600dp/rowkeys_farsi3.xml
deleted file mode 100644
index 3597618..0000000
--- a/java/res/xml-sw600dp/rowkeys_farsi3.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-<?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+0638: "ظ" ARABIC LETTER ZAH -->
-    <Key
-        latin:keyLabel="&#x0638;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0637: "ط" ARABIC LETTER TAH -->
-    <Key
-        latin:keyLabel="&#x0637;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0698: "ژ" ARABIC LETTER JEH -->
-    <Key
-        latin:keyLabel="&#x0698;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0632: "ز" ARABIC LETTER ZAIN -->
-    <Key
-        latin:keyLabel="&#x0632;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0631: "ر" ARABIC LETTER REH -->
-    <Key
-        latin:keyLabel="&#x0631;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0630: "ذ" ARABIC LETTER THAL -->
-    <Key
-        latin:keyLabel="&#x0630;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062F: "د" ARABIC LETTER DAL -->
-    <Key
-        latin:keyLabel="&#x062F;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+067E: "پ" ARABIC LETTER PEH -->
-    <Key
-        latin:keyLabel="&#x067E;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0648: "و" ARABIC LETTER WAW
-         U+0624: "ؤ" ARABIC LETTER WAW WITH HAMZA ABOVE -->
-    <Key
-        latin:keyLabel="&#x0648;"
-        latin:moreKeys="&#x0624;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE -->
-    <Key
-        latin:keyLabel="&#x0622;"
-        latin:keyLabelFlags="fontNormal" />
-</merge>
diff --git a/java/res/xml-sw600dp/rows_arabic.xml b/java/res/xml-sw600dp/rows_arabic.xml
index ec7c2ad..5a28d45 100644
--- a/java/res/xml-sw600dp/rows_arabic.xml
+++ b/java/res/xml-sw600dp/rows_arabic.xml
@@ -45,8 +45,7 @@
         latin:keyWidth="8.182%p"
     >
         <include
-            latin:keyboardLayout="@xml/rowkeys_arabic3"
-            latin:keyXPos="4.091%p" />
+            latin:keyboardLayout="@xml/rowkeys_arabic3" />
     </Row>
     <include
         latin:keyboardLayout="@xml/row_qwerty4" />
diff --git a/java/res/xml-sw600dp/rows_farsi.xml b/java/res/xml-sw600dp/rows_farsi.xml
index 52c2d93..a353b67 100644
--- a/java/res/xml-sw600dp/rows_farsi.xml
+++ b/java/res/xml-sw600dp/rows_farsi.xml
@@ -28,12 +28,6 @@
     >
         <include
             latin:keyboardLayout="@xml/rowkeys_farsi1" />
-    </Row>
-    <Row
-        latin:keyWidth="8.182%p"
-    >
-        <include
-            latin:keyboardLayout="@xml/rowkeys_farsi2" />
         <Key
             latin:keyStyle="deleteKeyStyle"
             latin:keyWidth="fillRight" />
@@ -42,12 +36,18 @@
         latin:keyWidth="8.182%p"
     >
         <include
-            latin:keyboardLayout="@xml/rowkeys_farsi3"
-            latin:keyXPos="4.091%p" />
+            latin:keyboardLayout="@xml/rowkeys_farsi2" />
         <Key
             latin:keyStyle="enterKeyStyle"
             latin:keyWidth="fillRight" />
     </Row>
+    <Row
+        latin:keyWidth="8.182%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_farsi3"
+            latin:keyXPos="4.091%p" />
+    </Row>
     <include
         latin:keyboardLayout="@xml/row_qwerty4" />
 </merge>
diff --git a/java/res/xml-sw768dp/rows_arabic.xml b/java/res/xml-sw768dp/rows_arabic.xml
index 8b05d93..204f6d5 100644
--- a/java/res/xml-sw768dp/rows_arabic.xml
+++ b/java/res/xml-sw768dp/rows_arabic.xml
@@ -54,7 +54,7 @@
     >
         <include
             latin:keyboardLayout="@xml/rowkeys_arabic3"
-            latin:keyXPos="13.829%p" />
+            latin:keyXPos="6.602%p" />
     </Row>
     <include
         latin:keyboardLayout="@xml/row_qwerty4" />
diff --git a/java/res/xml-sw768dp/rows_farsi.xml b/java/res/xml-sw768dp/rows_farsi.xml
index 4b4c970..8d3fb05 100644
--- a/java/res/xml-sw768dp/rows_farsi.xml
+++ b/java/res/xml-sw768dp/rows_farsi.xml
@@ -32,6 +32,9 @@
             latin:keyWidth="7.969%p" />
         <include
             latin:keyboardLayout="@xml/rowkeys_farsi1" />
+        <Key
+            latin:keyStyle="deleteKeyStyle"
+            latin:keyWidth="fillRight" />
     </Row>
     <Row
         latin:keyWidth="7.227%p"
@@ -39,22 +42,19 @@
         <Key
             latin:keyStyle="toSymbolKeyStyle"
             latin:keyLabelFlags="alignLeft"
-            latin:keyWidth="11.172%p"/>
+            latin:keyWidth="11.172%p" />
         <include
             latin:keyboardLayout="@xml/rowkeys_farsi2" />
         <Key
-            latin:keyStyle="deleteKeyStyle"
+            latin:keyStyle="enterKeyStyle"
             latin:keyWidth="fillRight" />
     </Row>
     <Row
-        latin:keyWidth="7.186%p"
+        latin:keyWidth="7.227%p"
     >
         <include
             latin:keyboardLayout="@xml/rowkeys_farsi3"
             latin:keyXPos="13.829%p" />
-        <Key
-            latin:keyStyle="enterKeyStyle"
-            latin:keyWidth="fillRight" />
     </Row>
     <include
         latin:keyboardLayout="@xml/row_qwerty4" />
diff --git a/java/res/xml/keys_arabic3_left.xml b/java/res/xml/keys_arabic3_left.xml
new file mode 100644
index 0000000..157af4a
--- /dev/null
+++ b/java/res/xml/keys_arabic3_left.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2013, 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+0630: "ذ" ARABIC LETTER THAL -->
+    <Key
+        latin:keyLabel="&#x0630;"
+        latin:keyLabelFlags="fontNormal" />
+</merge>
diff --git a/java/res/xml/keys_farsi3_right.xml b/java/res/xml/keys_farsi3_right.xml
new file mode 100644
index 0000000..77efb0a
--- /dev/null
+++ b/java/res/xml/keys_farsi3_right.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2013, 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+0686: "چ" ARABIC LETTER TCHEH -->
+    <Key
+        latin:keyLabel="&#x0686;"
+        latin:keyLabelFlags="fontNormal" />
+</merge>
diff --git a/java/res/xml/rowkeys_arabic1.xml b/java/res/xml/rowkeys_arabic1.xml
index a4bef83..3c0acf1 100644
--- a/java/res/xml/rowkeys_arabic1.xml
+++ b/java/res/xml/rowkeys_arabic1.xml
@@ -35,74 +35,78 @@
         latin:keyHintLabel="2"
         latin:additionalMoreKeys="2,&#x0662;"
         latin:keyLabelFlags="fontNormal" />
+    <!-- U+062B: "ث" ARABIC LETTER THEH
+         U+0663: "٣" ARABIC-INDIC DIGIT THREE -->
+    <Key
+        latin:keyLabel="&#x062B;"
+        latin:keyHintLabel="3"
+        latin:additionalMoreKeys="3,&#x0663;"
+        latin:keyLabelFlags="fontNormal" />
     <!-- U+0642: "ق" ARABIC LETTER QAF
          U+06A8: "ڨ" ARABIC LETTER QAF WITH THREE DOTS ABOVE
-         U+0663: "٣" ARABIC-INDIC DIGIT THREE -->
+         U+0664: "٤" ARABIC-INDIC DIGIT FOUR -->
     <!-- TODO: DroidSansArabic lacks the glyph of U+06A8 ARABIC LETTER QAF WITH THREE DOTS ABOVE -->
     <Key
         latin:keyLabel="&#x0642;"
-        latin:keyHintLabel="3"
-        latin:additionalMoreKeys="3,&#x0663;"
+        latin:keyHintLabel="4"
+        latin:additionalMoreKeys="4,&#x0664;"
         latin:moreKeys="&#x06A8;"
         latin:keyLabelFlags="fontNormal" />
     <!-- U+0641: "ف" ARABIC LETTER FEH
          U+06A4: "ڤ" ARABIC LETTER VEH
          U+06A2: "ڢ" ARABIC LETTER FEH WITH DOT MOVED BELOW
          U+06A5: "ڥ" ARABIC LETTER FEH WITH THREE DOTS BELOW
-         U+0664: "٤" ARABIC-INDIC DIGIT FOUR -->
+         U+0665: "٥" ARABIC-INDIC DIGIT FIVE -->
     <!-- TODO: DroidSansArabic lacks the glyph of U+06A2 ARABIC LETTER FEH WITH DOT MOVED BELOW -->
     <!-- TODO: DroidSansArabic lacks the glyph of U+06A5 ARABIC LETTER FEH WITH THREE DOTS BELOW -->
     <Key
         latin:keyLabel="&#x0641;"
-        latin:keyHintLabel="4"
-        latin:additionalMoreKeys="4,&#x0664;"
+        latin:keyHintLabel="5"
+        latin:additionalMoreKeys="5,&#x0665;"
         latin:moreKeys="&#x06A4;,&#x06A2;,&#x06A5;"
         latin:keyLabelFlags="fontNormal" />
     <!-- U+063A: "غ" ARABIC LETTER GHAIN
-         U+0665: "٥" ARABIC-INDIC DIGIT FIVE -->
-    <Key
-        latin:keyLabel="&#x063A;"
-        latin:keyHintLabel="5"
-        latin:additionalMoreKeys="5,&#x0665;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0639: "ع" ARABIC LETTER AIN
          U+0666: "٦" ARABIC-INDIC DIGIT SIX -->
     <Key
-        latin:keyLabel="&#x0639;"
+        latin:keyLabel="&#x063A;"
         latin:keyHintLabel="6"
         latin:additionalMoreKeys="6,&#x0666;"
         latin:keyLabelFlags="fontNormal" />
+    <!-- U+0639: "ع" ARABIC LETTER AIN
+         U+0667: "٧" ARABIC-INDIC DIGIT SEVEN -->
+    <Key
+        latin:keyLabel="&#x0639;"
+        latin:keyHintLabel="7"
+        latin:additionalMoreKeys="7,&#x0667;"
+        latin:keyLabelFlags="fontNormal" />
     <!-- U+0647: "ه" ARABIC LETTER HEH
          U+FEEB: "ﻫ" ARABIC LETTER HEH INITIAL FORM
          U+0647 U+200D: ARABIC LETTER HEH + ZERO WIDTH JOINER
-         U+0667: "٧" ARABIC-INDIC DIGIT SEVEN -->
+         U+0668: "٨" ARABIC-INDIC DIGIT EIGHT -->
     <Key
         latin:keyLabel="&#x0647;"
-        latin:keyHintLabel="7"
-        latin:additionalMoreKeys="7,&#x0667;"
+        latin:keyHintLabel="8"
+        latin:additionalMoreKeys="8,&#x0668;"
         latin:moreKeys="&#xFEEB;|&#x0647;&#x200D;"
         latin:keyLabelFlags="fontNormal" />
     <!-- U+062E: "خ" ARABIC LETTER KHAH
-         U+0668: "٨" ARABIC-INDIC DIGIT EIGHT -->
-    <Key
-        latin:keyLabel="&#x062E;"
-        latin:keyHintLabel="8"
-        latin:additionalMoreKeys="8,&#x0668;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062D: "ح" ARABIC LETTER HAH
          U+0669: "٩" ARABIC-INDIC DIGIT NINE -->
     <Key
-        latin:keyLabel="&#x062D;"
+        latin:keyLabel="&#x062E;"
         latin:keyHintLabel="9"
         latin:additionalMoreKeys="9,&#x0669;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+062C: "ج" ARABIC LETTER JEEM
-         U+0686: "چ" ARABIC LETTER TCHEH
+    <!-- U+062D: "ح" ARABIC LETTER HAH
          U+0660: "٠" ARABIC-INDIC DIGIT ZERO -->
     <Key
-        latin:keyLabel="&#x062C;"
+        latin:keyLabel="&#x062D;"
         latin:keyHintLabel="0"
         latin:additionalMoreKeys="0,&#x0660;"
+        latin:keyLabelFlags="fontNormal" />
+    <!-- U+062C: "ج" ARABIC LETTER JEEM
+         U+0686: "چ" ARABIC LETTER TCHEH -->
+    <Key
+        latin:keyLabel="&#x062C;"
         latin:moreKeys="&#x0686;"
         latin:keyLabelFlags="fontNormal" />
 </merge>
diff --git a/java/res/xml/rowkeys_arabic2.xml b/java/res/xml/rowkeys_arabic2.xml
index d733f64..00e69ac 100644
--- a/java/res/xml/rowkeys_arabic2.xml
+++ b/java/res/xml/rowkeys_arabic2.xml
@@ -68,11 +68,9 @@
         latin:keyLabel="&#x0627;"
         latin:moreKeys="&#x0621;,&#x0671;,&#x0623;,&#x0625;,&#x0622;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+062A: "ت" ARABIC LETTER TEH
-         U+062B: "ﺙ" ARABIC LETTER THEH -->
+    <!-- U+062A: "ت" ARABIC LETTER TEH -->
     <Key
         latin:keyLabel="&#x062A;"
-        latin:moreKeys="&#x062B;"
         latin:keyLabelFlags="fontNormal" />
     <!-- U+0646: "ن" ARABIC LETTER NOON -->
     <Key
@@ -89,4 +87,8 @@
         latin:keyLabel="&#x0643;"
         latin:moreKeys="&#x06AF;,&#x06A9;"
         latin:keyLabelFlags="fontNormal" />
+    <!-- U+0637: "ط" ARABIC LETTER TAH -->
+    <Key
+        latin:keyLabel="&#x0637;"
+        latin:keyLabelFlags="fontNormal" />
 </merge>
diff --git a/java/res/xml/rowkeys_arabic3.xml b/java/res/xml/rowkeys_arabic3.xml
index e4e6948..8a17b4b 100644
--- a/java/res/xml/rowkeys_arabic3.xml
+++ b/java/res/xml/rowkeys_arabic3.xml
@@ -21,21 +21,33 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <!-- U+0638: "ظ" ARABIC LETTER ZAH -->
+    <include
+        latin:keyboardLayout="@xml/keys_arabic3_left" />
+    <!-- U+0621: "ء" ARABIC LETTER HAMZA -->
     <Key
-        latin:keyLabel="&#x0638;"
+        latin:keyLabel="&#x0621;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0637: "ط" ARABIC LETTER TAH -->
+    <!-- U+0624: "ؤ" ARABIC LETTER WAW WITH HAMZA ABOVE -->
     <Key
-        latin:keyLabel="&#x0637;"
+        latin:keyLabel="&#x0624;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0630: "ذ" ARABIC LETTER THAL -->
+    <!-- U+0631: "ر" ARABIC LETTER REH -->
     <Key
-        latin:keyLabel="&#x0630;"
+        latin:keyLabel="&#x0631;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+062F: "د" ARABIC LETTER DAL -->
+    <!-- U+0649: "ى" ARABIC LETTER ALEF MAKSURA
+         U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE -->
     <Key
-        latin:keyLabel="&#x062F;"
+        latin:keyLabel="&#x0649;"
+        latin:moreKeys="&#x0626;"
+        latin:keyLabelFlags="fontNormal" />
+    <!-- U+0629: "ة" ARABIC LETTER TEH MARBUTA -->
+    <Key
+        latin:keyLabel="&#x0629;"
+        latin:keyLabelFlags="fontNormal" />
+    <!-- U+0648: "و" ARABIC LETTER WAW -->
+    <Key
+        latin:keyLabel="&#x0648;"
         latin:keyLabelFlags="fontNormal" />
     <!-- U+0632: "ز" ARABIC LETTER ZAIN
          U+0698: "ژ" ARABIC LETTER JEH -->
@@ -43,18 +55,12 @@
         latin:keyLabel="&#x0632;"
         latin:moreKeys="&#x0698;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0631: "ر" ARABIC LETTER REH -->
+    <!-- U+0638: "ظ" ARABIC LETTER ZAH -->
     <Key
-        latin:keyLabel="&#x0631;"
+        latin:keyLabel="&#x0638;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0629: "ة" ARABIC LETTER TEH MARBUTA -->
+    <!-- U+062F: "د" ARABIC LETTER DAL -->
     <Key
-        latin:keyLabel="&#x0629;"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+0648: "و" ARABIC LETTER WAW
-         U+0624: "ﺅ" ARABIC LETTER WAW WITH HAMZA ABOVE -->
-    <Key
-        latin:keyLabel="&#x0648;"
-        latin:moreKeys="&#x0624;"
+        latin:keyLabel="&#x062F;"
         latin:keyLabelFlags="fontNormal" />
 </merge>
diff --git a/java/res/xml/rowkeys_farsi1.xml b/java/res/xml/rowkeys_farsi1.xml
index 0ccf1ab..5a22a24 100644
--- a/java/res/xml/rowkeys_farsi1.xml
+++ b/java/res/xml/rowkeys_farsi1.xml
@@ -21,81 +21,83 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <!-- U+0635: "ص" ARABIC LETTER SAD
-         U+0636: "ض" ARABIC LETTER DAD
+    <!-- U+0636: "ض" ARABIC LETTER DAD
          U+06F1: "۱" EXTENDED ARABIC-INDIC DIGIT ONE -->
     <Key
-        latin:keyLabel="&#x0635;"
-        latin:moreKeys="&#x0636;,%"
+        latin:keyLabel="&#x0636;"
         latin:keyHintLabel="&#x06F1;"
         latin:additionalMoreKeys="&#x06F1;,1"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0642: "ق" ARABIC LETTER QAF
+    <!-- U+0635: "ص" ARABIC LETTER SAD
          U+06F2: "۲" EXTENDED ARABIC-INDIC DIGIT TWO -->
     <Key
-        latin:keyLabel="&#x0642;"
+        latin:keyLabel="&#x0635;"
         latin:keyHintLabel="&#x06F2;"
         latin:additionalMoreKeys="&#x06F2;,2"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0641: "ف" ARABIC LETTER FEH
+    <!-- U+062B: "ث" ARABIC LETTER THEH
          U+06F3: "۳" EXTENDED ARABIC-INDIC DIGIT THREE -->
     <Key
-        latin:keyLabel="&#x0641;"
+        latin:keyLabel="&#x062B;"
         latin:keyHintLabel="&#x06F3;"
         latin:additionalMoreKeys="&#x06F3;,3"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+063A: "غ" ARABIC LETTER GHAIN
+    <!-- U+0642: "ق" ARABIC LETTER QAF
          U+06F4: "۴" EXTENDED ARABIC-INDIC DIGIT FOUR -->
     <Key
-        latin:keyLabel="&#x063A;"
+        latin:keyLabel="&#x0642;"
         latin:keyHintLabel="&#x06F4;"
         latin:additionalMoreKeys="&#x06F4;,4"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0639: "ع" ARABIC LETTER AIN
+    <!-- U+0641: "ف" ARABIC LETTER FEH
          U+06F5: "۵" EXTENDED ARABIC-INDIC DIGIT FIVE -->
     <Key
-        latin:keyLabel="&#x0639;"
+        latin:keyLabel="&#x0641;"
         latin:keyHintLabel="&#x06F5;"
         latin:additionalMoreKeys="&#x06F5;,5"
         latin:keyLabelFlags="fontNormal" />
+    <!-- U+063A: "غ" ARABIC LETTER GHAIN
+         U+06F6: "۶" EXTENDED ARABIC-INDIC DIGIT SIX -->
+    <Key
+        latin:keyLabel="&#x063A;"
+        latin:keyHintLabel="&#x06F6;"
+        latin:additionalMoreKeys="&#x06F6;,6"
+        latin:keyLabelFlags="fontNormal" />
+    <!-- U+0639: "ع" ARABIC LETTER AIN
+         U+06F7: "۷" EXTENDED ARABIC-INDIC DIGIT SEVEN -->
+    <Key
+        latin:keyLabel="&#x0639;"
+        latin:keyHintLabel="&#x06F7;"
+        latin:additionalMoreKeys="&#x06F7;,7"
+        latin:keyLabelFlags="fontNormal" />
     <!-- U+0647: "ه" ARABIC LETTER HEH
          U+FEEB: "ﻫ" ARABIC LETTER HEH INITIAL FORM
          U+0647/U+200D: ARABIC LETTER HEH + ZERO WIDTH JOINER
          U+0647/U+0654: ARABIC LETTER HEH + ARABIC HAMZA ABOVE
          U+0629: "ة" ARABIC LETTER TEH MARBUTA
-         U+06F6: "۶" EXTENDED ARABIC-INDIC DIGIT SIX -->
+         U+06F8: "۸" EXTENDED ARABIC-INDIC DIGIT EIGHT -->
     <Key
         latin:keyLabel="&#x0647;"
         latin:moreKeys="&#xFEEB;|&#x0647;&#x200D;,&#x0647;&#x0654;,&#x0629;,%"
-        latin:keyHintLabel="&#x06F6;"
-        latin:additionalMoreKeys="&#x06F6;,6"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062E: "خ" ARABIC LETTER KHAH
-         U+06F7: "۷" EXTENDED ARABIC-INDIC DIGIT SEVEN -->
-    <Key
-        latin:keyLabel="&#x062E;"
-        latin:keyHintLabel="&#x06F7;"
-        latin:additionalMoreKeys="&#x06F7;,7"
-        latin:keyLabelFlags="fontNormal" />
-    <!-- U+062D: "ح" ARABIC LETTER HAH
-         U+06F8: "۸" EXTENDED ARABIC-INDIC DIGIT EIGHT -->
-    <Key
-        latin:keyLabel="&#x062D;"
         latin:keyHintLabel="&#x06F8;"
         latin:additionalMoreKeys="&#x06F8;,8"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+062C: "ج" ARABIC LETTER JEEM
+    <!-- U+062E: "خ" ARABIC LETTER KHAH
          U+06F9: "۹" EXTENDED ARABIC-INDIC DIGIT NINE -->
     <Key
-        latin:keyLabel="&#x062C;"
+        latin:keyLabel="&#x062E;"
         latin:keyHintLabel="&#x06F9;"
         latin:additionalMoreKeys="&#x06F9;,9"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0686: "چ" ARABIC LETTER TCHEH
+    <!-- U+062D: "ح" ARABIC LETTER HAH
          U+06F0: "۰" EXTENDED ARABIC-INDIC DIGIT ZERO -->
     <Key
-        latin:keyLabel="&#x0686;"
+        latin:keyLabel="&#x062D;"
         latin:keyHintLabel="&#x06F0;"
         latin:additionalMoreKeys="&#x06F0;,0"
         latin:keyLabelFlags="fontNormal" />
+    <!-- U+062C: "ج" ARABIC LETTER JEEM -->
+    <Key
+        latin:keyLabel="&#x062C;"
+        latin:keyLabelFlags="fontNormal" />
 </merge>
diff --git a/java/res/xml/rowkeys_farsi2.xml b/java/res/xml/rowkeys_farsi2.xml
index 4b6abe2..fc6789e 100644
--- a/java/res/xml/rowkeys_farsi2.xml
+++ b/java/res/xml/rowkeys_farsi2.xml
@@ -25,11 +25,9 @@
     <Key
         latin:keyLabel="&#x0634;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0633: "س" ARABIC LETTER SEEN
-         U+0636: "ض" ARABIC LETTER DAD -->
+    <!-- U+0633: "س" ARABIC LETTER SEEN -->
     <Key
         latin:keyLabel="&#x0633;"
-        latin:moreKeys="&#x0636;"
         latin:keyLabelFlags="fontNormal" />
     <!-- U+06CC: "ی" ARABIC LETTER FARSI YEH
          U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE
@@ -59,11 +57,10 @@
         latin:moreKeys="&#x0621;,&#x0622;,&#x0623;,&#x0671;,&#x0625;"
         latin:keyLabelFlags="fontNormal" />
     <!-- U+062A: "ت" ARABIC LETTER TEH
-         U+062B: "ﺙ" ARABIC LETTER THEH
          U+0629: "ة": ARABIC LETTER TEH MARBUTA -->
     <Key
         latin:keyLabel="&#x062A;"
-        latin:moreKeys="&#x062B;,&#x0629;"
+        latin:moreKeys="&#x0629;"
         latin:keyLabelFlags="fontNormal" />
     <!-- U+0646: "ن" ARABIC LETTER NOON -->
     <Key
@@ -79,4 +76,8 @@
         latin:keyLabel="&#x06A9;"
         latin:moreKeys="&#x0643;"
         latin:keyLabelFlags="fontNormal" />
+    <!-- U+06AF: "گ" ARABIC LETTER GAF -->
+    <Key
+        latin:keyLabel="&#x06AF;"
+        latin:keyLabelFlags="fontNormal" />
 </merge>
diff --git a/java/res/xml/rowkeys_farsi3.xml b/java/res/xml/rowkeys_farsi3.xml
index 7d2e81f..98949f4 100644
--- a/java/res/xml/rowkeys_farsi3.xml
+++ b/java/res/xml/rowkeys_farsi3.xml
@@ -21,17 +21,21 @@
 <merge
     xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
 >
-    <!-- U+0637: "ط" ARABIC LETTER TAH
-         U+0638: "ظ" ARABIC LETTER ZAH -->
+    <!-- U+0638: "ظ" ARABIC LETTER ZAH -->
+    <Key
+        latin:keyLabel="&#x0638;"
+        latin:keyLabelFlags="fontNormal" />
+    <!-- U+0637: "ط" ARABIC LETTER TAH -->
     <Key
         latin:keyLabel="&#x0637;"
-        latin:moreKeys="&#x0638;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+0632: "ز" ARABIC LETTER ZAIN
-         U+0698: "ژ" ARABIC LETTER JEH -->
+    <!-- U+0698: "ژ" ARABIC LETTER JEH -->
+    <Key
+        latin:keyLabel="&#x0698;"
+        latin:keyLabelFlags="fontNormal" />
+    <!-- U+0632: "ز" ARABIC LETTER ZAIN -->
     <Key
         latin:keyLabel="&#x0632;"
-        latin:moreKeys="&#x0698;"
         latin:keyLabelFlags="fontNormal" />
     <!-- U+0631: "ر" ARABIC LETTER REH -->
     <Key
@@ -55,8 +59,6 @@
         latin:keyLabel="&#x0648;"
         latin:moreKeys="&#x0624;"
         latin:keyLabelFlags="fontNormal" />
-    <!-- U+06AF: "گ" ARABIC LETTER GAF -->
-    <Key
-        latin:keyLabel="&#x06AF;"
-        latin:keyLabelFlags="fontNormal" />
+    <include
+        latin:keyboardLayout="@xml/keys_farsi3_right" />
 </merge>
diff --git a/java/res/xml/rows_arabic.xml b/java/res/xml/rows_arabic.xml
index 6449af2..798c23e 100644
--- a/java/res/xml/rows_arabic.xml
+++ b/java/res/xml/rows_arabic.xml
@@ -24,27 +24,25 @@
     <include
         latin:keyboardLayout="@xml/key_styles_common" />
     <Row
-        latin:keyWidth="10%p"
+        latin:keyWidth="9.091%p"
     >
         <include
             latin:keyboardLayout="@xml/rowkeys_arabic1" />
     </Row>
     <Row
-        latin:keyWidth="10%p"
+        latin:keyWidth="9.091%p"
     >
         <include
             latin:keyboardLayout="@xml/rowkeys_arabic2" />
     </Row>
     <Row
-        latin:keyWidth="10%p"
+        latin:keyWidth="9.091%p"
     >
         <include
-            latin:keyboardLayout="@xml/rowkeys_arabic3"
-            latin:keyXPos="5.0%p" />
+            latin:keyboardLayout="@xml/rowkeys_arabic3" />
         <Key
             latin:keyStyle="deleteKeyStyle"
-            latin:keyWidth="fillRight"
-            latin:visualInsetsLeft="1%p" />
+            latin:keyWidth="fillRight" />
     </Row>
     <include
         latin:keyboardLayout="@xml/row_qwerty4" />
diff --git a/java/res/xml/rows_farsi.xml b/java/res/xml/rows_farsi.xml
index cc0c526..c74614f 100644
--- a/java/res/xml/rows_farsi.xml
+++ b/java/res/xml/rows_farsi.xml
@@ -24,27 +24,25 @@
     <include
         latin:keyboardLayout="@xml/key_styles_common" />
     <Row
-        latin:keyWidth="10%p"
+        latin:keyWidth="9.091%p"
     >
         <include
             latin:keyboardLayout="@xml/rowkeys_farsi1" />
     </Row>
     <Row
-        latin:keyWidth="10%p"
+        latin:keyWidth="9.091%p"
     >
         <include
             latin:keyboardLayout="@xml/rowkeys_farsi2" />
     </Row>
     <Row
-        latin:keyWidth="10%p"
+        latin:keyWidth="9.091%p"
     >
         <include
-            latin:keyboardLayout="@xml/rowkeys_farsi3"
-            latin:keyXPos="5.0%p" />
+            latin:keyboardLayout="@xml/rowkeys_farsi3" />
         <Key
             latin:keyStyle="deleteKeyStyle"
-            latin:keyWidth="fillRight"
-            latin:visualInsetsLeft="1%p" />
+            latin:keyWidth="fillRight" />
     </Row>
     <include
         latin:keyboardLayout="@xml/row_qwerty4" />
diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp
index 173a612..3deeb3c 100644
--- a/native/jni/src/suggest/core/suggest.cpp
+++ b/native/jni/src/suggest/core/suggest.cpp
@@ -227,9 +227,14 @@
             ++outputWordIndex;
         }
 
-        const bool sameAsTyped = TRAVERSAL->sameAsTyped(traverseSession, terminalDicNode);
-        outputWordIndex = ShortcutUtils::outputShortcuts(&terminalAttributes, outputWordIndex,
-                finalScore, outputCodePoints, frequencies, outputTypes, sameAsTyped);
+        if (!terminalDicNode->hasMultipleWords()) {
+            // Shortcut is not supported for multiple words suggestions.
+            // TODO: Check shortcuts during traversal for multiple words suggestions.
+            const bool sameAsTyped = TRAVERSAL->sameAsTyped(traverseSession, terminalDicNode);
+            outputWordIndex = ShortcutUtils::outputShortcuts(&terminalAttributes, outputWordIndex,
+                    finalScore, outputCodePoints, frequencies, outputTypes, sameAsTyped);
+
+        }
         DicNode::managedDelete(terminalDicNode);
     }
 
diff --git a/tools/maketext/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl b/tools/maketext/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl
index 2fc97b5..479a766 100644
--- a/tools/maketext/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl
+++ b/tools/maketext/res/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.tmpl
@@ -20,7 +20,7 @@
 import android.content.res.Resources;
 
 import com.android.inputmethod.annotations.UsedForTesting;
-import com.android.inputmethod.latin.CollectionUtils;
+import com.android.inputmethod.latin.utils.CollectionUtils;
 
 import java.util.HashMap;