Support Thai Keyboard

Bug: 6070772
Change-Id: Ib7078d062801e17db500f0cd0b4b53d5433b75d1
diff --git a/java/res/xml/kbd_thai.xml b/java/res/xml/kbd_thai.xml
new file mode 100644
index 0000000..058ca16
--- /dev/null
+++ b/java/res/xml/kbd_thai.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_thai" />
+</Keyboard>
diff --git a/java/res/xml/kbd_thai_symbols.xml b/java/res/xml/kbd_thai_symbols.xml
new file mode 100644
index 0000000..7e075df
--- /dev/null
+++ b/java/res/xml/kbd_thai_symbols.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_symbols" />
+</Keyboard>
diff --git a/java/res/xml/kbd_thai_symbols_shift.xml b/java/res/xml/kbd_thai_symbols_shift.xml
new file mode 100644
index 0000000..25db3c8
--- /dev/null
+++ b/java/res/xml/kbd_thai_symbols_shift.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_symbols_shift" />
+</Keyboard>
diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml
index 077574f..544f3fd 100644
--- a/java/res/xml/method.xml
+++ b/java/res/xml/method.xml
@@ -58,6 +58,7 @@
     sl: Slovenian/qwerty
     sr: Serbian/south_slavic
     sv: Swedish/nordic
+    th: Thai/thai
     tr: Turkish/qwerty
     uk: Ukrainian/east_slavic
     vi: Vietnamese/qwerty
@@ -299,6 +300,12 @@
     />
     <subtype android:icon="@drawable/ic_subtype_keyboard"
             android:label="@string/subtype_generic"
+            android:imeSubtypeLocale="th"
+            android:imeSubtypeMode="keyboard"
+            android:imeSubtypeExtraValue=""
+    />
+    <subtype android:icon="@drawable/ic_subtype_keyboard"
+            android:label="@string/subtype_generic"
             android:imeSubtypeLocale="uk"
             android:imeSubtypeMode="keyboard"
             android:imeSubtypeExtraValue="SupportTouchPositionCorrection"
diff --git a/java/res/xml/rowkeys_thai1.xml b/java/res/xml/rowkeys_thai1.xml
new file mode 100644
index 0000000..54ec327
--- /dev/null
+++ b/java/res/xml/rowkeys_thai1.xml
@@ -0,0 +1,144 @@
+<?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:keyboardSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted"
+        >
+            <!-- U+0E0E: "ฎ" THAI CHARACTER DO CHADA -->
+            <Key
+                latin:keyLabel="&#x0E0E;"
+                latin:keyHintLabel="1"
+                latin:additionalMoreKeys="1" />
+            <!-- U+0E11: "ฑ" THAI CHARACTER THO NANGMONTHO -->
+            <Key
+                latin:keyLabel="&#x0E11;"
+                latin:keyHintLabel="2"
+                latin:additionalMoreKeys="2" />
+            <!-- U+0E18: "ธ" THAI CHARACTER THO THONG -->
+            <Key
+                latin:keyLabel="&#x0E18;"
+                latin:keyHintLabel="3"
+                latin:additionalMoreKeys="3" />
+            <!-- U+0E13: "ณ" THAI CHARACTER NO NEN -->
+            <Key
+                latin:keyLabel="&#x0E13;"
+                latin:keyHintLabel="4"
+                latin:additionalMoreKeys="4" />
+            <!-- U+0E0D: "ญ" THAI CHARACTER YO YING -->
+            <Key
+                latin:keyLabel="&#x0E0D;"
+                latin:keyHintLabel="5"
+                latin:additionalMoreKeys="5" />
+            <!-- U+0E10: "ฐ" THAI CHARACTER THO THAN -->
+            <Key
+                latin:keyLabel="&#x0E10;"
+                latin:keyHintLabel="6"
+                latin:additionalMoreKeys="6" />
+            <!-- U+0E03: "ฃ" THAI CHARACTER KHO KHUAT -->
+            <Key
+                latin:keyLabel="&#x0E03;"
+                latin:keyHintLabel="7"
+                latin:additionalMoreKeys="7" />
+            <!-- U+0E05: "ฅ" THAI CHARACTER KHO KHON -->
+            <Key
+                latin:keyLabel="&#x0E05;"
+                latin:keyHintLabel="8"
+                latin:additionalMoreKeys="8" />
+            <!-- U+0E51: "๑" THAI DIGIT ONE
+                 U+0E52: "๒" THAI DIGIT TWO
+                 U+0E53: "๓" THAI DIGIT THREE
+                 U+0E54: "๔" THAI DIGIT FOUR
+                 U+0E55: "๕" THAI DIGIT FIVE -->
+            <Key
+                latin:keyLabel="&#x0E51;"
+                latin:moreKeys="&#x0E52;,&#x0E53;,&#x0E54;,&#x0E55;,%"
+                latin:keyHintLabel="9"
+                latin:additionalMoreKeys="9" />
+            <!-- U+0E56: "๖" THAI DIGIT SIX
+                 U+0E57: "๗" THAI DIGIT SEVEN
+                 U+0E58: "๘" THAI DIGIT EIGHT
+                 U+0E59: "๙" THAI DIGIT NINE
+                 U+0E50: "๐" THAI DIGIT ZERO -->
+            <Key
+                latin:keyLabel="&#x0E56;"
+                latin:moreKeys="&#x0E57;,&#x0E58;,&#x0E59;,&#x0E50;,%"
+                latin:keyHintLabel="0"
+                latin:additionalMoreKeys="0" />
+        </case>
+        <default>
+            <!-- U+0E20: "ภ" THAI CHARACTER PHO SAMPHAO -->
+            <Key
+                latin:keyLabel="&#x0E20;"
+                latin:keyHintLabel="1"
+                latin:additionalMoreKeys="1,&#x0E51;" />
+            <!-- U+0E16: "ถ" THAI CHARACTER THO THUNG -->
+            <Key
+                latin:keyLabel="&#x0E16;"
+                latin:keyHintLabel="2"
+                latin:additionalMoreKeys="2,&#x0E52;" />
+            <!-- U+0E04: "ค" THAI CHARACTER KHO KHWAI -->
+            <Key
+                latin:keyLabel="&#x0E04;"
+                latin:keyHintLabel="3"
+                latin:additionalMoreKeys="3,&#x0E53;" />
+            <!-- U+0E15: "ต" THAI CHARACTER TO TAO -->
+            <Key
+                latin:keyLabel="&#x0E15;"
+                latin:keyHintLabel="4"
+                latin:additionalMoreKeys="4,&#x0E54;" />
+            <!-- U+0E08: "จ" THAI CHARACTER CHO CHAN -->
+            <Key
+                latin:keyLabel="&#x0E08;"
+                latin:keyHintLabel="5"
+                latin:additionalMoreKeys="5,&#x0E55;" />
+            <!-- U+0E02: "ข" THAI CHARACTER KHO KHAI -->
+            <Key
+                latin:keyLabel="&#x0E02;"
+                latin:keyHintLabel="6"
+                latin:additionalMoreKeys="6,&#x0E56;" />
+            <!-- U+0E0A: "ช" THAI CHARACTER CHO CHANG -->
+            <Key
+                latin:keyLabel="&#x0E0A;"
+                latin:keyHintLabel="7"
+                latin:additionalMoreKeys="7,&#x0E57;" />
+            <!-- U+0E23: "ร" THAI CHARACTER RO RUA
+                 U+0E25: "ล" THAI CHARACTER LO LING -->
+            <Key
+                latin:keyLabel="&#x0E23;"
+                latin:moreKeys="&#x0E25;"
+                latin:keyHintLabel="8"
+                latin:additionalMoreKeys="8,&#x0E58;" />
+            <!-- U+0E19: "น" THAI CHARACTER NO NU -->
+            <Key
+                latin:keyLabel="&#x0E19;"
+                latin:keyHintLabel="9"
+                latin:additionalMoreKeys="9,&#x0E59;" />
+            <!-- U+0E22: "ย" THAI CHARACTER YO YAK -->
+            <Key
+                latin:keyLabel="&#x0E22;"
+                latin:keyHintLabel="0"
+                latin:additionalMoreKeys="0,&#x0E50;" />
+        </default>
+    </switch>
+</merge>
diff --git a/java/res/xml/rowkeys_thai2.xml b/java/res/xml/rowkeys_thai2.xml
new file mode 100644
index 0000000..a5db665
--- /dev/null
+++ b/java/res/xml/rowkeys_thai2.xml
@@ -0,0 +1,105 @@
+<?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:keyboardSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted"
+        >
+            <!-- U+0E24: "ฤ" THAI CHARACTER RU -->
+            <Key
+                latin:keyLabel="&#x0E24;" />
+            <!-- U+0E06: "ฆ" THAI CHARACTER KHO RAKHANG -->
+            <Key
+                latin:keyLabel="&#x0E06;" />
+            <!-- U+0E0F: "ฏ" THAI CHARACTER TO PATAK -->
+            <Key
+                latin:keyLabel="&#x0E0F;" />
+            <!-- U+0E0C: "ฌ" THAI CHARACTER CHO CHOE -->
+            <Key
+                latin:keyLabel="&#x0E0C;" />
+            <!-- U+0E29: "ษ" THAI CHARACTER SO RUSI -->
+            <Key
+                latin:keyLabel="&#x0E29;" />
+            <!-- U+0E28: "ศ" THAI CHARACTER SO SALA -->
+            <Key
+                latin:keyLabel="&#x0E28;" />
+            <!-- U+0E0B: "ซ" THAI CHARACTER SO SO -->
+            <Key
+                latin:keyLabel="&#x0E0B;" />
+            <!-- U+0E3F: "฿" THAI CURRENCY SYMBOL BAHT -->
+            <Key
+                latin:keyLabel="&#x0E3F;" />
+            <!-- U+0E46: "ๆ" THAI CHARACTER MAIYAMOK
+                 U+0E2F: "ฯ" THAI CHARACTER PAIYANNOI -->
+            <Key
+                latin:keyLabel="&#x0E46;"
+                latin:moreKeys="&#x0E2F;" />
+        </case>
+        <default>
+            <!-- U+0E1F: "ฟ" THAI CHARACTER FO FAN
+                 U+0E1E: "พ" THAI CHARACTER PHO PHAN -->
+            <Key
+                latin:keyLabel="&#x0E1F;"
+                latin:moreKeys="&#x0E1E;" />
+            <!-- U+0E2B: "ห" THAI CHARACTER HO HIP -->
+            <Key
+                latin:keyLabel="&#x0E2B;" />
+            <!-- U+0E01: "ก" THAI CHARACTER KO KAI -->
+            <Key
+                latin:keyLabel="&#x0E01;" />
+            <!-- U+0E14: "ด" THAI CHARACTER DO DEK -->
+            <Key
+                latin:keyLabel="&#x0E14;" />
+            <!-- U+0E2A: "ส" THAI CHARACTER SO SUA -->
+            <Key
+                latin:keyLabel="&#x0E2A;" />
+            <!-- U+0E27: "ว" THAI CHARACTER WO WAEN -->
+            <Key
+                latin:keyLabel="&#x0E27;" />
+            <!-- U+0E07: "ง" THAI CHARACTER NGO NGU -->
+            <Key
+                latin:keyLabel="&#x0E07;" />
+            <!-- U+0E30: "ะ" THAI CHARACTER SARA A
+                 U+0E32: "า" THAI CHARACTER SARA AA
+                 U+0E33: " ำ" THAI CHARACTER SARA AM
+                 U+0E40: "เ" THAI CHARACTER SARA E
+                 U+0E41: "แ" THAI CHARACTER SARA AE
+                 U+0E43: "ใ" THAI CHARACTER SARA AI MAIMUAN
+                 U+0E44: "ไ" THAI CHARACTER SARA AI MAIMALAI
+                 U+0E42: "โ" THAI CHARACTER SARA O -->
+            <Key
+                latin:keyLabel="&#x0E30;"
+                latin:moreKeys="&#x0E32;,&#x0E33;,&#x0E40;,&#x0E41;,&#x0E43;,&#x0E44;,&#x0E42;" />
+            <!-- U+0E31: " ั" THAI CHARACTER MAI HAN-AKAT
+                 U+0E34: " ิ" THAI CHARACTER SARA I
+                 U+0E35: " ี" THAI CHARACTER SARA II
+                 U+0E36: " ึ" THAI CHARACTER SARA UE
+                 U+0E37: " ื" THAI CHARACTER SARA UEE
+                 U+0E38: " ุ" THAI CHARACTER SARA U
+                 U+0E39: " ู" THAI CHARACTER SARA UU -->
+            <Key
+                latin:keyLabel="&#x0E31;"
+                latin:moreKeys="&#x0E34;,&#x0E35;,&#x0E36;,&#x0E37;,&#x0E38;,&#x0E39;" />
+        </default>
+    </switch>
+</merge>
diff --git a/java/res/xml/rowkeys_thai3.xml b/java/res/xml/rowkeys_thai3.xml
new file mode 100644
index 0000000..72c0def
--- /dev/null
+++ b/java/res/xml/rowkeys_thai3.xml
@@ -0,0 +1,83 @@
+<?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:keyboardSetElement="alphabetManualShifted|alphabetShiftLocked|alphabetShiftLockShifted"
+        >
+            <!-- U+0E09: "ฉ" THAI CHARACTER CHO CHING -->
+            <Key
+                latin:keyLabel="&#x0E09;" />
+            <!-- U+0E2E: "ฮ" THAI CHARACTER HO NOKHUK -->
+            <Key
+                latin:keyLabel="&#x0E2E;" />
+            <!-- U+0E12: "ฒ" THAI CHARACTER THO PHUTHAO -->
+            <Key
+                latin:keyLabel="&#x0E12;" />
+            <!-- U+0E2C: "ฬ" THAI CHARACTER LO CHULA -->
+            <Key
+                latin:keyLabel="&#x0E2C;" />
+            <!-- U+0E26: "ฦ" THAI CHARACTER LU -->
+            <Key
+                latin:keyLabel="&#x0E26;" />
+            <!-- U+0E4C: " ์" THAI CHARACTER THANTHAKHAT
+                 U+0E4D: " ํ" THAI CHARACTER NIKHAHIT
+                 U+0E3A: " ฺ" THAI CHARACTER PHINTHU -->
+            <Key
+                latin:keyLabel="&#x0E4C;"
+                latin:moreKeys="&#x0E4D;,&#x0E3A;" />
+            <!-- U+0E47: " ็" THAI CHARACTER MAITAIKHU -->
+            <Key
+                latin:keyLabel="&#x0E47;" />
+        </case>
+        <default>
+            <!-- U+0E1C: "ผ" THAI CHARACTER PHO PHUNG -->
+            <Key
+                latin:keyLabel="&#x0E1C;" />
+            <!-- U+0E1B: "ป" THAI CHARACTER PO PLA
+                 U+0E1A: "บ" THAI CHARACTER BO BAIMAI -->
+            <Key
+                latin:keyLabel="&#x0E1B;"
+                latin:moreKeys="&#x0E1A;" />
+            <!-- U+0E2D: "อ" THAI CHARACTER O ANG -->
+            <Key
+                latin:keyLabel="&#x0E2D;" />
+            <!-- U+0E17: "ท" THAI CHARACTER THO THAHAN -->
+            <Key
+                latin:keyLabel="&#x0E17;" />
+            <!-- U+0E21: "ม" THAI CHARACTER MO MA -->
+            <Key
+                latin:keyLabel="&#x0E21;" />
+            <!-- U+0E1D: "ฝ" THAI CHARACTER FO FA -->
+            <Key
+                latin:keyLabel="&#x0E1D;" />
+            <!-- U+0E48: " ่" THAI CHARACTER MAI EK
+                 U+0E49: " ้" THAI CHARACTER MAI THO
+                 U+0E4A: " ๊" THAI CHARACTER MAI TRI
+                 U+0E4B: " ๋" THAI CHARACTER MAI CHATTAWA -->
+            <Key
+                latin:keyLabel="&#x0E48;"
+                latin:moreKeys="&#x0E49;,&#x0E4A;,&#x0E4B;" />
+        </default>
+    </switch>
+</merge>
diff --git a/java/res/xml/rows_thai.xml b/java/res/xml/rows_thai.xml
new file mode 100644
index 0000000..6b80df6
--- /dev/null
+++ b/java/res/xml/rows_thai.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"
+>
+    <include
+        latin:keyboardLayout="@xml/key_styles_common" />
+    <Row
+        latin:keyWidth="10%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_thai1" />
+    </Row>
+    <Row
+        latin:keyWidth="10%p"
+    >
+        <include
+            latin:keyboardLayout="@xml/rowkeys_thai2"
+            latin:keyXPos="5%p" />
+    </Row>
+    <Row
+        latin:keyWidth="10%p"
+    >
+        <Key
+            latin:keyStyle="shiftKeyStyle"
+            latin:keyWidth="15%p"
+            latin:visualInsetsRight="1%p" />
+        <include
+            latin:keyboardLayout="@xml/rowkeys_thai3" />
+        <Key
+            latin:keyStyle="deleteKeyStyle"
+            latin:keyWidth="fillRight"
+            latin:visualInsetsLeft="1%p" />
+    </Row>
+    <include
+        latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>