Fix Farsi keyboard

Bug: 5456620
Change-Id: Ia54f084fbc7a238aeda1df234c723d9e675ce62f
diff --git a/java/res/xml/kbd_farsi.xml b/java/res/xml/kbd_farsi.xml
new file mode 100644
index 0000000..1af4e61
--- /dev/null
+++ b/java/res/xml/kbd_farsi.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_farsi" />
+</Keyboard>
diff --git a/java/res/xml/key_styles_currency.xml b/java/res/xml/key_styles_currency.xml
index 3e4afdf..9dec7af 100644
--- a/java/res/xml/key_styles_currency.xml
+++ b/java/res/xml/key_styles_currency.xml
@@ -97,6 +97,32 @@
                 latin:styleName="moreCurrency4KeyStyle"
                 latin:keyLabel="¢" />
         </case>
+        <case
+            latin:languageCode="fa"
+        >
+            <!-- U+FDFC: "﷼" RIAL SIGN
+                 U+00A3: "£" POUND SIGN
+                 U+20AC: "€" EURO SIGN
+                 U+00A2: "¢" CENT SIGN -->
+            <!-- TODO: DroidSansArabic lacks the glyph of U+FCDC: RIAL SIGN -->
+            <key-style
+                latin:styleName="currencyKeyStyle"
+                latin:keyLabel="&#xFDFC;"
+                latin:moreKeys="@string/more_keys_for_currency_general" />
+            <key-style
+                latin:styleName="moreCurrency1KeyStyle"
+                latin:keyLabel="£" />
+            <key-style
+                latin:styleName="moreCurrency2KeyStyle"
+                latin:keyLabel="€" />
+            <key-style
+                latin:styleName="moreCurrency3KeyStyle"
+                latin:keyLabel="$"
+                latin:moreKeys="¢" />
+            <key-style
+                latin:styleName="moreCurrency4KeyStyle"
+                latin:keyLabel="¢" />
+        </case>
         <!-- United Kingdom -->
         <case
             latin:countryCode="GB"
diff --git a/java/res/xml/keys_comma_period.xml b/java/res/xml/keys_comma_period.xml
deleted file mode 100644
index 6db02b6..0000000
--- a/java/res/xml/keys_comma_period.xml
+++ /dev/null
@@ -1,46 +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"
->
-    <switch>
-        <case
-            latin:mode="email"
-        >
-            <Key
-                latin:keyLabel="," />
-            <Key
-                latin:keyLabel="." />
-        </case>
-        <default>
-            <Key
-                latin:keyLabel=","
-                latin:keyHintLabel="!"
-                latin:moreKeys="!"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-            <Key
-                latin:keyLabel="."
-                latin:keyHintLabel="\?"
-                latin:moreKeys="\?"
-                latin:keyStyle="hasShiftedLetterHintStyle" />
-        </default>
-    </switch>
-</merge>
diff --git a/java/res/xml/rowkeys_farsi1.xml b/java/res/xml/rowkeys_farsi1.xml
new file mode 100644
index 0000000..15cb801
--- /dev/null
+++ b/java/res/xml/rowkeys_farsi1.xml
@@ -0,0 +1,90 @@
+<?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+0635: "ص" ARABIC LETTER SAD
+         U+06F1: "۱" EXTENDED ARABIC-INDIC DIGIT ONE -->
+    <Key
+        latin:keyLabel="&#x0635;"
+        latin:keyHintLabel="1"
+        latin:additionalMoreKeys="1,&#x06F1;" />
+    <!-- U+0642: "ق" ARABIC LETTER QAF
+         U+06F2: "۲" EXTENDED ARABIC-INDIC DIGIT TWO -->
+    <Key
+        latin:keyLabel="&#x0642;"
+        latin:keyHintLabel="2"
+        latin:additionalMoreKeys="2,&#x06F2;" />
+    <!-- U+0641: "ف" ARABIC LETTER FEH
+         U+06F3: "۳" EXTENDED ARABIC-INDIC DIGIT THREE -->
+    <Key
+        latin:keyLabel="&#x0641;"
+        latin:keyHintLabel="3"
+        latin:additionalMoreKeys="3,&#x06F3;" />
+    <!-- U+063A: "غ" ARABIC LETTER GHAIN
+         U+06F4: "۴" EXTENDED ARABIC-INDIC DIGIT FOUR -->
+    <Key
+        latin:keyLabel="&#x063A;"
+        latin:keyHintLabel="4"
+        latin:additionalMoreKeys="4,&#x06F4;" />
+    <!-- U+0639: "ع" ARABIC LETTER AIN
+         U+06F5: "۵" EXTENDED ARABIC-INDIC DIGIT FIVE -->
+    <Key
+        latin:keyLabel="&#x0639;"
+        latin:keyHintLabel="5"
+        latin:additionalMoreKeys="5,&#x06F5;" />
+    <!-- U+0647: "ه" ARABIC LETTER HEH
+         U+FEEB: "ﻫ" ARABIC LETTER HEH INITIAL FORM
+         U+0647/U+200D: ARABIC LETTER HEH + ZERO WIDTH JOINER
+         U+06C0: "ۀ" ARABIC LETTER HEH WITH YEH ABOVE
+         U+0629: "ة" ARABIC LETTER TEH MARBUTA
+         U+06F6: "۶" EXTENDED ARABIC-INDIC DIGIT SIX -->
+    <!-- TODO: DroidSansArabic lacks the glyph of U+06C0 ARABIC LETTER HEH WITH YEH ABOVE -->
+    <Key
+        latin:keyLabel="&#x0647;"
+        latin:moreKeys="&#xFEEB;|&#x0647;&#x200D;,&#x06C0;,&#x0629;,%"
+        latin:keyHintLabel="6"
+        latin:additionalMoreKeys="6,&#x06F6;" />
+    <!-- U+062E: "خ" ARABIC LETTER KHAH
+         U+06F7: "۷" EXTENDED ARABIC-INDIC DIGIT SEVEN -->
+    <Key
+        latin:keyLabel="&#x062E;"
+        latin:keyHintLabel="7"
+        latin:additionalMoreKeys="7,&#x06F7;" />
+    <!-- U+062D: "ح" ARABIC LETTER HAH
+         U+06F8: "۸" EXTENDED ARABIC-INDIC DIGIT EIGHT -->
+    <Key
+        latin:keyLabel="&#x062D;"
+        latin:keyHintLabel="8"
+        latin:additionalMoreKeys="8,&#x06F8;" />
+    <!-- U+062C: "ج" ARABIC LETTER JEEM
+         U+06F9: "۹" EXTENDED ARABIC-INDIC DIGIT NINE -->
+    <Key
+        latin:keyLabel="&#x062C;"
+        latin:keyHintLabel="9"
+        latin:additionalMoreKeys="9,&#x06F9;" />
+    <!-- U+0686: "چ" ARABIC LETTER TCHEH
+         U+06F0: "۰" EXTENDED ARABIC-INDIC DIGIT ZERO -->
+    <Key
+        latin:keyLabel="&#x0686;"
+        latin:keyHintLabel="0"
+        latin:additionalMoreKeys="0,&#x06F0;" />
+</merge>
diff --git a/java/res/xml/rowkeys_farsi2.xml b/java/res/xml/rowkeys_farsi2.xml
new file mode 100644
index 0000000..77279c6
--- /dev/null
+++ b/java/res/xml/rowkeys_farsi2.xml
@@ -0,0 +1,71 @@
+<?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;" />
+    <!-- U+0633: "س" ARABIC LETTER SEEN
+         U+0636: "ض" ARABIC LETTER DAD -->
+    <Key
+        latin:keyLabel="&#x0633;"
+        latin:moreKeys="&#x0636;" />
+    <!-- U+06CC: "ی" ARABIC LETTER FARSI YEH
+         U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE
+         U+064A: "ي" ARABIC LETTER YEH -->
+    <Key
+        latin:keyLabel="&#x06CC;"
+        latin:moreKeys="&#x0626;,&#x064A;" />
+    <!-- U+0628: "ب" ARABIC LETTER BEH -->
+    <Key
+        latin:keyLabel="&#x0628;" />
+    <!-- U+0644: "ل" ARABIC LETTER LAM -->
+    <Key
+        latin:keyLabel="&#x0644;" />
+    <!-- U+0627: "ا" ARABIC LETTER ALEF
+         U+0621: "ء" ARABIC LETTER HAMZA
+         U+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE
+         U+0672: "ٲ" ARABIC LETTER ALEF WITH WAVY HAMZA ABOVE
+         U+0671: "ٱ" ARABIC LETTER ALEF WASLA
+         U+0673: "ٳ" ARABIC LETTER ALEF WITH WAVY HAMZA BELOW-->
+    <!-- TODO: DroidSansArabic lacks the glyph of U+0672 ARABIC LETTER ALEF WITH WAVY HAMZA ABOVE -->
+    <!-- TODO: DroidSansArabic lacks the glyph of U+0673 ARABIC LETTER ALEF WITH WAVY HAMZA BELOW -->
+    <Key
+        latin:keyLabel="&#x0627;"
+        latin:moreKeys="&#x0621;,&#x0622;,&#x0672;,&#x0671;,&#x0673;" />
+    <!-- U+062A: "ت" ARABIC LETTER TEH
+         U+062B: "ﺙ" ARABIC LETTER THEH -->
+    <Key
+        latin:keyLabel="&#x062A;"
+        latin:moreKeys="&#x062B;" />
+    <!-- U+0646: "ن" ARABIC LETTER NOON -->
+    <Key
+        latin:keyLabel="&#x0646;" />
+    <!-- U+0645: "م" ARABIC LETTER MEEM -->
+    <Key
+        latin:keyLabel="&#x0645;" />
+    <!-- U+06A9: "ک" ARABIC LETTER KEHEH
+         U+0643: "ك" ARABIC LETTER KAF -->
+    <Key
+        latin:keyLabel="&#x06A9;"
+        latin:moreKeys="&#x0643;" />
+</merge>
diff --git a/java/res/xml/rowkeys_farsi3.xml b/java/res/xml/rowkeys_farsi3.xml
new file mode 100644
index 0000000..8db56e3
--- /dev/null
+++ b/java/res/xml/rowkeys_farsi3.xml
@@ -0,0 +1,55 @@
+<?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+0637: "ط" ARABIC LETTER TAH
+         U+0638: "ظ" ARABIC LETTER ZAH -->
+    <Key
+        latin:keyLabel="&#x0637;"
+        latin:moreKeys="&#x0638;" />
+    <!-- U+0698: "ژ" ARABIC LETTER JEH -->
+    <Key
+        latin:keyLabel="&#x0698;" />
+    <!-- U+0632: "ز" ARABIC LETTER ZAIN -->
+    <Key
+        latin:keyLabel="&#x0632;" />
+    <!-- U+0631: "ر" ARABIC LETTER REH -->
+    <Key
+        latin:keyLabel="&#x0631;" />
+    <!-- U+062F: "د" ARABIC LETTER DAL
+         U+0630: "ذ" ARABIC LETTER THAL -->
+    <Key
+        latin:keyLabel="&#x062F;"
+        latin:moreKeys="&#x0630;" />
+    <!-- U+067E: "پ" ARABIC LETTER PEH -->
+    <Key
+        latin:keyLabel="&#x067E;" />
+    <!-- U+0648: "و" ARABIC LETTER WAW
+         U+0676: "ٶ" ARABIC LETTER HIGH HAMZA WAW -->
+    <!-- TODO: DroidSansArabic lacks the glyph of U+0676 ARABIC LETTER HIGH HAMZA WAW -->
+    <Key
+        latin:keyLabel="&#x0648;"
+        latin:moreKeys="&#x0676;" />
+    <!-- U+06AF: "گ" ARABIC LETTER GAF -->
+    <Key
+        latin:keyLabel="&#x06AF;" />
+</merge>
diff --git a/java/res/xml/rows_farsi.xml b/java/res/xml/rows_farsi.xml
new file mode 100644
index 0000000..cc0c526
--- /dev/null
+++ b/java/res/xml/rows_farsi.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"
+>
+    <include
+        latin:keyboardLayout="@xml/key_styles_common" />
+    <Row
+        latin:keyWidth="10%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_farsi1" />
+    </Row>
+    <Row
+        latin:keyWidth="10%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_farsi2" />
+    </Row>
+    <Row
+        latin:keyWidth="10%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_farsi3"
+            latin:keyXPos="5.0%p" />
+        <Key
+            latin:keyStyle="deleteKeyStyle"
+            latin:keyWidth="fillRight"
+            latin:visualInsetsLeft="1%p" />
+    </Row>
+    <include
+        latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>