Merge "[CB20] Some more refactoring"
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index e38bdd6..937a799 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -358,9 +358,13 @@
(US) should be an abbreviation of United Statesn to fit in the CHAR LIMIT.
This should be identical to subtype_es_US aside from the trailing (%s). -->
<string name="subtype_with_layout_es_US">Spanish (US) (<xliff:g id="KEYBOARD_LAYOUT" example="QWERTY">%s</xliff:g>)</string>
- <!-- Description for Nepali (Traditional) keyboard subtype [CHAR LIMIT=25]
+ <!-- Description for "LANGUAGE_NAME" (Traditional) keyboard subtype [CHAR LIMIT=25]
(Traditional) can be an abbreviation to fit in the CHAR LIMIT. -->
- <string name="subtype_nepali_traditional"><xliff:g id="LANGUAGE_NAME" example="Nepali">%s</xliff:g> (Traditional)</string>
+ <string name="subtype_generic_traditional"><xliff:g id="LANGUAGE_NAME" example="Nepali">%s</xliff:g> (Traditional)</string>
+ <!-- Description for "LANGUAGE_NAME" (Compact) keyboard subtype [CHAR LIMIT=25]
+ (Compact) can be an abbreviation to fit in the CHAR LIMIT.
+ TODO: Remove translatable=false once we are settled down with the naming. -->
+ <string name="subtype_generic_compact" translatable="false"><xliff:g id="LANGUAGE_NAME" example="Hindi">%s</xliff:g> (Compact)</string>
<!-- TODO: Uncomment once we can handle IETF language tag with script name specified.
Description for Serbian Cyrillic keyboard subtype [CHAR LIMIT=25]
(Cyrillic) can be an abbreviation to fit in the CHAR LIMIT.
diff --git a/java/res/xml-sw600dp/keys_comma_period.xml b/java/res/xml-sw600dp/keys_comma_period.xml
index ab98733..23172cf 100644
--- a/java/res/xml-sw600dp/keys_comma_period.xml
+++ b/java/res/xml-sw600dp/keys_comma_period.xml
@@ -28,11 +28,26 @@
latin:moreKeys="!text/morekeys_tablet_comma"
latin:backgroundType="functional"
latin:keyStyle="hasShiftedLetterHintStyle" />
- <Key
- latin:keySpec="!text/keyspec_tablet_period"
- latin:keyHintLabel="!text/keyhintlabel_tablet_period"
- latin:keyLabelFlags="hasPopupHint"
- latin:moreKeys="!text/morekeys_tablet_period"
- latin:backgroundType="functional"
- latin:keyStyle="hasShiftedLetterHintStyle" />
+ <switch>
+ <case
+ latin:languageCode="hi"
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+0964: "।" DEVANAGARI DANDA -->
+ <Key
+ latin:keySpec="\u0964"
+ latin:keyLabelFlags="hasPopupHint"
+ latin:moreKeys="!autoColumnOrder!8,\\,,.,',#,),(,/,;,@,:,-,",+,\\%,&"
+ latin:backgroundType="functional" />
+ </case>
+ <default>
+ <Key
+ latin:keySpec="!text/keyspec_tablet_period"
+ latin:keyHintLabel="!text/keyhintlabel_tablet_period"
+ latin:keyLabelFlags="hasPopupHint"
+ latin:moreKeys="!text/morekeys_tablet_period"
+ latin:backgroundType="functional"
+ latin:keyStyle="hasShiftedLetterHintStyle" />
+ </default>
+ </switch>
</merge>
diff --git a/java/res/xml-sw600dp/rows_hindi_compact.xml b/java/res/xml-sw600dp/rows_hindi_compact.xml
new file mode 100644
index 0000000..ac476eb
--- /dev/null
+++ b/java/res/xml-sw600dp/rows_hindi_compact.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2014, 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="8.182%p"
+ >
+ <include
+ latin:keyboardLayout="@xml/rowkeys_hindi_compact1" />
+ <Key
+ latin:keyStyle="deleteKeyStyle"
+ latin:keyWidth="fillRight" />
+ </Row>
+ <Row
+ latin:keyWidth="8.182%p"
+ >
+ <include
+ latin:keyboardLayout="@xml/rowkeys_hindi_compact2" />
+ <Key
+ latin:keyStyle="enterKeyStyle"
+ latin:keyWidth="fillRight" />
+ </Row>
+ <Row
+ latin:keyWidth="8.182%p"
+ >
+ <include
+ latin:keyboardLayout="@xml/rowkeys_hindi_compact3" />
+ <include
+ latin:keyboardLayout="@xml/keys_exclamation_question" />
+ </Row>
+ <include
+ latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>
diff --git a/java/res/xml-v16/key_devanagari_sign_anusvara.xml b/java/res/xml-v16/key_devanagari_sign_anusvara.xml
deleted file mode 100644
index ee0f21d..0000000
--- a/java/res/xml-v16/key_devanagari_sign_anusvara.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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.
-*/
--->
-
-<!-- The code point U+25CC for key label is needed because the font rendering system prior to
- API version 16 can't automatically render dotted circle for incomplete combining letter
- of some scripts. The files named res/xml/key_*.xml have this U+25CC hack, although the
- counterpart files named res/xml-v16/key_*.xml don't have this hack. -->
-<merge
- xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
- <!-- U+0902: "ं" DEVANAGARI SIGN ANUSVARA -->
- <Key
- latin:keySpec="ं"
- latin:keyLabelFlags="fontNormal" />
-</merge>
diff --git a/java/res/xml-v16/key_devanagari_vowel_sign_candra_o.xml b/java/res/xml-v16/key_devanagari_vowel_sign_candra_o.xml
deleted file mode 100644
index 2f17399..0000000
--- a/java/res/xml-v16/key_devanagari_vowel_sign_candra_o.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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.
-*/
--->
-
-<!-- The code point U+25CC for key label is needed because the font rendering system prior to
- API version 16 can't automatically render dotted circle for incomplete combining letter
- of some scripts. The files named res/xml/key_*.xml have this U+25CC hack, although the
- counterpart files named res/xml-v16/key_*.xml don't have this hack. -->
-<merge
- xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
- <!-- U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O -->
- <Key
- latin:keySpec="ॉ"
- latin:keyLabelFlags="fontNormal" />
-</merge>
diff --git a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml b/java/res/xml-v16/keystyle_devanagari_sign_anusvara.xml
similarity index 67%
copy from java/res/xml-v16/key_devanagari_sign_candrabindu.xml
copy to java/res/xml-v16/keystyle_devanagari_sign_anusvara.xml
index f246120..71439d6 100644
--- a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml
+++ b/java/res/xml-v16/keystyle_devanagari_sign_anusvara.xml
@@ -27,21 +27,24 @@
>
<switch>
<case
- latin:keyboardLayoutSet="hindi"
+ latin:keyboardLayoutSet="hindi_compact"
>
- <!-- U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E -->
+ <!-- U+0903: "ः" DEVANAGARI SIGN VISARGA
+ U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
+ U+093C: "़" DEVANAGARI SIGN NUKTA -->
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu"
- latin:moreKeys="ॅ" />
+ latin:styleName="moreKeysDevanagariSignAnusvara"
+ latin:moreKeys="ः,ँ,़" />
</case>
<default>
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu" />
+ latin:styleName="moreKeysDevanagariSignAnusvara" />
</default>
</switch>
- <!-- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignCandrabindu"
- latin:keySpec="ँ"
+ <!-- U+0902: "ं" DEVANAGARI SIGN ANUSVARA -->
+ <key-style
+ latin:styleName="baseKeyDevanagariSignAnusvara"
+ latin:parentStyle="moreKeysDevanagariSignAnusvara"
+ latin:keySpec="ं"
latin:keyLabelFlags="fontNormal" />
</merge>
diff --git a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml b/java/res/xml-v16/keystyle_devanagari_sign_candrabindu.xml
similarity index 92%
rename from java/res/xml-v16/key_devanagari_sign_candrabindu.xml
rename to java/res/xml-v16/keystyle_devanagari_sign_candrabindu.xml
index f246120..6198d01 100644
--- a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml
+++ b/java/res/xml-v16/keystyle_devanagari_sign_candrabindu.xml
@@ -40,8 +40,9 @@
</default>
</switch>
<!-- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignCandrabindu"
+ <key-style
+ latin:styleName="baseKeyDevanagariSignCandrabindu"
+ latin:parentStyle="moreKeysDevanagariSignCandrabindu"
latin:keySpec="ँ"
latin:keyLabelFlags="fontNormal" />
</merge>
diff --git a/java/res/xml-v16/key_devanagari_sign_nukta.xml b/java/res/xml-v16/keystyle_devanagari_sign_nukta.xml
similarity index 81%
rename from java/res/xml-v16/key_devanagari_sign_nukta.xml
rename to java/res/xml-v16/keystyle_devanagari_sign_nukta.xml
index 9157795..e0b47bb 100644
--- a/java/res/xml-v16/key_devanagari_sign_nukta.xml
+++ b/java/res/xml-v16/keystyle_devanagari_sign_nukta.xml
@@ -36,14 +36,23 @@
latin:styleName="moreKeysDevanagariSignNukta"
latin:moreKeys="ॽ,॰,ऽ" />
</case>
+ <case
+ latin:keyboardLayoutSet="nepali_romanized"
+ >
+ <!-- U+093C: "़" DEVANAGARI SIGN NUKTA -->
+ <key-style
+ latin:styleName="moreKeysDevanagariSignNukta"
+ latin:moreKeys="़" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariSignNukta" />
</default>
</switch>
<!-- U+093C: "़" DEVANAGARI SIGN NUKTA -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignNukta"
+ <key-style
+ latin:styleName="baseKeyDevanagariSignNukta"
+ latin:parentStyle="moreKeysDevanagariSignNukta"
latin:keySpec="़"
latin:keyLabelFlags="fontNormal" />
</merge>
diff --git a/java/res/xml-v16/keystyle_devanagari_sign_virama.xml b/java/res/xml-v16/keystyle_devanagari_sign_virama.xml
index 764fb1f..0c3a29b 100644
--- a/java/res/xml-v16/keystyle_devanagari_sign_virama.xml
+++ b/java/res/xml-v16/keystyle_devanagari_sign_virama.xml
@@ -25,9 +25,24 @@
<merge
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
>
+ <switch>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+094D: "्" DEVANAGARI SIGN VIRAMA -->
+ <key-style
+ latin:styleName="moreKeysDevanagariSignVirama"
+ latin:moreKeys="्" />
+ </case>
+ <default>
+ <key-style
+ latin:styleName="moreKeysDevanagariSignVirama" />
+ </default>
+ </switch>
<!-- U+094D: "्" DEVANAGARI SIGN VIRAMA -->
<key-style
latin:styleName="baseKeyDevanagariSignVirama"
+ latin:parentStyle="moreKeysDevanagariSignVirama"
latin:keySpec="्"
latin:keyLabelFlags="fontNormal" />
</merge>
diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_aa.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_aa.xml
index fe9264b..5bb0351 100644
--- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_aa.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_aa.xml
@@ -35,6 +35,14 @@
latin:styleName="moreKeysDevanagariVowelSignAa"
latin:moreKeys="ां,ाँ,%" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+093E: "ा" DEVANAGARI VOWEL SIGN AA -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignAa"
+ latin:moreKeys="ा,%" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignAa" />
diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_ai.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_ai.xml
index fdb53bb..8edf6eb 100644
--- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_ai.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_ai.xml
@@ -35,6 +35,14 @@
latin:moreKeys="ैं,%" />
</case>
<case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+0948: "ै" DEVANAGARI VOWEL SIGN AI -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignAi"
+ latin:moreKeys="ै,%" />
+ </case>
+ <case
latin:keyboardLayoutSet="nepali_traditional"
>
<!-- U+0936/U+094D/U+0930: "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA -->
diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_au.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_au.xml
index 653e79e..212e058 100644
--- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_au.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_au.xml
@@ -34,6 +34,14 @@
latin:styleName="moreKeysDevanagariVowelSignAu"
latin:moreKeys="ौं,%" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+094C: "ौ" DEVANAGARI VOWEL SIGN AU -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignAu"
+ latin:moreKeys="ौ,%" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignAu" />
diff --git a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_e.xml
similarity index 75%
copy from java/res/xml-v16/key_devanagari_sign_candrabindu.xml
copy to java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_e.xml
index f246120..ef2c3f1 100644
--- a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_e.xml
@@ -2,7 +2,7 @@
<!--
/*
**
-** Copyright 2013, The Android Open Source Project
+** Copyright 2014, 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.
@@ -27,21 +27,16 @@
>
<switch>
<case
- latin:keyboardLayoutSet="hindi"
+ latin:keyboardLayoutSet="hindi_compact"
>
<!-- U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E -->
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu"
+ latin:styleName="moreKeysDevanagariVowelSignCandraE"
latin:moreKeys="ॅ" />
</case>
<default>
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu" />
+ latin:styleName="moreKeysDevanagariVowelSignCandraE" />
</default>
</switch>
- <!-- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignCandrabindu"
- latin:keySpec="ँ"
- latin:keyLabelFlags="fontNormal" />
</merge>
diff --git a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_o.xml
similarity index 71%
copy from java/res/xml-v16/key_devanagari_sign_candrabindu.xml
copy to java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_o.xml
index f246120..ac01d37 100644
--- a/java/res/xml-v16/key_devanagari_sign_candrabindu.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_candra_o.xml
@@ -27,21 +27,22 @@
>
<switch>
<case
- latin:keyboardLayoutSet="hindi"
+ latin:keyboardLayoutSet="hindi_compact"
>
- <!-- U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E -->
+ <!-- U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O -->
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu"
- latin:moreKeys="ॅ" />
+ latin:styleName="moreKeysDevanagariVowelSignCandraO"
+ latin:moreKeys="ॉ" />
</case>
<default>
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu" />
+ latin:styleName="moreKeysDevanagariVowelSignCandraO" />
</default>
</switch>
- <!-- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignCandrabindu"
- latin:keySpec="ँ"
+ <!-- U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O -->
+ <key-style
+ latin:styleName="baseKeyDevanagariVowelSignCandraO"
+ latin:parentStyle="moreKeysDevanagariVowelSignCandraO"
+ latin:keySpec="ॉ"
latin:keyLabelFlags="fontNormal" />
</merge>
diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_e.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_e.xml
index 7240a2c..77d6eb5 100644
--- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_e.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_e.xml
@@ -35,6 +35,14 @@
latin:moreKeys="ें" />
</case>
<case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+0947: "े" DEVANAGARI VOWEL SIGN E -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignE"
+ latin:moreKeys="े" />
+ </case>
+ <case
latin:keyboardLayoutSet="nepali_traditional"
>
<!-- U+0903: "ः" DEVANAGARI SIGN VISARGA
diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_i.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_i.xml
index 5a006f0..d79447b 100644
--- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_i.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_i.xml
@@ -34,6 +34,14 @@
latin:styleName="moreKeysDevanagariVowelSignI"
latin:moreKeys="िं" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+093F: "ि" DEVANAGARI VOWEL SIGN I -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignI"
+ latin:moreKeys="ि" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignI" />
diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_ii.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_ii.xml
index a2b07fe..0e10f31 100644
--- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_ii.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_ii.xml
@@ -34,6 +34,14 @@
latin:styleName="moreKeysDevanagariVowelSignIi"
latin:moreKeys="ीं,%" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+0940: "ी" DEVANAGARI VOWEL SIGN II -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignIi"
+ latin:moreKeys="ी,%" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignIi" />
diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_o.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_o.xml
index 4b764cd..47ca906 100644
--- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_o.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_o.xml
@@ -29,13 +29,21 @@
<case
latin:keyboardLayoutSet="hindi"
>
- <!-- U+094B/U+0902: "қं" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA
+ <!-- U+094B/U+0902: "ों" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA
U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O
U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O -->
<key-style
latin:styleName="moreKeysDevanagariVowelSignO"
latin:moreKeys="ों,ॉ,ॊ" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+094B: "ो" DEVANAGARI VOWEL SIGN O -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignO"
+ latin:moreKeys="ो" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignO" />
diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_u.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_u.xml
index 18d485a..694e4ab 100644
--- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_u.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_u.xml
@@ -35,6 +35,14 @@
latin:styleName="moreKeysDevanagariVowelSignU"
latin:moreKeys="ुं,ुँ" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+0941: "ु" DEVANAGARI VOWEL SIGN U -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignU"
+ latin:moreKeys="ु" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignU" />
diff --git a/java/res/xml-v16/keystyle_devanagari_vowel_sign_uu.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_uu.xml
index d770ee6..f17489e 100644
--- a/java/res/xml-v16/keystyle_devanagari_vowel_sign_uu.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_uu.xml
@@ -35,6 +35,14 @@
latin:styleName="moreKeysDevanagariVowelSignUu"
latin:moreKeys="ूं,ूँ,%" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+0942: "ू" DEVANAGARI VOWEL SIGN UU -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignUu"
+ latin:moreKeys="ू,%" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignUu" />
diff --git a/java/res/xml-v16/key_devanagari_vowel_sign_vocalic_r.xml b/java/res/xml-v16/keystyle_devanagari_vowel_sign_vocalic_r.xml
similarity index 79%
rename from java/res/xml-v16/key_devanagari_vowel_sign_vocalic_r.xml
rename to java/res/xml-v16/keystyle_devanagari_vowel_sign_vocalic_r.xml
index dc7a0e0..2709846 100644
--- a/java/res/xml-v16/key_devanagari_vowel_sign_vocalic_r.xml
+++ b/java/res/xml-v16/keystyle_devanagari_vowel_sign_vocalic_r.xml
@@ -35,6 +35,15 @@
latin:moreKeys="ॄ" />
</case>
<case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R
+ U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignVocalicR"
+ latin:moreKeys="ऋ,ृ" />
+ </case>
+ <case
latin:keyboardLayoutSet="nepali_traditional"
>
<!-- U+0913: "ओ" DEVANAGARI LETTER O -->
@@ -48,8 +57,9 @@
</default>
</switch>
<!-- U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R -->
- <Key
- latin:keyStyle="moreKeysDevanagariVowelSignVocalicR"
+ <key-style
+ latin:styleName="baseKeyDevanagariVowelSignVocalicR"
+ latin:parentStyle="moreKeysDevanagariVowelSignVocalicR"
latin:keySpec="ृ"
latin:keyLabelFlags="fontNormal" />
</merge>
diff --git a/java/res/xml/kbd_hindi_compact.xml b/java/res/xml/kbd_hindi_compact.xml
new file mode 100644
index 0000000..7502bba
--- /dev/null
+++ b/java/res/xml/kbd_hindi_compact.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2014, 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_hindi_compact" />
+</Keyboard>
diff --git a/java/res/xml/key_devanagari_sign_anusvara.xml b/java/res/xml/key_devanagari_sign_anusvara.xml
deleted file mode 100644
index 5d7c018..0000000
--- a/java/res/xml/key_devanagari_sign_anusvara.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?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.
-*/
--->
-
-<!-- The code point U+25CC for key label is needed because the font rendering system prior to
- API version 16 can't automatically render dotted circle for incomplete combining letter
- of some scripts. The files named res/xml/key_*.xml have this U+25CC hack, although the
- counterpart files named res/xml-v16/key_*.xml don't have this hack. -->
-<merge
- xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
- <!-- U+25CC: "◌" DOTTED CIRCLE
- U+0902: "ं" DEVANAGARI SIGN ANUSVARA -->
- <Key
- latin:keySpec="◌ं|ं"
- latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
-</merge>
diff --git a/java/res/xml/key_devanagari_vowel_sign_candra_o.xml b/java/res/xml/key_devanagari_vowel_sign_candra_o.xml
deleted file mode 100644
index 6d7d000..0000000
--- a/java/res/xml/key_devanagari_vowel_sign_candra_o.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?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.
-*/
--->
-
-<!-- The code point U+25CC for key label is needed because the font rendering system prior to
- API version 16 can't automatically render dotted circle for incomplete combining letter
- of some scripts. The files named res/xml/key_*.xml have this U+25CC hack, although the
- counterpart files named res/xml-v16/key_*.xml don't have this hack. -->
-<merge
- xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
->
- <!-- U+25CC: "◌" DOTTED CIRCLE
- U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O -->
- <Key
- latin:keySpec="◌ॉ|ॉ"
- latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
-</merge>
diff --git a/java/res/xml/key_period.xml b/java/res/xml/key_period.xml
index ce23e22..e1d4bbd 100644
--- a/java/res/xml/key_period.xml
+++ b/java/res/xml/key_period.xml
@@ -23,6 +23,17 @@
>
<switch>
<case
+ latin:languageCode="hi"
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+0964: "।" DEVANAGARI DANDA -->
+ <Key
+ latin:keySpec="\u0964"
+ latin:keyLabelFlags="hasPopupHint"
+ latin:moreKeys="!autoColumnOrder!9,\\,,.,?,!,#,),(,/,;,',@,:,-,",+,\\%,&"
+ latin:backgroundType="functional" />
+ </case>
+ <case
latin:languageCode="ne"
latin:keyboardLayoutSet="nepali_traditional"
>
diff --git a/java/res/xml/keyboard_layout_set_hindi_compact.xml b/java/res/xml/keyboard_layout_set_hindi_compact.xml
new file mode 100644
index 0000000..77d02fb
--- /dev/null
+++ b/java/res/xml/keyboard_layout_set_hindi_compact.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2014, 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_hindi_compact"
+ 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/key_devanagari_sign_candrabindu.xml b/java/res/xml/keystyle_devanagari_sign_anusvara.xml
similarity index 66%
copy from java/res/xml/key_devanagari_sign_candrabindu.xml
copy to java/res/xml/keystyle_devanagari_sign_anusvara.xml
index 9e9c371..6dc9b7e 100644
--- a/java/res/xml/key_devanagari_sign_candrabindu.xml
+++ b/java/res/xml/keystyle_devanagari_sign_anusvara.xml
@@ -27,23 +27,26 @@
>
<switch>
<case
- latin:keyboardLayoutSet="hindi"
+ latin:keyboardLayoutSet="hindi_compact"
>
<!-- U+25CC: "◌" DOTTED CIRCLE
- U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E -->
+ U+0903: "ः" DEVANAGARI SIGN VISARGA
+ U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
+ U+093C: "़" DEVANAGARI SIGN NUKTA -->
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu"
- latin:moreKeys="◌ॅ|ॅ" />
+ latin:styleName="moreKeysDevanagariSignAnusvara"
+ latin:moreKeys="◌ः|ः,◌ँ|ँ,◌़|़" />
</case>
<default>
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu" />
+ latin:styleName="moreKeysDevanagariSignAnusvara" />
</default>
</switch>
<!-- U+25CC: "◌" DOTTED CIRCLE
- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignCandrabindu"
- latin:keySpec="◌ँ|ँ"
+ U+0902: "ं" DEVANAGARI SIGN ANUSVARA -->
+ <key-style
+ latin:styleName="baseKeyDevanagariSignAnusvara"
+ latin:parentStyle="moreKeysDevanagariSignAnusvara"
+ latin:keySpec="◌ं|ं"
latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
</merge>
diff --git a/java/res/xml/key_devanagari_sign_candrabindu.xml b/java/res/xml/keystyle_devanagari_sign_candrabindu.xml
similarity index 93%
rename from java/res/xml/key_devanagari_sign_candrabindu.xml
rename to java/res/xml/keystyle_devanagari_sign_candrabindu.xml
index 9e9c371..24cb44b 100644
--- a/java/res/xml/key_devanagari_sign_candrabindu.xml
+++ b/java/res/xml/keystyle_devanagari_sign_candrabindu.xml
@@ -42,8 +42,9 @@
</switch>
<!-- U+25CC: "◌" DOTTED CIRCLE
U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignCandrabindu"
+ <key-style
+ latin:styleName="baseKeyDevanagariSignCandrabindu"
+ latin:parentStyle="moreKeysDevanagariSignCandrabindu"
latin:keySpec="◌ँ|ँ"
latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
</merge>
diff --git a/java/res/xml/key_devanagari_sign_nukta.xml b/java/res/xml/keystyle_devanagari_sign_nukta.xml
similarity index 80%
rename from java/res/xml/key_devanagari_sign_nukta.xml
rename to java/res/xml/keystyle_devanagari_sign_nukta.xml
index b56eb0a..41da555 100644
--- a/java/res/xml/key_devanagari_sign_nukta.xml
+++ b/java/res/xml/keystyle_devanagari_sign_nukta.xml
@@ -37,6 +37,15 @@
latin:styleName="moreKeysDevanagariSignNukta"
latin:moreKeys="◌ॽ|ॽ,◌॰|॰,◌ऽ|ऽ" />
</case>
+ <case
+ latin:keyboardLayoutSet="nepali_romanized"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+093C: "़" DEVANAGARI SIGN NUKTA -->
+ <key-style
+ latin:styleName="moreKeysDevanagariSignNukta"
+ latin:moreKeys="◌़|़" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariSignNukta" />
@@ -44,8 +53,9 @@
</switch>
<!-- U+25CC: "◌" DOTTED CIRCLE
U+093C: "़" DEVANAGARI SIGN NUKTA -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignNukta"
+ <key-style
+ latin:styleName="baseKeyDevanagariSignNukta"
+ latin:parentStyle="moreKeysDevanagariSignNukta"
latin:keySpec="◌़|़"
latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
</merge>
diff --git a/java/res/xml/keystyle_devanagari_sign_virama.xml b/java/res/xml/keystyle_devanagari_sign_virama.xml
index 5e0e108..96506e2 100644
--- a/java/res/xml/keystyle_devanagari_sign_virama.xml
+++ b/java/res/xml/keystyle_devanagari_sign_virama.xml
@@ -25,10 +25,26 @@
<merge
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
>
+ <switch>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+094D: "्" DEVANAGARI SIGN VIRAMA -->
+ <key-style
+ latin:styleName="moreKeysDevanagariSignVirama"
+ latin:moreKeys="◌्|्" />
+ </case>
+ <default>
+ <key-style
+ latin:styleName="moreKeysDevanagariSignVirama" />
+ </default>
+ </switch>
<!-- U+25CC: "◌" DOTTED CIRCLE
U+094D: "्" DEVANAGARI SIGN VIRAMA -->
<key-style
latin:styleName="baseKeyDevanagariSignVirama"
+ latin:parentStyle="moreKeysDevanagariSignVirama"
latin:keySpec="◌्|्"
latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
</merge>
diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml b/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml
index 97f98e3..4b87650 100644
--- a/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml
@@ -36,6 +36,15 @@
latin:styleName="moreKeysDevanagariVowelSignAa"
latin:moreKeys="◌ां|ां,◌ाँ|ाँ,%" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+093E: "ा" DEVANAGARI VOWEL SIGN AA -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignAa"
+ latin:moreKeys="◌ा|ा,%" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignAa" />
diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml b/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml
index 4d1b2c5..050a7ce 100644
--- a/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml
@@ -36,6 +36,15 @@
latin:moreKeys="◌ैं|ैं,%" />
</case>
<case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+0948: "ै" DEVANAGARI VOWEL SIGN AI -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignAi"
+ latin:moreKeys="◌ै|ै,%" />
+ </case>
+ <case
latin:keyboardLayoutSet="nepali_traditional"
>
<!-- U+0936/U+094D/U+0930: "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA -->
diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_au.xml b/java/res/xml/keystyle_devanagari_vowel_sign_au.xml
index 66628b5..49e67da 100644
--- a/java/res/xml/keystyle_devanagari_vowel_sign_au.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_au.xml
@@ -30,11 +30,20 @@
latin:keyboardLayoutSet="hindi"
>
<!-- U+25CC: "◌" DOTTED CIRCLE
- U+094C/U+0902: "ौं" DEVANAGARI VOWEL SIGN AU/DEVANAGARI SIGN ANUSVARA -->
+ U+094C/U+0902: "ौं" DEVANAGARI VOWEL SIGN AU/DEVANAGARI SIGN ANUSVARA -->
<key-style
latin:styleName="moreKeysDevanagariVowelSignAu"
latin:moreKeys="◌ौं|ौं,%" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+094C: "ौ" DEVANAGARI VOWEL SIGN AU -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignAu"
+ latin:moreKeys="◌ौ|ौ,%" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignAu" />
diff --git a/java/res/xml/key_devanagari_sign_candrabindu.xml b/java/res/xml/keystyle_devanagari_vowel_sign_candra_e.xml
similarity index 73%
copy from java/res/xml/key_devanagari_sign_candrabindu.xml
copy to java/res/xml/keystyle_devanagari_vowel_sign_candra_e.xml
index 9e9c371..86f68d3 100644
--- a/java/res/xml/key_devanagari_sign_candrabindu.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_candra_e.xml
@@ -2,7 +2,7 @@
<!--
/*
**
-** Copyright 2013, The Android Open Source Project
+** Copyright 2014, 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.
@@ -27,23 +27,17 @@
>
<switch>
<case
- latin:keyboardLayoutSet="hindi"
+ latin:keyboardLayoutSet="hindi_compact"
>
<!-- U+25CC: "◌" DOTTED CIRCLE
U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E -->
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu"
+ latin:styleName="moreKeysDevanagariVowelSignCandraE"
latin:moreKeys="◌ॅ|ॅ" />
</case>
<default>
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu" />
+ latin:styleName="moreKeysDevanagariVowelSignCandraE" />
</default>
</switch>
- <!-- U+25CC: "◌" DOTTED CIRCLE
- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignCandrabindu"
- latin:keySpec="◌ँ|ँ"
- latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
</merge>
diff --git a/java/res/xml/key_devanagari_sign_candrabindu.xml b/java/res/xml/keystyle_devanagari_vowel_sign_candra_o.xml
similarity index 71%
copy from java/res/xml/key_devanagari_sign_candrabindu.xml
copy to java/res/xml/keystyle_devanagari_vowel_sign_candra_o.xml
index 9e9c371..fd711e0 100644
--- a/java/res/xml/key_devanagari_sign_candrabindu.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_candra_o.xml
@@ -27,23 +27,24 @@
>
<switch>
<case
- latin:keyboardLayoutSet="hindi"
+ latin:keyboardLayoutSet="hindi_compact"
>
<!-- U+25CC: "◌" DOTTED CIRCLE
- U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E -->
+ U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O -->
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu"
- latin:moreKeys="◌ॅ|ॅ" />
+ latin:styleName="moreKeysDevanagariVowelSignCandraO"
+ latin:moreKeys="◌ॉ|ॉ" />
</case>
<default>
<key-style
- latin:styleName="moreKeysDevanagariSignCandrabindu" />
+ latin:styleName="moreKeysDevanagariVowelSignCandraO" />
</default>
</switch>
<!-- U+25CC: "◌" DOTTED CIRCLE
- U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU -->
- <Key
- latin:keyStyle="moreKeysDevanagariSignCandrabindu"
- latin:keySpec="◌ँ|ँ"
+ U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O -->
+ <key-style
+ latin:styleName="baseKeyDevanagariVowelSignCandraO"
+ latin:parentStyle="moreKeysDevanagariVowelSignCandraO"
+ latin:keySpec="◌ॉ|ॉ"
latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
</merge>
diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_e.xml b/java/res/xml/keystyle_devanagari_vowel_sign_e.xml
index de1d949..88f6a74 100644
--- a/java/res/xml/keystyle_devanagari_vowel_sign_e.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_e.xml
@@ -36,6 +36,15 @@
latin:moreKeys="◌ें|ें" />
</case>
<case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+0947: "े" DEVANAGARI VOWEL SIGN E -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignE"
+ latin:moreKeys="◌े|े" />
+ </case>
+ <case
latin:keyboardLayoutSet="nepali_traditional"
>
<!-- U+25CC: "◌" DOTTED CIRCLE
diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_i.xml b/java/res/xml/keystyle_devanagari_vowel_sign_i.xml
index d1d56c1..a84fdb4 100644
--- a/java/res/xml/keystyle_devanagari_vowel_sign_i.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_i.xml
@@ -35,6 +35,15 @@
latin:styleName="moreKeysDevanagariVowelSignI"
latin:moreKeys="ि◌ं|िं" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+093F: "ि" DEVANAGARI VOWEL SIGN I -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignI"
+ latin:moreKeys="◌ि|ि" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignI" />
diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml b/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml
index fd0ce77..6f6eb0f 100644
--- a/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml
@@ -29,12 +29,21 @@
<case
latin:keyboardLayoutSet="hindi"
>
- <!-- U+0940: "ी" DEVANAGARI VOWEL SIGN II
+ <!-- U+25CC: "◌" DOTTED CIRCLE
U+0940/U+0902: "ीं" DEVANAGARI VOWEL SIGN II/DEVANAGARI SIGN ANUSVARA -->
<key-style
latin:styleName="moreKeysDevanagariVowelSignIi"
latin:moreKeys="◌ीं|ीं,%" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+0940: "ी" DEVANAGARI VOWEL SIGN II -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignIi"
+ latin:moreKeys="◌ी|ी,%" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignIi" />
diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_o.xml b/java/res/xml/keystyle_devanagari_vowel_sign_o.xml
index edc3bef..68b176a 100644
--- a/java/res/xml/keystyle_devanagari_vowel_sign_o.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_o.xml
@@ -30,13 +30,22 @@
latin:keyboardLayoutSet="hindi"
>
<!-- U+25CC: "◌" DOTTED CIRCLE
- U+094B/U+0902: "қं" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA
+ U+094B/U+0902: "ों" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA
U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O
U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O -->
<key-style
latin:styleName="moreKeysDevanagariVowelSignO"
latin:moreKeys="◌ों|ों,◌ॉ|ॉ,◌ॊ|ॊ" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+094B: "ो" DEVANAGARI VOWEL SIGN O -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignO"
+ latin:moreKeys="◌ो|ो" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignO" />
diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_u.xml b/java/res/xml/keystyle_devanagari_vowel_sign_u.xml
index c7de4fd..7c058b1 100644
--- a/java/res/xml/keystyle_devanagari_vowel_sign_u.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_u.xml
@@ -36,6 +36,15 @@
latin:styleName="moreKeysDevanagariVowelSignU"
latin:moreKeys="◌ुं|ुं,◌ुँ|ुँ" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+0941: "ु" DEVANAGARI VOWEL SIGN U -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignU"
+ latin:moreKeys="◌ु|ु" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignU" />
diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml b/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml
index 6029d6d..73ab63c 100644
--- a/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml
@@ -36,6 +36,15 @@
latin:styleName="moreKeysDevanagariVowelSignUu"
latin:moreKeys="◌ूं|ूं,◌ूँ|ूँ,%" />
</case>
+ <case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+25CC: "◌" DOTTED CIRCLE
+ U+0942: "ू" DEVANAGARI VOWEL SIGN UU -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignUu"
+ latin:moreKeys="◌ू|ू,%" />
+ </case>
<default>
<key-style
latin:styleName="moreKeysDevanagariVowelSignUu" />
diff --git a/java/res/xml/key_devanagari_vowel_sign_vocalic_r.xml b/java/res/xml/keystyle_devanagari_vowel_sign_vocalic_r.xml
similarity index 79%
rename from java/res/xml/key_devanagari_vowel_sign_vocalic_r.xml
rename to java/res/xml/keystyle_devanagari_vowel_sign_vocalic_r.xml
index badea3e..29b083e 100644
--- a/java/res/xml/key_devanagari_vowel_sign_vocalic_r.xml
+++ b/java/res/xml/keystyle_devanagari_vowel_sign_vocalic_r.xml
@@ -36,6 +36,16 @@
latin:moreKeys="◌ॄ|ॄ" />
</case>
<case
+ latin:keyboardLayoutSet="hindi_compact"
+ >
+ <!-- U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R
+ U+25CC: "◌" DOTTED CIRCLE
+ U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R -->
+ <key-style
+ latin:styleName="moreKeysDevanagariVowelSignVocalicR"
+ latin:moreKeys="ऋ,◌ृ|ृ" />
+ </case>
+ <case
latin:keyboardLayoutSet="nepali_traditional"
>
<!-- U+0913: "ओ" DEVANAGARI LETTER O -->
@@ -50,8 +60,9 @@
</switch>
<!-- U+25CC: "◌" DOTTED CIRCLE
U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R -->
- <Key
- latin:keyStyle="moreKeysDevanagariVowelSignVocalicR"
+ <key-style
+ latin:styleName="baseKeyDevanagariVowelSignVocalicR"
+ latin:parentStyle="moreKeysDevanagariVowelSignVocalicR"
latin:keySpec="◌ृ|ृ"
latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
</merge>
diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml
index c64b3a4..ee1b54b 100644
--- a/java/res/xml/method.xml
+++ b/java/res/xml/method.xml
@@ -49,6 +49,7 @@
fr_CH: French (Switzerland)/swiss
gl_ES: Galician (Spain)/spanish
hi: Hindi/hindi
+ hi: Hindi/hindi_compact
hr: Croatian/qwertz
hu: Hungarian/qwertz
hy_AM: Armenian (Armenia) Phonetic/armenian_phonetic
@@ -321,6 +322,14 @@
android:isAsciiCapable="false"
/>
<subtype android:icon="@drawable/ic_ime_switcher_dark"
+ android:label="@string/subtype_generic_compact"
+ android:subtypeId="0xe49c89a1"
+ android:imeSubtypeLocale="hi"
+ android:imeSubtypeMode="keyboard"
+ android:imeSubtypeExtraValue="KeyboardLayoutSet=hindi_compact,EmojiCapable"
+ android:isAsciiCapable="false"
+ />
+ <subtype android:icon="@drawable/ic_ime_switcher_dark"
android:label="@string/subtype_generic"
android:subtypeId="0x35b7526a"
android:imeSubtypeLocale="hr"
@@ -485,7 +494,7 @@
android:isAsciiCapable="false"
/>
<subtype android:icon="@drawable/ic_ime_switcher_dark"
- android:label="@string/subtype_nepali_traditional"
+ android:label="@string/subtype_generic_traditional"
android:subtypeId="0x5fafea88"
android:imeSubtypeLocale="ne_NP"
android:imeSubtypeMode="keyboard"
diff --git a/java/res/xml/rowkeys_hindi1.xml b/java/res/xml/rowkeys_hindi1.xml
index 5d696b3..cff9756 100644
--- a/java/res/xml/rowkeys_hindi1.xml
+++ b/java/res/xml/rowkeys_hindi1.xml
@@ -92,9 +92,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+0967: "१" DEVANAGARI DIGIT ONE -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_au" />
+ <!-- U+0967: "१" DEVANAGARI DIGIT ONE -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignAu"
latin:keyHintLabel="1"
@@ -102,9 +102,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+0968: "२" DEVANAGARI DIGIT TWO -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_ai" />
+ <!-- U+0968: "२" DEVANAGARI DIGIT TWO -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignAi"
latin:keyHintLabel="2"
@@ -112,9 +112,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+0969: "३" DEVANAGARI DIGIT THREE -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_aa" />
+ <!-- U+0969: "३" DEVANAGARI DIGIT THREE -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignAa"
latin:keyHintLabel="3"
@@ -122,9 +122,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+096A: "४" DEVANAGARI DIGIT FOUR -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_ii" />
+ <!-- U+096A: "४" DEVANAGARI DIGIT FOUR -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignIi"
latin:keyHintLabel="4"
@@ -132,9 +132,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+096B: "५" DEVANAGARI DIGIT FIVE -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_uu" />
+ <!-- U+096B: "५" DEVANAGARI DIGIT FIVE -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignUu"
latin:keyHintLabel="5"
diff --git a/java/res/xml/rowkeys_hindi3.xml b/java/res/xml/rowkeys_hindi3.xml
index a9be472..cf36fc5 100644
--- a/java/res/xml/rowkeys_hindi3.xml
+++ b/java/res/xml/rowkeys_hindi3.xml
@@ -33,7 +33,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_sign_candrabindu" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_candrabindu" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariSignCandrabindu" />
<!-- U+0923: "ण" DEVANAGARI LETTER NNA -->
<Key
latin:keySpec="ण"
@@ -59,7 +61,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_vowel_sign_vocalic_r" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_vocalic_r" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariVowelSignVocalicR" />
<!-- U+091E: "ञ" DEVANAGARI LETTER NYA -->
<Key
latin:keySpec="ञ"
@@ -70,9 +74,16 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_vowel_sign_candra_o" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_candra_o" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariVowelSignCandraO" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_sign_anusvara" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariSignAnusvara" />
<!-- U+092E: "म" DEVANAGARI LETTER MA
U+0950: "ॐ" DEVANAGARI OM -->
<Key
@@ -112,7 +123,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_sign_nukta" />
- </default>
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_nukta" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariSignNukta" />
+ </default>
</switch>
</merge>
diff --git a/java/res/xml/rowkeys_hindi_compact1.xml b/java/res/xml/rowkeys_hindi_compact1.xml
new file mode 100644
index 0000000..c63de4f
--- /dev/null
+++ b/java/res/xml/rowkeys_hindi_compact1.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2014, 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"
+>
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_au" />
+ <!-- U+0914: "औ" DEVANAGARI LETTER AU
+ U+0967: "१" DEVANAGARI DIGIT ONE -->
+ <Key
+ latin:keySpec="औ"
+ latin:keyStyle="moreKeysDevanagariVowelSignAu"
+ latin:keyHintLabel="1"
+ latin:additionalMoreKeys="१,1"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_ai" />
+ <!-- U+0910: "ऐ" DEVANAGARI LETTER AI
+ U+0968: "२" DEVANAGARI DIGIT TWO -->
+ <Key
+ latin:keySpec="ऐ"
+ latin:keyStyle="moreKeysDevanagariVowelSignAi"
+ latin:keyHintLabel="2"
+ latin:additionalMoreKeys="२,2"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_aa" />
+ <!-- U+0906: "आ" DEVANAGARI LETTER AA
+ U+0969: "३" DEVANAGARI DIGIT THREE -->
+ <Key
+ latin:keySpec="आ"
+ latin:keyStyle="moreKeysDevanagariVowelSignAa"
+ latin:keyHintLabel="3"
+ latin:additionalMoreKeys="३,3"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_ii" />
+ <!-- U+0908: "ई" DEVANAGARI LETTER II
+ U+096A: "४" DEVANAGARI DIGIT FOUR -->
+ <Key
+ latin:keySpec="ई"
+ latin:keyStyle="moreKeysDevanagariVowelSignIi"
+ latin:keyHintLabel="4"
+ latin:additionalMoreKeys="४,4"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_uu" />
+ <!-- U+090A: "ऊ" DEVANAGARI LETTER UU
+ U+096B: "५" DEVANAGARI DIGIT FIVE -->
+ <Key
+ latin:keySpec="ऊ"
+ latin:keyStyle="moreKeysDevanagariVowelSignUu"
+ latin:keyHintLabel="5"
+ latin:additionalMoreKeys="५,5"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+092C: "ब" DEVANAGARI LETTER BA
+ U+092D: "भ" DEVANAGARI LETTER BHA
+ U+096C: "६" DEVANAGARI DIGIT SIX -->
+ <Key
+ latin:keySpec="ब"
+ latin:moreKeys="भ,%"
+ latin:keyHintLabel="6"
+ latin:additionalMoreKeys="६,6"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0939: "ह" DEVANAGARI LETTER HA
+ U+096D: "७" DEVANAGARI DIGIT SEVEN -->
+ <Key
+ latin:keySpec="ह"
+ latin:keyHintLabel="7"
+ latin:additionalMoreKeys="७,7"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0917: "ग" DEVANAGARI LETTER GA
+ U+0918: "घ" DEVANAGARI LETTER GHA
+ U+096E: "८" DEVANAGARI DIGIT EIGHT -->
+ <Key
+ latin:keySpec="ग"
+ latin:moreKeys="घ,%"
+ latin:keyHintLabel="8"
+ latin:additionalMoreKeys="८,8"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0926: "द" DEVANAGARI LETTER DA
+ U+0927: "ध" DEVANAGARI LETTER DHA
+ U+096F: "९" DEVANAGARI DIGIT NINE -->
+ <Key
+ latin:keySpec="द"
+ latin:moreKeys="ध,%"
+ latin:keyHintLabel="9"
+ latin:additionalMoreKeys="९,9"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+091C: "ज" DEVANAGARI LETTER JA
+ U+091D: "झ" DEVANAGARI LETTER JHA
+ U+091C/U+094D/U+091E: "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA
+ U+0966: "०" DEVANAGARI DIGIT ZERO -->
+ <Key
+ latin:keySpec="ज"
+ latin:moreKeys="झ,ज्ञ,%"
+ latin:keyHintLabel="0"
+ latin:additionalMoreKeys="०,0"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0921: "ड" DEVANAGARI LETTER DDA
+ U+0922: "ढ" DEVANAGARI LETTER DDHA -->
+ <Key
+ latin:keySpec="ड"
+ latin:moreKeys="ढ"
+ latin:keyLabelFlags="fontNormal" />
+</merge>
diff --git a/java/res/xml/rowkeys_hindi_compact2.xml b/java/res/xml/rowkeys_hindi_compact2.xml
new file mode 100644
index 0000000..06364c2
--- /dev/null
+++ b/java/res/xml/rowkeys_hindi_compact2.xml
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2014, 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"
+>
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_o" />
+ <!-- U+0913: "ओ" DEVANAGARI LETTER O -->
+ <Key
+ latin:keySpec="ओ"
+ latin:keyStyle="moreKeysDevanagariVowelSignO"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_e" />
+ <!-- U+090F: "ए" DEVANAGARI LETTER E -->
+ <Key
+ latin:keySpec="ए"
+ latin:keyStyle="moreKeysDevanagariVowelSignE"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_virama" />
+ <!-- U+0905: "अ" DEVANAGARI LETTER A -->
+ <Key
+ latin:keySpec="अ"
+ latin:keyStyle="moreKeysDevanagariSignVirama"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_i" />
+ <!-- U+0907: "इ" DEVANAGARI LETTER I -->
+ <Key
+ latin:keySpec="इ"
+ latin:keyStyle="moreKeysDevanagariVowelSignI"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_u" />
+ <!-- U+0909: "उ" DEVANAGARI LETTER U -->
+ <Key
+ latin:keySpec="उ"
+ latin:keyStyle="moreKeysDevanagariVowelSignU"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+092A: "प" DEVANAGARI LETTER PA
+ U+092B: "फ" DEVANAGARI LETTER PHA -->
+ <Key
+ latin:keySpec="प"
+ latin:moreKeys="फ"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_vocalic_r" />
+ <!-- U+0930: "र" DEVANAGARI LETTER RA -->
+ <Key
+ latin:keySpec="र"
+ latin:keyStyle="moreKeysDevanagariVowelSignVocalicR"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0915: "क" DEVANAGARI LETTER KA
+ U+0916: "ख" DEVANAGARI LETTER KHA -->
+ <Key
+ latin:keySpec="क"
+ latin:moreKeys="ख"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0924: "त" DEVANAGARI LETTER TA
+ U+0925: "थ" DEVANAGARI LETTER THA
+ U+0924/U+094D/U+0930: "त्र" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA -->
+ <Key
+ latin:keySpec="त"
+ latin:moreKeys="थ,त्र"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+091A: "च" DEVANAGARI LETTER CA
+ U+091B: "छ" DEVANAGARI LETTER CHA -->
+ <Key
+ latin:keySpec="च"
+ latin:moreKeys="छ"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+091F: "ट" DEVANAGARI LETTER TTA
+ U+0920: "ठ" DEVANAGARI LETTER TTHA -->
+ <Key
+ latin:keySpec="ट"
+ latin:moreKeys="ठ"
+ latin:keyLabelFlags="fontNormal" />
+</merge>
diff --git a/java/res/xml/rowkeys_hindi_compact3.xml b/java/res/xml/rowkeys_hindi_compact3.xml
new file mode 100644
index 0000000..0e8165e
--- /dev/null
+++ b/java/res/xml/rowkeys_hindi_compact3.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2014, 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"
+>
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_candra_o" />
+ <!-- U+0911: "ऑ" DEVANAGARI LETTER CANDRA O -->
+ <Key
+ latin:keySpec="ऑ"
+ latin:keyStyle="moreKeysDevanagariVowelSignCandraO"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_candra_e" />
+ <!-- U+090D: "ऍ" DEVANAGARI LETTER CANDRA E -->
+ <Key
+ latin:keySpec="ऍ"
+ latin:keyStyle="moreKeysDevanagariVowelSignCandraE"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariSignAnusvara" />
+ <!-- U+092E: "म" DEVANAGARI LETTER MA
+ U+0950: "ॐ" DEVANAGARI OM -->
+ <Key
+ latin:keySpec="म"
+ latin:moreKeys="ॐ"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0928: "न" DEVANAGARI LETTER NA
+ U+0923: "ण" DEVANAGARI LETTER NNA
+ U+091E: "ञ" DEVANAGARI LETTER NYA
+ U+0919: "ङ" DEVANAGARI LETTER NGA -->
+ <Key
+ latin:keySpec="न"
+ latin:moreKeys="ण,ञ,ङ"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0935: "व" DEVANAGARI LETTER VA -->
+ <Key
+ latin:keySpec="व"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0932: "ल" DEVANAGARI LETTER LA -->
+ <Key
+ latin:keySpec="ल"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0938: "स" DEVANAGARI LETTER SA
+ U+0936: "श" DEVANAGARI LETTER SHA
+ U+0937: "ष" DEVANAGARI LETTER SSA
+ U+0936/U+094D/U+0930: "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA -->
+ <Key
+ latin:keySpec="स"
+ latin:moreKeys="श,ष,श्र"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+092F: "य" DEVANAGARI LETTER YA -->
+ <Key
+ latin:keySpec="य"
+ latin:keyLabelFlags="fontNormal" />
+ <!-- U+0915/U+094D/U+0937: "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA -->
+ <Key
+ latin:keySpec="क्ष"
+ latin:keyLabelFlags="fontNormal|followKeyLetterRatio" />
+</merge>
diff --git a/java/res/xml/rowkeys_nepali_romanized1.xml b/java/res/xml/rowkeys_nepali_romanized1.xml
index 3c082c2..616b259 100644
--- a/java/res/xml/rowkeys_nepali_romanized1.xml
+++ b/java/res/xml/rowkeys_nepali_romanized1.xml
@@ -44,7 +44,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_vowel_sign_vocalic_r" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_vocalic_r" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariVowelSignVocalicR" />
<!-- U+0925: "थ" DEVANAGARI LETTER THA -->
<Key
latin:keySpec="थ"
@@ -81,21 +83,25 @@
latin:keyLabelFlags="fontNormal" />
</case>
<default>
+ <!-- Because the font rendering system prior to API version 16 can't automatically
+ render dotted circle for incomplete combining letter of some scripts, different
+ set of Key definitions are needed based on the API version. -->
+ <include
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_nukta" />
<!-- U+091F: "ट" DEVANAGARI LETTER TTA
- U+0967: "१" DEVANAGARI DIGIT ONE
- U+093C: "़" DEVANAGARI SIGN NUKTA -->
+ U+0967: "१" DEVANAGARI DIGIT ONE -->
<Key
latin:keySpec="ट"
latin:keyHintLabel="1"
latin:additionalMoreKeys="१,1"
- latin:moreKeys="़"
+ latin:keyStyle="moreKeysDevanagariSignNukta"
latin:keyLabelFlags="fontNormal" />
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+0968: "२" DEVANAGARI DIGIT TWO -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_au" />
+ <!-- U+0968: "२" DEVANAGARI DIGIT TWO -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignAu"
latin:keyHintLabel="2"
@@ -103,9 +109,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+0969: "३" DEVANAGARI DIGIT THREE -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_e" />
+ <!-- U+0969: "३" DEVANAGARI DIGIT THREE -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignE"
latin:keyHintLabel="3"
@@ -134,9 +140,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+096D: "७" DEVANAGARI DIGIT SEVEN -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_u" />
+ <!-- U+096D: "७" DEVANAGARI DIGIT SEVEN -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignU"
latin:keyHintLabel="7"
@@ -144,9 +150,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+096E: "८" DEVANAGARI DIGIT EIGHT -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_i" />
+ <!-- U+096E: "८" DEVANAGARI DIGIT EIGHT -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignI"
latin:keyHintLabel="8"
@@ -154,9 +160,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+096F: "९" DEVANAGARI DIGIT NINE -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_o" />
+ <!-- U+096F: "९" DEVANAGARI DIGIT NINE -->
<Key
latin:keyStyle="baseKeyDevanagariVowelSignO"
latin:keyHintLabel="9"
diff --git a/java/res/xml/rowkeys_nepali_romanized3.xml b/java/res/xml/rowkeys_nepali_romanized3.xml
index 232d96e..cc2ca8c 100644
--- a/java/res/xml/rowkeys_nepali_romanized3.xml
+++ b/java/res/xml/rowkeys_nepali_romanized3.xml
@@ -41,7 +41,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_sign_candrabindu" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_candrabindu" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariSignCandrabindu" />
<!-- U+092D: "भ" DEVANAGARI LETTER BHA -->
<Key
latin:keySpec="भ"
@@ -54,7 +56,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_sign_anusvara" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariSignAnusvara" />
<!-- U+0919: "ङ" DEVANAGARI LETTER NGA -->
<Key
latin:keySpec="ङ"
diff --git a/java/res/xml/rowkeys_nepali_traditional1.xml b/java/res/xml/rowkeys_nepali_traditional1.xml
index 98a7be2..cf4bda9 100644
--- a/java/res/xml/rowkeys_nepali_traditional1.xml
+++ b/java/res/xml/rowkeys_nepali_traditional1.xml
@@ -91,7 +91,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_vowel_sign_vocalic_r" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_vowel_sign_vocalic_r" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariVowelSignVocalicR" />
</case>
<default>
<!-- U+091F: "ट" DEVANAGARI LETTER TTA
diff --git a/java/res/xml/rowkeys_nepali_traditional2.xml b/java/res/xml/rowkeys_nepali_traditional2.xml
index 5ea14ea..58a463e 100644
--- a/java/res/xml/rowkeys_nepali_traditional2.xml
+++ b/java/res/xml/rowkeys_nepali_traditional2.xml
@@ -41,7 +41,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_sign_candrabindu" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_candrabindu" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariSignCandrabindu" />
<!-- U+0926/U+094D/U+0926: "द्द" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DA -->
<Key
latin:keySpec="द्द"
diff --git a/java/res/xml/rowkeys_nepali_traditional3_right3.xml b/java/res/xml/rowkeys_nepali_traditional3_right3.xml
index d6a74d4..3e6187d 100644
--- a/java/res/xml/rowkeys_nepali_traditional3_right3.xml
+++ b/java/res/xml/rowkeys_nepali_traditional3_right3.xml
@@ -29,7 +29,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_sign_anusvara" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariSignAnusvara" />
<!-- U+0919: "ङ" DEVANAGARI LETTER NGA -->
<Key
latin:keySpec="ङ"
@@ -54,8 +56,8 @@
<Key
latin:keySpec="।"
latin:keyLabelFlags="fontNormal" />
- <!-- U+0930: "र" DEVANAGARI LETTER RA
- U+0930/U+0941: "रु" DEVANAGARI LETTER RA/DEVANAGARI VOWEL SIGN U -->
+ <!-- U+0930: "र" DEVANAGARI LETTER RA
+ U+0930/U+0941: "रु" DEVANAGARI LETTER RA/DEVANAGARI VOWEL SIGN U -->
<Key
latin:keySpec="र"
latin:moreKeys="रु"
diff --git a/java/res/xml/rowkeys_nepali_traditional3_right5.xml b/java/res/xml/rowkeys_nepali_traditional3_right5.xml
index a34f400..89d5aa4 100644
--- a/java/res/xml/rowkeys_nepali_traditional3_right5.xml
+++ b/java/res/xml/rowkeys_nepali_traditional3_right5.xml
@@ -29,7 +29,9 @@
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
<include
- latin:keyboardLayout="@xml/key_devanagari_sign_anusvara" />
+ latin:keyboardLayout="@xml/keystyle_devanagari_sign_anusvara" />
+ <Key
+ latin:keyStyle="baseKeyDevanagariSignAnusvara" />
<!-- U+0919: "ङ" DEVANAGARI LETTER NGA -->
<Key
latin:keySpec="ङ"
@@ -53,9 +55,9 @@
<!-- Because the font rendering system prior to API version 16 can't automatically
render dotted circle for incomplete combining letter of some scripts, different
set of Key definitions are needed based on the API version. -->
- <!-- U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA -->
<include
latin:keyboardLayout="@xml/keystyle_devanagari_sign_visarga" />
+ <!-- U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA -->
<Key
latin:keyStyle="baseKeyDevanagariSignVisarga"
latin:moreKeys="ऽ" />
diff --git a/java/res/xml/rows_hindi_compact.xml b/java/res/xml/rows_hindi_compact.xml
new file mode 100644
index 0000000..a60cf2b
--- /dev/null
+++ b/java/res/xml/rows_hindi_compact.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2014, 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_hindi_compact1" />
+ </Row>
+ <Row
+ latin:keyWidth="9.091%p"
+ >
+ <include
+ latin:keyboardLayout="@xml/rowkeys_hindi_compact2" />
+ </Row>
+ <Row
+ latin:keyWidth="9.091%p"
+ >
+ <include
+ latin:keyboardLayout="@xml/rowkeys_hindi_compact3" />
+ <Key
+ latin:keyStyle="deleteKeyStyle"
+ latin:keyWidth="fillRight" />
+ </Row>
+ <include
+ latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>
diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java
index 6465909..6535d2d 100644
--- a/java/src/com/android/inputmethod/event/Event.java
+++ b/java/src/com/android/inputmethod/event/Event.java
@@ -36,25 +36,25 @@
// Should the types below be represented by separate classes instead? It would be cleaner
// but probably a bit too much
// An event we don't handle in Latin IME, for example pressing Ctrl on a hardware keyboard.
- final public static int EVENT_NOT_HANDLED = 0;
+ final public static int EVENT_TYPE_NOT_HANDLED = 0;
// A key press that is part of input, for example pressing an alphabetic character on a
// hardware qwerty keyboard. It may be part of a sequence that will be re-interpreted later
// through combination.
- final public static int EVENT_INPUT_KEYPRESS = 1;
+ final public static int EVENT_TYPE_INPUT_KEYPRESS = 1;
// A toggle event is triggered by a key that affects the previous character. An example would
// be a numeric key on a 10-key keyboard, which would toggle between 1 - a - b - c with
// repeated presses.
- final public static int EVENT_TOGGLE = 2;
+ final public static int EVENT_TYPE_TOGGLE = 2;
// A mode event instructs the combiner to change modes. The canonical example would be the
// hankaku/zenkaku key on a Japanese keyboard, or even the caps lock key on a qwerty keyboard
// if handled at the combiner level.
- final public static int EVENT_MODE_KEY = 3;
+ final public static int EVENT_TYPE_MODE_KEY = 3;
// An event corresponding to a gesture.
- final public static int EVENT_GESTURE = 4;
+ final public static int EVENT_TYPE_GESTURE = 4;
// An event corresponding to the manual pick of a suggestion.
- final public static int EVENT_SUGGESTION_PICKED = 5;
+ final public static int EVENT_TYPE_SUGGESTION_PICKED = 5;
// An event corresponding to a string generated by some software process.
- final public static int EVENT_SOFTWARE_GENERATED_STRING = 6;
+ final public static int EVENT_TYPE_SOFTWARE_GENERATED_STRING = 6;
// 0 is a valid code point, so we use -1 here.
final public static int NOT_A_CODE_POINT = -1;
@@ -66,7 +66,7 @@
// or dead-abovering.
final private static int FLAG_DEAD = 0x1;
- final private int mType; // The type of event - one of the constants above
+ final private int mEventType; // The type of event - one of the constants above
// The code point associated with the event, if relevant. This is a unicode code point, and
// has nothing to do with other representations of the key. It is only relevant if this event
// is of KEYPRESS type, but for a mode key like hankaku/zenkaku or ctrl, there is no code point
@@ -94,7 +94,7 @@
// Some flags that can't go into the key code. It's a bit field of FLAG_*
final private int mFlags;
- // If this is of type EVENT_SUGGESTION_PICKED, this must not be null (and must be null in
+ // If this is of type EVENT_TYPE_SUGGESTION_PICKED, this must not be null (and must be null in
// other cases).
final public SuggestedWordInfo mSuggestedWordInfo;
@@ -105,7 +105,7 @@
private Event(final int type, final CharSequence text, final int codePoint, final int keyCode,
final int x, final int y, final SuggestedWordInfo suggestedWordInfo, final int flags,
final Event next) {
- mType = type;
+ mEventType = type;
mText = text;
mCodePoint = codePoint;
mKeyCode = keyCode;
@@ -116,7 +116,7 @@
mNextEvent = next;
// Sanity checks
// mSuggestedWordInfo is non-null if and only if the type is SUGGESTION_PICKED
- if (EVENT_SUGGESTION_PICKED == mType) {
+ if (EVENT_TYPE_SUGGESTION_PICKED == mEventType) {
if (null == mSuggestedWordInfo) {
throw new RuntimeException("Wrong event: SUGGESTION_PICKED event must have a "
+ "non-null SuggestedWordInfo");
@@ -131,13 +131,13 @@
public static Event createSoftwareKeypressEvent(final int codePoint, final int keyCode,
final int x, final int y) {
- return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, x, y,
- null /* suggestedWordInfo */, FLAG_NONE, null);
+ return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode, x, y,
+ null /* suggestedWordInfo */, FLAG_NONE, null /* next */);
}
public static Event createHardwareKeypressEvent(final int codePoint, final int keyCode,
final Event next) {
- return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, keyCode,
+ return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode,
Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE,
null /* suggestedWordInfo */, FLAG_NONE, next);
}
@@ -145,7 +145,7 @@
// This creates an input event for a dead character. @see {@link #FLAG_DEAD}
public static Event createDeadEvent(final int codePoint, final int keyCode, final Event next) {
// TODO: add an argument or something if we ever create a software layout with dead keys.
- return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, keyCode,
+ return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, keyCode,
Constants.EXTERNAL_KEYBOARD_COORDINATE, Constants.EXTERNAL_KEYBOARD_COORDINATE,
null /* suggestedWordInfo */, FLAG_DEAD, next);
}
@@ -159,7 +159,7 @@
*/
public static Event createEventForCodePointFromUnknownSource(final int codePoint) {
// TODO: should we have a different type of event for this? After all, it's not a key press.
- return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, NOT_A_KEY_CODE,
+ return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, NOT_A_KEY_CODE,
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE,
null /* suggestedWordInfo */, FLAG_NONE, null /* next */);
}
@@ -175,8 +175,8 @@
public static Event createEventForCodePointFromAlreadyTypedText(final int codePoint,
final int x, final int y) {
// TODO: should we have a different type of event for this? After all, it's not a key press.
- return new Event(EVENT_INPUT_KEYPRESS, null /* text */, codePoint, NOT_A_KEY_CODE, x, y,
- null /* suggestedWordInfo */, FLAG_NONE, null /* next */);
+ return new Event(EVENT_TYPE_INPUT_KEYPRESS, null /* text */, codePoint, NOT_A_KEY_CODE,
+ x, y, null /* suggestedWordInfo */, FLAG_NONE, null /* next */);
}
/**
@@ -184,10 +184,10 @@
* @return an event for this suggestion pick.
*/
public static Event createSuggestionPickedEvent(final SuggestedWordInfo suggestedWordInfo) {
- return new Event(EVENT_SUGGESTION_PICKED, suggestedWordInfo.mWord,
+ return new Event(EVENT_TYPE_SUGGESTION_PICKED, suggestedWordInfo.mWord,
NOT_A_CODE_POINT, NOT_A_KEY_CODE,
Constants.SUGGESTION_STRIP_COORDINATE, Constants.SUGGESTION_STRIP_COORDINATE,
- suggestedWordInfo, FLAG_NONE, null);
+ suggestedWordInfo, FLAG_NONE, null /* next */);
}
/**
@@ -199,13 +199,26 @@
* @return an event for this text.
*/
public static Event createSoftwareTextEvent(final CharSequence text, final int keyCode) {
- return new Event(EVENT_SOFTWARE_GENERATED_STRING, text, NOT_A_CODE_POINT, keyCode,
+ return new Event(EVENT_TYPE_SOFTWARE_GENERATED_STRING, text, NOT_A_CODE_POINT, keyCode,
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE,
null /* suggestedWordInfo */, FLAG_NONE, null /* next */);
}
+ /**
+ * Creates an input event representing the manual pick of a punctuation suggestion.
+ * @return an event for this suggestion pick.
+ */
+ public static Event createPunctuationSuggestionPickedEvent(
+ final SuggestedWordInfo suggestedWordInfo) {
+ final int primaryCode = suggestedWordInfo.mWord.charAt(0);
+ return new Event(EVENT_TYPE_SUGGESTION_PICKED, suggestedWordInfo.mWord, primaryCode,
+ NOT_A_KEY_CODE, Constants.SUGGESTION_STRIP_COORDINATE,
+ Constants.SUGGESTION_STRIP_COORDINATE, suggestedWordInfo, FLAG_NONE,
+ null /* next */);
+ }
+
public static Event createNotHandledEvent() {
- return new Event(EVENT_NOT_HANDLED, null /* text */, NOT_A_CODE_POINT, NOT_A_KEY_CODE,
+ return new Event(EVENT_TYPE_NOT_HANDLED, null /* text */, NOT_A_CODE_POINT, NOT_A_KEY_CODE,
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE,
null /* suggestedWordInfo */, FLAG_NONE, null);
}
@@ -218,25 +231,26 @@
// Returns whether this is a fake key press from the suggestion strip. This happens with
// punctuation signs selected from the suggestion strip.
public boolean isSuggestionStripPress() {
- return EVENT_INPUT_KEYPRESS == mType && Constants.SUGGESTION_STRIP_COORDINATE == mX;
+ return EVENT_TYPE_SUGGESTION_PICKED == mEventType;
}
public boolean isHandled() {
- return EVENT_NOT_HANDLED != mType;
+ return EVENT_TYPE_NOT_HANDLED != mEventType;
}
public CharSequence getTextToCommit() {
- switch (mType) {
- case EVENT_MODE_KEY:
- case EVENT_NOT_HANDLED:
- case EVENT_TOGGLE:
+ switch (mEventType) {
+ case EVENT_TYPE_MODE_KEY:
+ case EVENT_TYPE_NOT_HANDLED:
+ case EVENT_TYPE_TOGGLE:
return "";
- case EVENT_INPUT_KEYPRESS:
+ case EVENT_TYPE_INPUT_KEYPRESS:
return StringUtils.newSingleCodePointString(mCodePoint);
- case EVENT_GESTURE:
- case EVENT_SOFTWARE_GENERATED_STRING:
+ case EVENT_TYPE_GESTURE:
+ case EVENT_TYPE_SOFTWARE_GENERATED_STRING:
+ case EVENT_TYPE_SUGGESTION_PICKED:
return mText;
}
- throw new RuntimeException("Unknown event type: " + mType);
+ throw new RuntimeException("Unknown event type: " + mEventType);
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 37a4bf8..fd0be6f 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -204,10 +204,12 @@
keyboardView.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
final boolean subtypeChanged = (oldKeyboard == null)
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
- final boolean needsToDisplayLanguage = mSubtypeSwitcher.needsToDisplayLanguage(
+ final int languageOnSpacebarFormatType = mSubtypeSwitcher.getLanguageOnSpacebarFormatType(
keyboard.mId.mSubtype);
- keyboardView.startDisplayLanguageOnSpacebar(subtypeChanged, needsToDisplayLanguage,
- RichInputMethodManager.getInstance().hasMultipleEnabledIMEsOrSubtypes(true));
+ final boolean hasMultipleEnabledIMEsOrSubtypes = RichInputMethodManager.getInstance()
+ .hasMultipleEnabledIMEsOrSubtypes(true /* shouldIncludeAuxiliarySubtypes */);
+ keyboardView.startDisplayLanguageOnSpacebar(subtypeChanged, languageOnSpacebarFormatType,
+ hasMultipleEnabledIMEsOrSubtypes);
}
public Keyboard getKeyboard() {
diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
index 03425ef..0f9c39a 100644
--- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java
@@ -49,6 +49,7 @@
import com.android.inputmethod.keyboard.internal.KeyDrawParams;
import com.android.inputmethod.keyboard.internal.KeyPreviewChoreographer;
import com.android.inputmethod.keyboard.internal.KeyPreviewDrawParams;
+import com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper;
import com.android.inputmethod.keyboard.internal.NonDistinctMultitouchHelper;
import com.android.inputmethod.keyboard.internal.SlidingKeyInputDrawingPreview;
import com.android.inputmethod.keyboard.internal.TimerHandler;
@@ -123,7 +124,7 @@
// Stuff to draw language name on spacebar.
private final int mLanguageOnSpacebarFinalAlpha;
private ObjectAnimator mLanguageOnSpacebarFadeoutAnimator;
- private boolean mNeedsToDisplayLanguage;
+ private int mLanguageOnSpacebarFormatType;
private boolean mHasMultipleEnabledIMEsOrSubtypes;
private int mLanguageOnSpacebarAnimAlpha = Constants.Color.ALPHA_OPAQUE;
private final float mLanguageOnSpacebarTextRatio;
@@ -811,14 +812,16 @@
}
public void startDisplayLanguageOnSpacebar(final boolean subtypeChanged,
- final boolean needsToDisplayLanguage, final boolean hasMultipleEnabledIMEsOrSubtypes) {
- mNeedsToDisplayLanguage = needsToDisplayLanguage;
+ final int languageOnSpacebarFormatType,
+ final boolean hasMultipleEnabledIMEsOrSubtypes) {
+ mLanguageOnSpacebarFormatType = languageOnSpacebarFormatType;
mHasMultipleEnabledIMEsOrSubtypes = hasMultipleEnabledIMEsOrSubtypes;
final ObjectAnimator animator = mLanguageOnSpacebarFadeoutAnimator;
if (animator == null) {
- mNeedsToDisplayLanguage = false;
+ mLanguageOnSpacebarFormatType = LanguageOnSpacebarHelper.FORMAT_TYPE_NONE;
} else {
- if (subtypeChanged && needsToDisplayLanguage) {
+ if (subtypeChanged
+ && languageOnSpacebarFormatType != LanguageOnSpacebarHelper.FORMAT_TYPE_NONE) {
setLanguageOnSpacebarAnimAlpha(Constants.Color.ALPHA_OPAQUE);
if (animator.isStarted()) {
animator.cancel();
@@ -919,9 +922,11 @@
private String layoutLanguageOnSpacebar(final Paint paint,
final InputMethodSubtype subtype, final int width) {
// Choose appropriate language name to fit into the width.
- final String fullText = SpacebarLanguageUtils.getFullDisplayName(subtype);
- if (fitsTextIntoWidth(width, fullText, paint)) {
- return fullText;
+ if (mLanguageOnSpacebarFormatType == LanguageOnSpacebarHelper.FORMAT_TYPE_FULL_LOCALE) {
+ final String fullText = SpacebarLanguageUtils.getFullDisplayName(subtype);
+ if (fitsTextIntoWidth(width, fullText, paint)) {
+ return fullText;
+ }
}
final String middleText = SpacebarLanguageUtils.getMiddleDisplayName(subtype);
@@ -937,7 +942,7 @@
final int height = key.getHeight();
// If input language are explicitly selected.
- if (mNeedsToDisplayLanguage) {
+ if (mLanguageOnSpacebarFormatType != LanguageOnSpacebarHelper.FORMAT_TYPE_NONE) {
paint.setTextAlign(Align.CENTER);
paint.setTypeface(Typeface.DEFAULT);
paint.setTextSize(mLanguageOnSpacebarTextSize);
diff --git a/java/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelper.java b/java/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelper.java
new file mode 100644
index 0000000..6400a24
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelper.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import android.view.inputmethod.InputMethodSubtype;
+
+import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * This class determines that the language name on the spacebar should be displayed in what format.
+ */
+public final class LanguageOnSpacebarHelper {
+ public static final int FORMAT_TYPE_NONE = 0;
+ public static final int FORMAT_TYPE_LANGUAGE_ONLY = 1;
+ public static final int FORMAT_TYPE_FULL_LOCALE = 2;
+
+ private List<InputMethodSubtype> mEnabledSubtypes = Collections.emptyList();
+ private boolean mIsSystemLanguageSameAsInputLanguage;
+
+ public int getLanguageOnSpacebarFormatType(final InputMethodSubtype subtype) {
+ if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
+ return FORMAT_TYPE_FULL_LOCALE;
+ }
+ // Only this subtype is enabled and equals to the system locale.
+ if (mEnabledSubtypes.size() < 2 && mIsSystemLanguageSameAsInputLanguage) {
+ return FORMAT_TYPE_NONE;
+ }
+ final String keyboardLanguage = SubtypeLocaleUtils.getSubtypeLocale(subtype).getLanguage();
+ final String keyboardLayout = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
+ int sameLanguageAndLayoutCount = 0;
+ for (final InputMethodSubtype ims : mEnabledSubtypes) {
+ final String language = SubtypeLocaleUtils.getSubtypeLocale(ims).getLanguage();
+ if (keyboardLanguage.equals(language) && keyboardLayout.equals(
+ SubtypeLocaleUtils.getKeyboardLayoutSetName(ims))) {
+ sameLanguageAndLayoutCount++;
+ }
+ }
+ // Display full locale name only when there are multiple subtypes that have the same
+ // locale and keyboard layout. Otherwise displaying language name is enough.
+ return sameLanguageAndLayoutCount > 1 ? FORMAT_TYPE_FULL_LOCALE
+ : FORMAT_TYPE_LANGUAGE_ONLY;
+ }
+
+ public void updateEnabledSubtypes(final List<InputMethodSubtype> enabledSubtypes) {
+ mEnabledSubtypes = enabledSubtypes;
+ }
+
+ public void updateIsSystemLanguageSameAsInputLanguage(final boolean isSame) {
+ mIsSystemLanguageSameAsInputLanguage = isSame;
+ }
+}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguage.java b/java/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguage.java
deleted file mode 100644
index e548de5..0000000
--- a/java/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguage.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-
-package com.android.inputmethod.keyboard.internal;
-
-import android.view.inputmethod.InputMethodSubtype;
-
-import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
-
-/**
- * This class determines that the language name on the spacebar should be displayed or not.
- */
-public final class NeedsToDisplayLanguage {
- private int mEnabledSubtypeCount;
- private boolean mIsSystemLanguageSameAsInputLanguage;
-
- public boolean needsToDisplayLanguage(final InputMethodSubtype subtype) {
- if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
- return true;
- }
- return mEnabledSubtypeCount >= 2 || !mIsSystemLanguageSameAsInputLanguage;
- }
-
- public void updateEnabledSubtypeCount(final int count) {
- mEnabledSubtypeCount = count;
- }
-
- public void updateIsSystemLanguageSameAsInputLanguage(final boolean isSame) {
- mIsSystemLanguageSameAsInputLanguage = isSame;
- }
-}
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 60ac1ba..30c2dfe 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -89,6 +89,8 @@
private final long mDictSize;
private final String mDictFilePath;
private final boolean mIsUpdatable;
+ private boolean mHasUpdated;
+
private final int[] mInputCodePoints = new int[MAX_WORD_LENGTH];
private final int[] mOutputSuggestionCount = new int[1];
private final int[] mOutputCodePoints = new int[MAX_WORD_LENGTH * MAX_RESULTS];
@@ -97,6 +99,7 @@
private final int[] mOutputTypes = new int[MAX_RESULTS];
// Only one result is ever used
private final int[] mOutputAutoCommitFirstWordConfidence = new int[1];
+ private final float[] mInputOutputLanguageWeight = new float[1];
private final NativeSuggestOptions mNativeSuggestOptions = new NativeSuggestOptions();
@@ -137,6 +140,7 @@
mDictSize = length;
mDictFilePath = filename;
mIsUpdatable = isUpdatable;
+ mHasUpdated = false;
mNativeSuggestOptions.setUseFullEditDistance(useFullEditDistance);
loadDictionary(filename, offset, length, isUpdatable);
}
@@ -167,7 +171,7 @@
int[] pointerIds, int[] inputCodePoints, int inputSize, int[] suggestOptions,
int[] prevWordCodePointArray, int[] outputSuggestionCount, int[] outputCodePoints,
int[] outputScores, int[] outputIndices, int[] outputTypes,
- int[] outputAutoCommitFirstWordConfidence);
+ int[] outputAutoCommitFirstWordConfidence, float[] inOutLanguageWeight);
private static native void addUnigramWordNative(long dict, int[] word, int probability,
int[] shortcutTarget, int shortcutProbability, boolean isNotAWord,
boolean isBlacklisted, int timestamp);
@@ -184,6 +188,7 @@
// TODO: Move native dict into session
private final void loadDictionary(final String path, final long startOffset,
final long length, final boolean isUpdatable) {
+ mHasUpdated = false;
mNativeDict = openNative(path, startOffset, length, isUpdatable);
}
@@ -231,16 +236,17 @@
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
- final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
+ final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
+ final float[] inOutLanguageWeight) {
return getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords,
- additionalFeaturesOptions, 0 /* sessionId */);
+ additionalFeaturesOptions, 0 /* sessionId */, inOutLanguageWeight);
}
@Override
public ArrayList<SuggestedWordInfo> getSuggestionsWithSessionId(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
- final int sessionId) {
+ final int sessionId, final float[] inOutLanguageWeight) {
if (!isValidDictionary()) return null;
Arrays.fill(mInputCodePoints, Constants.NOT_A_CODE);
@@ -261,13 +267,22 @@
final int inputSize = isGesture ? ips.getPointerSize() : composerSize;
mNativeSuggestOptions.setIsGesture(isGesture);
mNativeSuggestOptions.setAdditionalFeaturesOptions(additionalFeaturesOptions);
+ if (inOutLanguageWeight != null) {
+ mInputOutputLanguageWeight[0] = inOutLanguageWeight[0];
+ } else {
+ mInputOutputLanguageWeight[0] = Dictionary.NOT_A_LANGUAGE_WEIGHT;
+ }
// proximityInfo and/or prevWordForBigrams may not be null.
getSuggestionsNative(mNativeDict, proximityInfo.getNativeProximityInfo(),
getTraverseSession(sessionId).getSession(), ips.getXCoordinates(),
ips.getYCoordinates(), ips.getTimes(), ips.getPointerIds(), mInputCodePoints,
inputSize, mNativeSuggestOptions.getOptions(),
prevWordCodePointArray, mOutputSuggestionCount, mOutputCodePoints, mOutputScores,
- mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence);
+ mSpaceIndices, mOutputTypes, mOutputAutoCommitFirstWordConfidence,
+ mInputOutputLanguageWeight);
+ if (inOutLanguageWeight != null) {
+ inOutLanguageWeight[0] = mInputOutputLanguageWeight[0];
+ }
final int count = mOutputSuggestionCount[0];
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList();
for (int j = 0; j < count; ++j) {
@@ -390,6 +405,7 @@
StringUtils.toCodePointArray(shortcutTarget) : null;
addUnigramWordNative(mNativeDict, codePoints, probability, shortcutTargetCodePoints,
shortcutProbability, isNotAWord, isBlacklisted, timestamp);
+ mHasUpdated = true;
}
// Add a bigram entry to binary dictionary with timestamp in native code.
@@ -401,6 +417,7 @@
final int[] codePoints0 = StringUtils.toCodePointArray(word0);
final int[] codePoints1 = StringUtils.toCodePointArray(word1);
addBigramWordsNative(mNativeDict, codePoints0, codePoints1, probability, timestamp);
+ mHasUpdated = true;
}
// Remove a bigram entry form binary dictionary in native code.
@@ -411,6 +428,7 @@
final int[] codePoints0 = StringUtils.toCodePointArray(word0);
final int[] codePoints1 = StringUtils.toCodePointArray(word1);
removeBigramWordsNative(mNativeDict, codePoints0, codePoints1);
+ mHasUpdated = true;
}
public void addMultipleDictionaryEntries(final LanguageModelParam[] languageModelParams) {
@@ -422,6 +440,7 @@
}
processedParamCount = addMultipleDictionaryEntriesNative(mNativeDict,
languageModelParams, processedParamCount);
+ mHasUpdated = true;
if (processedParamCount <= 0) {
return;
}
@@ -440,8 +459,10 @@
public void flush() {
if (!isValidDictionary()) return;
- flushNative(mNativeDict, mDictFilePath);
- reopen();
+ if (mHasUpdated) {
+ flushNative(mNativeDict, mDictFilePath);
+ reopen();
+ }
}
public void flushWithGC() {
diff --git a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java
index 4e17f83..d5873d7 100644
--- a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java
@@ -100,10 +100,6 @@
});
}
- public void reopen(final Context context) {
- registerObserver(context);
- }
-
@Override
public synchronized void close() {
if (mObserver != null) {
diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java
index e0452484..0742fbd 100644
--- a/java/src/com/android/inputmethod/latin/Dictionary.java
+++ b/java/src/com/android/inputmethod/latin/Dictionary.java
@@ -27,6 +27,7 @@
*/
public abstract class Dictionary {
public static final int NOT_A_PROBABILITY = -1;
+ public static final float NOT_A_LANGUAGE_WEIGHT = -1.0f;
// The following types do not actually come from real dictionary instances, so we create
// corresponding instances.
@@ -70,22 +71,26 @@
* @param proximityInfo the object for key proximity. May be ignored by some implementations.
* @param blockOffensiveWords whether to block potentially offensive words
* @param additionalFeaturesOptions options about additional features used for the suggestion.
+ * @param inOutLanguageWeight the language weight used for generating suggestions.
+ * inOutLanguageWeight is a float array that has only one element. This can be updated when the
+ * different language weight is used.
* @return the list of suggestions (possibly null if none)
*/
// TODO: pass more context than just the previous word, to enable better suggestions (n-gram
// and more)
abstract public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
- final boolean blockOffensiveWords, final int[] additionalFeaturesOptions);
+ final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
+ final float[] inOutLanguageWeight);
// The default implementation of this method ignores sessionId.
// Subclasses that want to use sessionId need to override this method.
public ArrayList<SuggestedWordInfo> getSuggestionsWithSessionId(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
- final int sessionId) {
+ final int sessionId, final float[] inOutLanguageWeight) {
return getSuggestions(composer, prevWord, proximityInfo, blockOffensiveWords,
- additionalFeaturesOptions);
+ additionalFeaturesOptions, inOutLanguageWeight);
}
/**
@@ -159,7 +164,8 @@
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
- final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
+ final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
+ final float[] inOutLanguageWeight) {
return null;
}
diff --git a/java/src/com/android/inputmethod/latin/DictionaryCollection.java b/java/src/com/android/inputmethod/latin/DictionaryCollection.java
index bf07514..16173ff 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryCollection.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryCollection.java
@@ -58,18 +58,21 @@
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
- final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
+ final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
+ final float[] inOutLanguageWeight) {
final CopyOnWriteArrayList<Dictionary> dictionaries = mDictionaries;
if (dictionaries.isEmpty()) return null;
// To avoid creating unnecessary objects, we get the list out of the first
// dictionary and add the rest to it if not null, hence the get(0)
ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getSuggestions(composer,
- prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions);
+ prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions,
+ inOutLanguageWeight);
if (null == suggestions) suggestions = CollectionUtils.newArrayList();
final int length = dictionaries.size();
for (int i = 1; i < length; ++ i) {
final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getSuggestions(composer,
- prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions);
+ prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions,
+ inOutLanguageWeight);
if (null != sugg) suggestions.addAll(sugg);
}
return suggestions;
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
index ae2d7c9..7cb218f 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java
@@ -36,7 +36,6 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -54,6 +53,15 @@
// To synchronize assigning mDictionaries to ensure closing dictionaries.
private Object mLock = new Object();
+ private static final String[] dictTypesOrderedToGetSuggestion =
+ new String[] {
+ Dictionary.TYPE_MAIN,
+ Dictionary.TYPE_USER_HISTORY,
+ Dictionary.TYPE_PERSONALIZATION,
+ Dictionary.TYPE_USER,
+ Dictionary.TYPE_CONTACTS
+ };
+
/**
* Class contains dictionaries for a locale.
*/
@@ -453,11 +461,14 @@
final Map<String, Dictionary> dictMap = dictionaries.mDictMap;
final SuggestionResults suggestionResults =
new SuggestionResults(dictionaries.mLocale, SuggestedWords.MAX_SUGGESTIONS);
- for (final Dictionary dictionary : dictMap.values()) {
+ final float[] languageWeight = new float[] { Dictionary.NOT_A_LANGUAGE_WEIGHT };
+ for (final String dictType : dictTypesOrderedToGetSuggestion) {
+ final Dictionary dictionary = dictMap.get(dictType);
if (null == dictionary) continue;
final ArrayList<SuggestedWordInfo> dictionarySuggestions =
dictionary.getSuggestionsWithSessionId(composer, prevWord, proximityInfo,
- blockOffensiveWords, additionalFeaturesOptions, sessionId);
+ blockOffensiveWords, additionalFeaturesOptions, sessionId,
+ languageWeight);
if (null == dictionarySuggestions) continue;
suggestionResults.addAll(dictionarySuggestions);
if (null != rawSuggestions) {
diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
index 92b5354..64e9d2b 100644
--- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
@@ -262,6 +262,9 @@
ExecutorUtils.getExecutor(mDictName).execute(new Runnable() {
@Override
public void run() {
+ if (mBinaryDictionary == null) {
+ return;
+ }
runGCAfterAllPrioritizedTasksIfRequiredLocked(mindsBlockByGC);
}
});
@@ -274,9 +277,6 @@
}
private void runGCAfterAllPrioritizedTasksIfRequiredLocked(final boolean mindsBlockByGC) {
- if (mBinaryDictionary == null) {
- return;
- }
// needsToRunGC() have to be called with lock.
if (mBinaryDictionary.needsToRunGC(mindsBlockByGC)) {
if (setProcessingLargeTaskIfNot()) {
@@ -301,9 +301,13 @@
protected void addWordDynamically(final String word, final int frequency,
final String shortcutTarget, final int shortcutFreq, final boolean isNotAWord,
final boolean isBlacklisted, final int timestamp) {
+ reloadDictionaryIfRequired();
ExecutorUtils.getExecutor(mDictName).execute(new Runnable() {
@Override
public void run() {
+ if (mBinaryDictionary == null) {
+ return;
+ }
runGCAfterAllPrioritizedTasksIfRequiredLocked(true /* mindsBlockByGC */);
addWordDynamicallyLocked(word, frequency, shortcutTarget, shortcutFreq,
isNotAWord, isBlacklisted, timestamp);
@@ -323,9 +327,13 @@
*/
protected void addBigramDynamically(final String word0, final String word1,
final int frequency, final int timestamp) {
+ reloadDictionaryIfRequired();
ExecutorUtils.getExecutor(mDictName).execute(new Runnable() {
@Override
public void run() {
+ if (mBinaryDictionary == null) {
+ return;
+ }
runGCAfterAllPrioritizedTasksIfRequiredLocked(true /* mindsBlockByGC */);
addBigramDynamicallyLocked(word0, word1, frequency, timestamp);
}
@@ -341,9 +349,13 @@
* Dynamically remove a word bigram in the dictionary.
*/
protected void removeBigramDynamically(final String word0, final String word1) {
+ reloadDictionaryIfRequired();
ExecutorUtils.getExecutor(mDictName).execute(new Runnable() {
@Override
public void run() {
+ if (mBinaryDictionary == null) {
+ return;
+ }
runGCAfterAllPrioritizedTasksIfRequiredLocked(true /* mindsBlockByGC */);
mBinaryDictionary.removeBigramWords(word0, word1);
}
@@ -360,14 +372,15 @@
protected void addMultipleDictionaryEntriesDynamically(
final ArrayList<LanguageModelParam> languageModelParams,
final AddMultipleDictionaryEntriesCallback callback) {
+ reloadDictionaryIfRequired();
ExecutorUtils.getExecutor(mDictName).execute(new Runnable() {
@Override
public void run() {
+ if (mBinaryDictionary == null) {
+ return;
+ }
final boolean locked = setProcessingLargeTaskIfNot();
try {
- if (mBinaryDictionary == null) {
- return;
- }
mBinaryDictionary.addMultipleDictionaryEntries(
languageModelParams.toArray(
new LanguageModelParam[languageModelParams.size()]));
@@ -387,7 +400,7 @@
public ArrayList<SuggestedWordInfo> getSuggestionsWithSessionId(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
- final int sessionId) {
+ final int sessionId, final float[] inOutLanguageWeight) {
reloadDictionaryIfRequired();
if (processingLargeTask()) {
return null;
@@ -404,7 +417,7 @@
final ArrayList<SuggestedWordInfo> binarySuggestion =
mBinaryDictionary.getSuggestionsWithSessionId(composer, prevWord,
proximityInfo, blockOffensiveWords, additionalFeaturesOptions,
- sessionId);
+ sessionId, inOutLanguageWeight);
holder.set(binarySuggestion);
if (mBinaryDictionary.isCorrupted()) {
removeBinaryDictionaryLocked();
@@ -417,9 +430,10 @@
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
- final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
+ final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
+ final float[] inOutLanguageWeight) {
return getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords,
- additionalFeaturesOptions, 0 /* sessionId */);
+ additionalFeaturesOptions, 0 /* sessionId */, inOutLanguageWeight);
}
@Override
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 53e6232..b4807b0 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -156,7 +156,7 @@
private static final int MSG_SHOW_GESTURE_PREVIEW_AND_SUGGESTION_STRIP = 3;
private static final int MSG_RESUME_SUGGESTIONS = 4;
private static final int MSG_REOPEN_DICTIONARIES = 5;
- private static final int MSG_ON_END_BATCH_INPUT = 6;
+ private static final int MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED = 6;
private static final int MSG_RESET_CACHES = 7;
// Update this when adding new messages
private static final int MSG_LAST = MSG_RESET_CACHES;
@@ -220,8 +220,9 @@
// get any suggestions. Wait one frame.
postUpdateSuggestionStrip();
break;
- case MSG_ON_END_BATCH_INPUT:
- latinIme.mInputLogic.endBatchInputInternal(latinIme.mSettings.getCurrent(),
+ case MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED:
+ latinIme.mInputLogic.onUpdateTailBatchInputCompleted(
+ latinIme.mSettings.getCurrent(),
(SuggestedWords) msg.obj, latinIme.mKeyboardSwitcher);
break;
case MSG_RESET_CACHES:
@@ -304,8 +305,8 @@
ARG1_NOT_GESTURE_INPUT, ARG2_UNUSED, suggestedWords).sendToTarget();
}
- public void onEndBatchInput(final SuggestedWords suggestedWords) {
- obtainMessage(MSG_ON_END_BATCH_INPUT, suggestedWords).sendToTarget();
+ public void showTailBatchInputResult(final SuggestedWords suggestedWords) {
+ obtainMessage(MSG_UPDATE_TAIL_BATCH_INPUT_COMPLETED, suggestedWords).sendToTarget();
}
// Working variables for the following methods.
diff --git a/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java
index 68505ce..9f61d6c 100644
--- a/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java
@@ -51,20 +51,21 @@
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
- final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
+ final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
+ final float[] inOutLanguageWeight) {
return getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords,
- additionalFeaturesOptions, 0 /* sessionId */);
+ additionalFeaturesOptions, 0 /* sessionId */, inOutLanguageWeight);
}
@Override
public ArrayList<SuggestedWordInfo> getSuggestionsWithSessionId(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
- final int sessionId) {
+ final int sessionId, final float[] inOutLanguageWeight) {
if (mLock.readLock().tryLock()) {
try {
return mBinaryDictionary.getSuggestions(composer, prevWord, proximityInfo,
- blockOffensiveWords, additionalFeaturesOptions);
+ blockOffensiveWords, additionalFeaturesOptions, inOutLanguageWeight);
} finally {
mLock.readLock().unlock();
}
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index d430122..0211339 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -34,7 +34,7 @@
import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
-import com.android.inputmethod.keyboard.internal.NeedsToDisplayLanguage;
+import com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper;
import com.android.inputmethod.latin.utils.LocaleUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@@ -54,7 +54,8 @@
private /* final */ Resources mResources;
private /* final */ ConnectivityManager mConnectivityManager;
- private final NeedsToDisplayLanguage mNeedsToDisplayLanguage = new NeedsToDisplayLanguage();
+ private final LanguageOnSpacebarHelper mLanguageOnSpacebarHelper =
+ new LanguageOnSpacebarHelper();
private InputMethodInfo mShortcutInputMethodInfo;
private InputMethodSubtype mShortcutSubtype;
private InputMethodSubtype mNoLanguageSubtype;
@@ -127,7 +128,7 @@
public void updateParametersOnStartInputView() {
final List<InputMethodSubtype> enabledSubtypesOfThisIme =
mRichImm.getMyEnabledInputMethodSubtypeList(true);
- mNeedsToDisplayLanguage.updateEnabledSubtypeCount(enabledSubtypesOfThisIme.size());
+ mLanguageOnSpacebarHelper.updateEnabledSubtypes(enabledSubtypesOfThisIme);
updateShortcutIME();
}
@@ -176,7 +177,7 @@
final boolean sameLanguage = systemLocale.getLanguage().equals(newLocale.getLanguage());
final boolean implicitlyEnabled =
mRichImm.checkIfSubtypeBelongsToThisImeAndImplicitlyEnabled(newSubtype);
- mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(
+ mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(
sameLocale || (sameLanguage && implicitlyEnabled));
updateShortcutIME();
@@ -249,8 +250,8 @@
// Subtype Switching functions //
//////////////////////////////////
- public boolean needsToDisplayLanguage(final InputMethodSubtype subtype) {
- return mNeedsToDisplayLanguage.needsToDisplayLanguage(subtype);
+ public int getLanguageOnSpacebarFormatType(final InputMethodSubtype subtype) {
+ return mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(subtype);
}
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() {
diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java
index 9c095e4..c24ee40 100644
--- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java
@@ -34,10 +34,11 @@
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
final String prevWordForBigrams, final ProximityInfo proximityInfo,
- final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
+ final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
+ final float[] inOutLanguageWeight) {
synchronized (mLock) {
return super.getSuggestions(codes, prevWordForBigrams, proximityInfo,
- blockOffensiveWords, additionalFeaturesOptions);
+ blockOffensiveWords, additionalFeaturesOptions, inOutLanguageWeight);
}
}
diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java
index 801fb5b..1d29d7a 100644
--- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java
@@ -39,10 +39,11 @@
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes,
final String prevWordForBigrams, final ProximityInfo proximityInfo,
- final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
+ final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
+ final float[] inOutLanguageWeight) {
synchronized (mLock) {
return super.getSuggestions(codes, prevWordForBigrams, proximityInfo,
- blockOffensiveWords, additionalFeaturesOptions);
+ blockOffensiveWords, additionalFeaturesOptions, inOutLanguageWeight);
}
}
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index ec6bd28..ee31c46 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -210,22 +210,12 @@
// So, LatinImeLogger logs "" as a user's input.
LatinImeLogger.logOnManualSuggestion("", suggestion, index, suggestedWords);
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
- final int primaryCode = suggestion.charAt(0);
- // TODO: we should be using createSuggestionPickedEvent here, but for legacy reasons,
- // onCodeInput is expected a software keypress event for a suggested punctuation
- // because the current code is descended from a time where this information used not
- // to be available. Fix this.
- final Event event = Event.createSoftwareKeypressEvent(primaryCode,
- Event.NOT_A_KEY_CODE /* keyCode*/,
- Constants.SUGGESTION_STRIP_COORDINATE /* x */,
- Constants.SUGGESTION_STRIP_COORDINATE /* y */);
- final InputTransaction completeTransaction = onCodeInput(settingsValues, event,
- keyboardShiftState, handler);
+ final Event event = Event.createPunctuationSuggestionPickedEvent(suggestionInfo);
if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
ResearchLogger.latinIME_punctuationSuggestion(index, suggestion,
false /* isBatchMode */, suggestedWords.mIsPrediction);
}
- return completeTransaction;
+ return onCodeInput(settingsValues, event, keyboardShiftState, handler);
}
final Event event = Event.createSuggestionPickedEvent(suggestionInfo);
@@ -601,7 +591,7 @@
}
public void onEndBatchInput(final InputPointers batchPointers) {
- mInputLogicHandler.onEndBatchInput(batchPointers, mAutoCommitSequenceNumber);
+ mInputLogicHandler.updateTailBatchInput(batchPointers, mAutoCommitSequenceNumber);
++mAutoCommitSequenceNumber;
}
@@ -833,13 +823,11 @@
}
if (Constants.CODE_SPACE == codePoint) {
- if (inputTransaction.mSettingsValues.isSuggestionsRequested()) {
- if (maybeDoubleSpacePeriod(inputTransaction)) {
- inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
- mSpaceState = SpaceState.DOUBLE;
- } else if (!mSuggestedWords.isPunctuationSuggestions()) {
- mSpaceState = SpaceState.WEAK;
- }
+ if (maybeDoubleSpacePeriod(inputTransaction)) {
+ inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
+ mSpaceState = SpaceState.DOUBLE;
+ } else if (!mSuggestedWords.isPunctuationSuggestions()) {
+ mSpaceState = SpaceState.WEAK;
}
startDoubleSpacePeriodCountdown(inputTransaction);
@@ -1794,7 +1782,7 @@
* @param settingsValues the current values of the settings.
* @param suggestedWords suggestedWords to use.
*/
- public void endBatchInputInternal(final SettingsValues settingsValues,
+ public void onUpdateTailBatchInputCompleted(final SettingsValues settingsValues,
final SuggestedWords suggestedWords,
// TODO: remove this argument
final KeyboardSwitcher keyboardSwitcher) {
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java
index 42f0d7c..e3b8ab4 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogicHandler.java
@@ -54,7 +54,8 @@
@Override
public void onCancelBatchInput() {}
@Override
- public void onEndBatchInput(final InputPointers batchPointers, final int sequenceNumber) {}
+ public void updateTailBatchInput(final InputPointers batchPointers,
+ final int sequenceNumber) {}
@Override
public void getSuggestedWords(final int sessionId, final int sequenceNumber,
final OnGetSuggestedWordsCallback callback) {}
@@ -106,7 +107,7 @@
* Fetch suggestions corresponding to an update of a batch input.
* @param batchPointers the updated pointers, including the part that was passed last time.
* @param sequenceNumber the sequence number associated with this batch input.
- * @param forEnd true if this is the end of a batch input, false if it's an update.
+ * @param isTailBatchInput true if this is the end of a batch input, false if it's an update.
*/
// This method can be called from any thread and will see to it that the correct threads
// are used for parts that require it. This method will send a message to the Non-UI handler
@@ -115,7 +116,7 @@
// send a message to the UI handler in LatinIME so that showing suggestions can be done on
// the UI thread.
private void updateBatchInput(final InputPointers batchPointers,
- final int sequenceNumber, final boolean forEnd) {
+ final int sequenceNumber, final boolean isTailBatchInput) {
synchronized (mLock) {
if (!mInBatchInput) {
// Batch input has ended or canceled while the message was being delivered.
@@ -136,12 +137,12 @@
suggestedWords = mInputLogic.mSuggestedWords;
}
mLatinIME.mHandler.showGesturePreviewAndSuggestionStrip(suggestedWords,
- forEnd /* dismissGestureFloatingPreviewText */);
- if (forEnd) {
+ isTailBatchInput /* dismissGestureFloatingPreviewText */);
+ if (isTailBatchInput) {
mInBatchInput = false;
// The following call schedules onEndBatchInputInternal
// to be called on the UI thread.
- mLatinIME.mHandler.onEndBatchInput(suggestedWords);
+ mLatinIME.mHandler.showTailBatchInputResult(suggestedWords);
}
}
});
@@ -159,13 +160,13 @@
// Called on the UI thread by InputLogic.
public void onUpdateBatchInput(final InputPointers batchPointers,
final int sequenceNumber) {
- updateBatchInput(batchPointers, sequenceNumber, false /* forEnd */);
+ updateBatchInput(batchPointers, sequenceNumber, false /* isTailBatchInput */);
}
/**
* Cancel a batch input.
*
- * Note that as opposed to onEndBatchInput, we do the UI side of this immediately on the
+ * Note that as opposed to updateTailBatchInput, we do the UI side of this immediately on the
* same thread, rather than get this to call a method in LatinIME. This is because
* canceling a batch input does not necessitate the long operation of pulling suggestions.
*/
@@ -177,17 +178,20 @@
}
/**
- * Finish a batch input.
+ * Trigger an update for a tail batch input.
*
- * This fetches suggestions, updates the suggestion strip and commits the first suggestion.
- * It also dismisses the floating text preview.
+ * A tail batch input is the last update for a gesture, the one that is triggered after the
+ * user lifts their finger. This method schedules fetching suggestions on the non-UI thread,
+ * then when the suggestions are computed it comes back on the UI thread to update the
+ * suggestion strip, commit the first suggestion, and dismiss the floating text preview.
*
* @param batchPointers the updated batch pointers.
* @param sequenceNumber the sequence number associated with this batch input.
*/
// Called on the UI thread by InputLogic.
- public void onEndBatchInput(final InputPointers batchPointers, final int sequenceNumber) {
- updateBatchInput(batchPointers, sequenceNumber, true /* forEnd */);
+ public void updateTailBatchInput(final InputPointers batchPointers,
+ final int sequenceNumber) {
+ updateBatchInput(batchPointers, sequenceNumber, true /* isTailBatchInput */);
}
public void getSuggestedWords(final int sessionId, final int sequenceNumber,
diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
index 6f84e1f..712e314 100644
--- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
+++ b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java
@@ -66,7 +66,7 @@
}
// Flush pending writes.
flush();
- // TODO: Quit depending on finalize() and really close the dictionary file.
+ super.close();
}
public void flush() {
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
index 3947019..69d0927 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
@@ -327,7 +327,8 @@
final ArrayList<SuggestedWordInfo> suggestions =
dictInfo.mDictionary.getSuggestions(composer, prevWord,
dictInfo.getProximityInfo(), true /* blockOffensiveWords */,
- null /* additionalFeaturesOptions */);
+ null /* additionalFeaturesOptions */,
+ null /* inOutLanguageWeight */);
if (suggestions != null) {
for (final SuggestedWordInfo suggestion : suggestions) {
final String suggestionStr = suggestion.mWord;
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/DictionaryPool.java b/java/src/com/android/inputmethod/latin/spellcheck/DictionaryPool.java
index b7a5a40..c992643 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/DictionaryPool.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/DictionaryPool.java
@@ -53,7 +53,8 @@
@Override
public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
final String prevWord, final ProximityInfo proximityInfo,
- final boolean blockOffensiveWords, final int[] additionalFeaturesOptions) {
+ final boolean blockOffensiveWords, final int[] additionalFeaturesOptions,
+ final float[] inOutLanguageWeight) {
return noSuggestions;
}
@Override
diff --git a/native/jni/Android.mk b/native/jni/Android.mk
index c1372bd..5c117ce 100644
--- a/native/jni/Android.mk
+++ b/native/jni/Android.mk
@@ -87,6 +87,8 @@
LOCAL_LDFLAGS += -ldl
include $(BUILD_SHARED_LIBRARY)
-
#################### Clean up the tmp vars
include $(LOCAL_PATH)/CleanupNativeFileList.mk
+
+#################### Unit test on host environment
+include $(LOCAL_PATH)/HostUnitTests.mk
diff --git a/native/jni/CleanupNativeFileList.mk b/native/jni/CleanupNativeFileList.mk
index 5420f16..1738f8c 100644
--- a/native/jni/CleanupNativeFileList.mk
+++ b/native/jni/CleanupNativeFileList.mk
@@ -13,5 +13,6 @@
# limitations under the License.
LATIN_IME_CORE_SRC_FILES :=
+LATIN_IME_CORE_TEST_FILES :=
LATIN_IME_JNI_SRC_FILES :=
LATIN_IME_SRC_DIR :=
diff --git a/native/jni/HostUnitTests.mk b/native/jni/HostUnitTests.mk
new file mode 100644
index 0000000..967099a
--- /dev/null
+++ b/native/jni/HostUnitTests.mk
@@ -0,0 +1,60 @@
+# Copyright (C) 2014 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.
+
+# HACK: Temporarily disable host tool build on Mac until the build system is ready for C++11.
+LATINIME_HOST_OSNAME := $(shell uname -s)
+ifneq ($(LATINIME_HOST_OSNAME), Darwin) # TODO: Remove this
+
+LOCAL_PATH := $(call my-dir)
+
+######################################
+include $(CLEAR_VARS)
+
+include $(LOCAL_PATH)/NativeFileList.mk
+
+#################### Host library for unit test
+# TODO: Remove -std=c++11 once it is set by default on host build.
+LATIN_IME_SRC_DIR := src
+LOCAL_CFLAGS += -std=c++11 -Wno-unused-parameter -Wno-unused-function
+LOCAL_CLANG := true
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE := liblatinime_host_static_for_unittests
+LOCAL_MODULE_TAGS := optional
+LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+#################### Host native tests
+include $(CLEAR_VARS)
+LATIN_IME_TEST_SRC_DIR := tests
+# TODO: Remove -std=c++11 once it is set by default on host build.
+LOCAL_CFLAGS += -std=c++11 -Wno-unused-parameter -Wno-unused-function
+LOCAL_CLANG := true
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE := liblatinime_host_unittests
+LOCAL_MODULE_TAGS := tests
+LOCAL_NDK_STL_VARIANT := c++_static
+LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_TEST_SRC_DIR)/, $(LATIN_IME_CORE_TEST_FILES))
+LOCAL_STATIC_LIBRARIES += liblatinime_host_static_for_unittests libgtest_host libgtest_main_host
+include $(BUILD_HOST_NATIVE_TEST)
+
+endif # Darwin - TODO: Remove this
+
+#################### Clean up the tmp vars
+LATINIME_HOST_OSNAME :=
+LATIN_IME_SRC_DIR :=
+LATIN_IME_TEST_SRC_DIR :=
+include $(LOCAL_PATH)/CleanupNativeFileList.mk
diff --git a/native/jni/NativeFileList.mk b/native/jni/NativeFileList.mk
index 2ee4caa..3da9d56 100644
--- a/native/jni/NativeFileList.mk
+++ b/native/jni/NativeFileList.mk
@@ -99,3 +99,6 @@
char_utils.cpp \
log_utils.cpp \
time_keeper.cpp)
+
+LATIN_IME_CORE_TEST_FILES := \
+ utils/autocorrection_threshold_utils_test.cpp
diff --git a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
index 154ea98..bf03fdf 100644
--- a/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
+++ b/native/jni/com_android_inputmethod_latin_BinaryDictionary.cpp
@@ -146,7 +146,8 @@
jintArray inputCodePointsArray, jint inputSize, jintArray suggestOptions,
jintArray prevWordCodePointsForBigrams, jintArray outSuggestionCount,
jintArray outCodePointsArray, jintArray outScoresArray, jintArray outSpaceIndicesArray,
- jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray) {
+ jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray,
+ jfloatArray inOutLanguageWeight) {
Dictionary *dictionary = reinterpret_cast<Dictionary *>(dict);
// Assign 0 to outSuggestionCount here in case of returning earlier in this method.
int count = 0;
@@ -209,20 +210,22 @@
ASSERT(false);
return;
}
-
+ float languageWeight;
+ env->GetFloatArrayRegion(inOutLanguageWeight, 0, 1 /* len */, &languageWeight);
SuggestionResults suggestionResults(MAX_RESULTS);
if (givenSuggestOptions.isGesture() || inputSize > 0) {
// TODO: Use SuggestionResults to return suggestions.
dictionary->getSuggestions(pInfo, traverseSession, xCoordinates, yCoordinates,
times, pointerIds, inputCodePoints, inputSize, prevWordCodePoints,
- prevWordCodePointsLength, &givenSuggestOptions, &suggestionResults);
+ prevWordCodePointsLength, &givenSuggestOptions, languageWeight,
+ &suggestionResults);
} else {
dictionary->getPredictions(prevWordCodePoints, prevWordCodePointsLength,
&suggestionResults);
}
suggestionResults.outputSuggestions(env, outSuggestionCount, outCodePointsArray,
outScoresArray, outSpaceIndicesArray, outTypesArray,
- outAutoCommitFirstWordConfidenceArray);
+ outAutoCommitFirstWordConfidenceArray, inOutLanguageWeight);
}
static jint latinime_BinaryDictionary_getProbability(JNIEnv *env, jclass clazz, jlong dict,
@@ -489,7 +492,7 @@
},
{
const_cast<char *>("getSuggestionsNative"),
- const_cast<char *>("(JJJ[I[I[I[I[II[I[I[I[I[I[I[I[I)V"),
+ const_cast<char *>("(JJJ[I[I[I[I[II[I[I[I[I[I[I[I[I[F)V"),
reinterpret_cast<void *>(latinime_BinaryDictionary_getSuggestions)
},
{
diff --git a/native/jni/run-tests.sh b/native/jni/run-tests.sh
new file mode 100755
index 0000000..5b60e0d
--- /dev/null
+++ b/native/jni/run-tests.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+# Copyright 2014, 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.
+
+if [[ $(type -t mmm) != function ]]; then
+echo "Usage:" 1>&2
+echo " source $0" 1>&2
+echo " or" 1>&2
+echo " . $0" 1>&2
+if [[ ${BASH_SOURCE[0]} != $0 ]]; then return; else exit 1; fi
+fi
+
+pushd $PWD > /dev/null
+cd $(gettop)
+mmm -j16 packages/inputmethods/LatinIME/native/jni || \
+ make -j16 liblatinime_host_unittests
+${ANDROID_HOST_OUT}/bin/liblatinime_host_unittests
+popd > /dev/null
\ No newline at end of file
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 3651cd5..1719b1c 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -118,14 +118,6 @@
}
}
-static inline void dumpResult(const int *outWords, const int *frequencies) {
- AKLOGI("--- DUMP RESULT ---------");
- for (int i = 0; i < MAX_RESULTS; ++i) {
- dumpWordInfo(&outWords[i * MAX_WORD_LENGTH], MAX_WORD_LENGTH, i, frequencies[i]);
- }
- AKLOGI("-------------------------");
-}
-
static AK_FORCE_INLINE void dumpWord(const int *word, const int length) {
static char charBuf[50];
const int N = intArrayToCharArray(word, length, charBuf, NELEMS(charBuf));
@@ -309,6 +301,7 @@
#define NOT_A_PROBABILITY (-1)
#define NOT_A_DICT_POS (S_INT_MIN)
#define NOT_A_TIMESTAMP (-1)
+#define NOT_A_LANGUAGE_WEIGHT (-1.0f)
// A special value to mean the first word confidence makes no sense in this case,
// e.g. this is not a multi-word suggestion.
diff --git a/native/jni/src/suggest/core/dictionary/dictionary.cpp b/native/jni/src/suggest/core/dictionary/dictionary.cpp
index ae4646d..ef7a0a8 100644
--- a/native/jni/src/suggest/core/dictionary/dictionary.cpp
+++ b/native/jni/src/suggest/core/dictionary/dictionary.cpp
@@ -47,7 +47,7 @@
void Dictionary::getSuggestions(ProximityInfo *proximityInfo, DicTraverseSession *traverseSession,
int *xcoordinates, int *ycoordinates, int *times, int *pointerIds, int *inputCodePoints,
int inputSize, int *prevWordCodePoints, int prevWordLength,
- const SuggestOptions *const suggestOptions,
+ const SuggestOptions *const suggestOptions, const float languageWeight,
SuggestionResults *const outSuggestionResults) const {
TimeKeeper::setCurrentTime();
DicTraverseSession::initSessionInstance(
@@ -55,11 +55,11 @@
if (suggestOptions->isGesture()) {
mGestureSuggest->getSuggestions(proximityInfo, traverseSession, xcoordinates,
ycoordinates, times, pointerIds, inputCodePoints, inputSize,
- outSuggestionResults);
+ languageWeight, outSuggestionResults);
} else {
mTypingSuggest->getSuggestions(proximityInfo, traverseSession, xcoordinates,
ycoordinates, times, pointerIds, inputCodePoints, inputSize,
- outSuggestionResults);
+ languageWeight, outSuggestionResults);
}
if (DEBUG_DICT) {
outSuggestionResults->dumpSuggestions();
diff --git a/native/jni/src/suggest/core/dictionary/dictionary.h b/native/jni/src/suggest/core/dictionary/dictionary.h
index df5fc9b..cd983b0 100644
--- a/native/jni/src/suggest/core/dictionary/dictionary.h
+++ b/native/jni/src/suggest/core/dictionary/dictionary.h
@@ -65,7 +65,7 @@
void getSuggestions(ProximityInfo *proximityInfo, DicTraverseSession *traverseSession,
int *xcoordinates, int *ycoordinates, int *times, int *pointerIds, int *inputCodePoints,
int inputSize, int *prevWordCodePoints, int prevWordLength,
- const SuggestOptions *const suggestOptions,
+ const SuggestOptions *const suggestOptions, const float languageWeight,
SuggestionResults *const outSuggestionResults) const;
void getPredictions(const int *word, int length,
diff --git a/native/jni/src/suggest/core/layout/proximity_info.cpp b/native/jni/src/suggest/core/layout/proximity_info.cpp
index 8b3ae4d..c40a2bd 100644
--- a/native/jni/src/suggest/core/layout/proximity_info.cpp
+++ b/native/jni/src/suggest/core/layout/proximity_info.cpp
@@ -58,7 +58,6 @@
const jfloatArray sweetSpotCenterYs, const jfloatArray sweetSpotRadii)
: GRID_WIDTH(gridWidth), GRID_HEIGHT(gridHeight), MOST_COMMON_KEY_WIDTH(mostCommonKeyWidth),
MOST_COMMON_KEY_WIDTH_SQUARE(mostCommonKeyWidth * mostCommonKeyWidth),
- MOST_COMMON_KEY_HEIGHT(mostCommonKeyHeight),
NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE(1.0f +
GeometryUtils::SQUARE_FLOAT(static_cast<float>(mostCommonKeyHeight) /
static_cast<float>(mostCommonKeyWidth))),
diff --git a/native/jni/src/suggest/core/layout/proximity_info.h b/native/jni/src/suggest/core/layout/proximity_info.h
index a91b9d6..b72c293 100644
--- a/native/jni/src/suggest/core/layout/proximity_info.h
+++ b/native/jni/src/suggest/core/layout/proximity_info.h
@@ -35,7 +35,6 @@
const jfloatArray sweetSpotCenterYs, const jfloatArray sweetSpotRadii);
~ProximityInfo();
bool hasSpaceProximity(const int x, const int y) const;
- int getNormalizedSquaredDistance(const int inputIndex, const int proximityIndex) const;
float getNormalizedSquaredDistanceFromCenterFloatG(
const int keyId, const int x, const int y, const bool isGeometric) const;
int getCodePointOf(const int keyIndex) const;
@@ -48,8 +47,6 @@
float getSweetSpotRadiiAt(int keyIndex) const { return mSweetSpotRadii[keyIndex]; }
float getSweetSpotCenterXAt(int keyIndex) const { return mSweetSpotCenterXs[keyIndex]; }
float getSweetSpotCenterYAt(int keyIndex) const { return mSweetSpotCenterYs[keyIndex]; }
- void calculateNearbyKeyCodes(
- const int x, const int y, const int primaryKey, int *inputCodes) const;
bool hasTouchPositionCorrectionData() const { return HAS_TOUCH_POSITION_CORRECTION_DATA; }
int getMostCommonKeyWidth() const { return MOST_COMMON_KEY_WIDTH; }
int getMostCommonKeyWidthSquare() const { return MOST_COMMON_KEY_WIDTH_SQUARE; }
@@ -97,7 +94,6 @@
const int GRID_HEIGHT;
const int MOST_COMMON_KEY_WIDTH;
const int MOST_COMMON_KEY_WIDTH_SQUARE;
- const int MOST_COMMON_KEY_HEIGHT;
const float NORMALIZED_SQUARED_MOST_COMMON_KEY_HYPOTENUSE;
const int CELL_WIDTH;
const int CELL_HEIGHT;
@@ -124,7 +120,6 @@
int mCenterXsG[MAX_KEY_COUNT_IN_A_KEYBOARD];
int mCenterYsG[MAX_KEY_COUNT_IN_A_KEYBOARD];
int mKeyKeyDistancesG[MAX_KEY_COUNT_IN_A_KEYBOARD][MAX_KEY_COUNT_IN_A_KEYBOARD];
- // TODO: move to correction.h
};
} // namespace latinime
#endif // LATINIME_PROXIMITY_INFO_H
diff --git a/native/jni/src/suggest/core/layout/proximity_info_params.cpp b/native/jni/src/suggest/core/layout/proximity_info_params.cpp
index 49df103..597518a 100644
--- a/native/jni/src/suggest/core/layout/proximity_info_params.cpp
+++ b/native/jni/src/suggest/core/layout/proximity_info_params.cpp
@@ -98,7 +98,4 @@
const int ProximityInfoParams::FIRST_POINT_TIME_OFFSET_MILLIS = 150;
const int ProximityInfoParams::STRONG_DOUBLE_LETTER_TIME_MILLIS = 600;
-// Used by ProximityInfoStateUtils::calculateNormalizedSquaredDistance()
-const int ProximityInfoParams::NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR = 1 << 10;
-
} // namespace latinime
diff --git a/native/jni/src/suggest/core/layout/proximity_info_state.h b/native/jni/src/suggest/core/layout/proximity_info_state.h
index 9abd69a..e253d95 100644
--- a/native/jni/src/suggest/core/layout/proximity_info_state.h
+++ b/native/jni/src/suggest/core/layout/proximity_info_state.h
@@ -108,10 +108,6 @@
return false;
}
- inline const int *getPrimaryInputWord() const {
- return mPrimaryInputWord;
- }
-
inline bool touchPositionCorrectionEnabled() const {
return mTouchPositionCorrectionEnabled;
}
@@ -156,10 +152,6 @@
ProximityType getProximityTypeG(const int index, const int codePoint) const;
- const std::vector<int> *getSearchKeyVector(const int index) const {
- return &mSampledSearchKeyVectors[index];
- }
-
float getSpeedRate(const int index) const {
return mSpeedRates[index];
}
diff --git a/native/jni/src/suggest/core/layout/proximity_info_state_utils.h b/native/jni/src/suggest/core/layout/proximity_info_state_utils.h
index 6de9700..ea0cd11 100644
--- a/native/jni/src/suggest/core/layout/proximity_info_state_utils.h
+++ b/native/jni/src/suggest/core/layout/proximity_info_state_utils.h
@@ -90,10 +90,6 @@
std::vector<float> *sampledNormalizedSquaredLengthCache);
static void initPrimaryInputWord(const int inputSize, const int *const inputProximities,
int *primaryInputWord);
- static void initNormalizedSquaredDistances(const ProximityInfo *const proximityInfo,
- const int inputSize, const int *inputXCoordinates, const int *inputYCoordinates,
- const int *const inputProximities, const std::vector<int> *const sampledInputXs,
- const std::vector<int> *const sampledInputYs, int *normalizedSquaredDistances);
static void dump(const bool isGeometric, const int inputSize,
const int *const inputXCoordinates, const int *const inputYCoordinates,
const int sampledInputSize, const std::vector<int> *const sampledInputXs,
diff --git a/native/jni/src/suggest/core/result/suggestion_results.cpp b/native/jni/src/suggest/core/result/suggestion_results.cpp
index da1c6bc..088a55f 100644
--- a/native/jni/src/suggest/core/result/suggestion_results.cpp
+++ b/native/jni/src/suggest/core/result/suggestion_results.cpp
@@ -20,7 +20,8 @@
void SuggestionResults::outputSuggestions(JNIEnv *env, jintArray outSuggestionCount,
jintArray outputCodePointsArray, jintArray outScoresArray, jintArray outSpaceIndicesArray,
- jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray) {
+ jintArray outTypesArray, jintArray outAutoCommitFirstWordConfidenceArray,
+ jfloatArray outLanguageWeight) {
int outputIndex = 0;
while (!mSuggestedWords.empty()) {
const SuggestedWord &suggestedWord = mSuggestedWords.top();
@@ -50,6 +51,7 @@
mSuggestedWords.pop();
}
env->SetIntArrayRegion(outSuggestionCount, 0 /* start */, 1 /* len */, &outputIndex);
+ env->SetFloatArrayRegion(outLanguageWeight, 0 /* start */, 1 /* len */, &mLanguageWeight);
}
void SuggestionResults::addPrediction(const int *const codePoints, const int codePointCount,
@@ -94,6 +96,7 @@
}
void SuggestionResults::dumpSuggestions() const {
+ AKLOGE("language weight: %f", mLanguageWeight);
std::vector<SuggestedWord> suggestedWords;
auto copyOfSuggestedWords = mSuggestedWords;
while (!copyOfSuggestedWords.empty()) {
diff --git a/native/jni/src/suggest/core/result/suggestion_results.h b/native/jni/src/suggest/core/result/suggestion_results.h
index 020bab4..8e845e2 100644
--- a/native/jni/src/suggest/core/result/suggestion_results.h
+++ b/native/jni/src/suggest/core/result/suggestion_results.h
@@ -29,12 +29,13 @@
class SuggestionResults {
public:
explicit SuggestionResults(const int maxSuggestionCount)
- : mMaxSuggestionCount(maxSuggestionCount), mSuggestedWords() {}
+ : mMaxSuggestionCount(maxSuggestionCount), mLanguageWeight(NOT_A_LANGUAGE_WEIGHT),
+ mSuggestedWords() {}
// Returns suggestion count.
void outputSuggestions(JNIEnv *env, jintArray outSuggestionCount, jintArray outCodePointsArray,
jintArray outScoresArray, jintArray outSpaceIndicesArray, jintArray outTypesArray,
- jintArray outAutoCommitFirstWordConfidenceArray);
+ jintArray outAutoCommitFirstWordConfidenceArray, jfloatArray outLanguageWeight);
void addPrediction(const int *const codePoints, const int codePointCount, const int score);
void addSuggestion(const int *const codePoints, const int codePointCount,
const int score, const int type, const int indexToPartialCommit,
@@ -42,6 +43,10 @@
void getSortedScores(int *const outScores) const;
void dumpSuggestions() const;
+ void setLanguageWeight(const float languageWeight) {
+ mLanguageWeight = languageWeight;
+ }
+
int getSuggestionCount() const {
return mSuggestedWords.size();
}
@@ -50,6 +55,7 @@
DISALLOW_IMPLICIT_CONSTRUCTORS(SuggestionResults);
const int mMaxSuggestionCount;
+ float mLanguageWeight;
std::priority_queue<
SuggestedWord, std::vector<SuggestedWord>, SuggestedWord::Comparator> mSuggestedWords;
};
diff --git a/native/jni/src/suggest/core/result/suggestions_output_utils.cpp b/native/jni/src/suggest/core/result/suggestions_output_utils.cpp
index 83140f1..a307cb4 100644
--- a/native/jni/src/suggest/core/result/suggestions_output_utils.cpp
+++ b/native/jni/src/suggest/core/result/suggestions_output_utils.cpp
@@ -33,7 +33,7 @@
/* static */ void SuggestionsOutputUtils::outputSuggestions(
const Scoring *const scoringPolicy, DicTraverseSession *traverseSession,
- SuggestionResults *const outSuggestionResults) {
+ const float languageWeight, SuggestionResults *const outSuggestionResults) {
#if DEBUG_EVALUATE_MOST_PROBABLE_STRING
const int terminalSize = 0;
#else
@@ -43,9 +43,12 @@
for (int index = terminalSize - 1; index >= 0; --index) {
traverseSession->getDicTraverseCache()->popTerminal(&terminals[index]);
}
-
- const float languageWeight = scoringPolicy->getAdjustedLanguageWeight(
- traverseSession, terminals.data(), terminalSize);
+ // Compute a language weight when an invalid language weight is passed.
+ // NOT_A_LANGUAGE_WEIGHT (-1) is assumed as an invalid language weight.
+ const float languageWeightToOutputSuggestions = (languageWeight < 0.0f) ?
+ scoringPolicy->getAdjustedLanguageWeight(
+ traverseSession, terminals.data(), terminalSize) : languageWeight;
+ outSuggestionResults->setLanguageWeight(languageWeightToOutputSuggestions);
// Force autocorrection for obvious long multi-word suggestions when the top suggestion is
// a long multiple words suggestion.
// TODO: Implement a smarter auto-commit method for handling multi-word suggestions.
@@ -61,10 +64,11 @@
// Output suggestion results here
for (auto &terminalDicNode : terminals) {
outputSuggestionsOfDicNode(scoringPolicy, traverseSession, &terminalDicNode,
- languageWeight, boostExactMatches, forceCommitMultiWords,
+ languageWeightToOutputSuggestions, boostExactMatches, forceCommitMultiWords,
outputSecondWordFirstLetterInputIndex, outSuggestionResults);
}
- scoringPolicy->getMostProbableString(traverseSession, languageWeight, outSuggestionResults);
+ scoringPolicy->getMostProbableString(traverseSession, languageWeightToOutputSuggestions,
+ outSuggestionResults);
}
/* static */ void SuggestionsOutputUtils::outputSuggestionsOfDicNode(
diff --git a/native/jni/src/suggest/core/result/suggestions_output_utils.h b/native/jni/src/suggest/core/result/suggestions_output_utils.h
index 73cdb95..b099b47 100644
--- a/native/jni/src/suggest/core/result/suggestions_output_utils.h
+++ b/native/jni/src/suggest/core/result/suggestions_output_utils.h
@@ -33,7 +33,8 @@
* Outputs the final list of suggestions (i.e., terminal nodes).
*/
static void outputSuggestions(const Scoring *const scoringPolicy,
- DicTraverseSession *traverseSession, SuggestionResults *const outSuggestionResults);
+ DicTraverseSession *traverseSession, const float languageWeight,
+ SuggestionResults *const outSuggestionResults);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(SuggestionsOutputUtils);
diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp
index 303182c..433820a 100644
--- a/native/jni/src/suggest/core/suggest.cpp
+++ b/native/jni/src/suggest/core/suggest.cpp
@@ -44,7 +44,8 @@
*/
void Suggest::getSuggestions(ProximityInfo *pInfo, void *traverseSession,
int *inputXs, int *inputYs, int *times, int *pointerIds, int *inputCodePoints,
- int inputSize, SuggestionResults *const outSuggestionResults) const {
+ int inputSize, const float languageWeight,
+ SuggestionResults *const outSuggestionResults) const {
PROF_OPEN;
PROF_START(0);
const float maxSpatialDistance = TRAVERSAL->getMaxSpatialDistance();
@@ -65,7 +66,8 @@
}
PROF_END(1);
PROF_START(2);
- SuggestionsOutputUtils::outputSuggestions(SCORING, tSession, outSuggestionResults);
+ SuggestionsOutputUtils::outputSuggestions(
+ SCORING, tSession, languageWeight, outSuggestionResults);
PROF_END(2);
PROF_CLOSE;
}
diff --git a/native/jni/src/suggest/core/suggest.h b/native/jni/src/suggest/core/suggest.h
index 13ad621..788e031 100644
--- a/native/jni/src/suggest/core/suggest.h
+++ b/native/jni/src/suggest/core/suggest.h
@@ -49,7 +49,7 @@
AK_FORCE_INLINE virtual ~Suggest() {}
void getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs,
int *times, int *pointerIds, int *inputCodePoints, int inputSize,
- SuggestionResults *const outSuggestionResults) const;
+ const float languageWeight, SuggestionResults *const outSuggestionResults) const;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(Suggest);
diff --git a/native/jni/src/suggest/core/suggest_interface.h b/native/jni/src/suggest/core/suggest_interface.h
index c3ffea9..a6e5aef 100644
--- a/native/jni/src/suggest/core/suggest_interface.h
+++ b/native/jni/src/suggest/core/suggest_interface.h
@@ -28,7 +28,7 @@
public:
virtual void getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs,
int *inputYs, int *times, int *pointerIds, int *inputCodePoints, int inputSize,
- SuggestionResults *const suggestionResults) const = 0;
+ const float languageWeight, SuggestionResults *const suggestionResults) const = 0;
SuggestInterface() {}
virtual ~SuggestInterface() {}
private:
diff --git a/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp b/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp
index c4c5716..fa9600c 100644
--- a/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp
+++ b/native/jni/src/suggest/policyimpl/typing/scoring_params.cpp
@@ -52,8 +52,8 @@
const float ScoringParams::COST_NEW_WORD = 0.0314f;
const float ScoringParams::COST_SECOND_OR_LATER_WORD_FIRST_CHAR_UPPERCASE = 0.3224f;
const float ScoringParams::DISTANCE_WEIGHT_LANGUAGE = 1.1214f;
-const float ScoringParams::COST_FIRST_LOOKAHEAD = 0.4836f;
-const float ScoringParams::COST_LOOKAHEAD = 0.00624f;
+const float ScoringParams::COST_FIRST_COMPLETION = 0.4836f;
+const float ScoringParams::COST_COMPLETION = 0.00624f;
const float ScoringParams::HAS_PROXIMITY_TERMINAL_COST = 0.0683f;
const float ScoringParams::HAS_EDIT_CORRECTION_TERMINAL_COST = 0.0362f;
const float ScoringParams::HAS_MULTI_WORD_TERMINAL_COST = 0.4182f;
diff --git a/native/jni/src/suggest/policyimpl/typing/scoring_params.h b/native/jni/src/suggest/policyimpl/typing/scoring_params.h
index de7410d..b669620 100644
--- a/native/jni/src/suggest/policyimpl/typing/scoring_params.h
+++ b/native/jni/src/suggest/policyimpl/typing/scoring_params.h
@@ -59,8 +59,8 @@
static const float COST_NEW_WORD;
static const float COST_SECOND_OR_LATER_WORD_FIRST_CHAR_UPPERCASE;
static const float DISTANCE_WEIGHT_LANGUAGE;
- static const float COST_FIRST_LOOKAHEAD;
- static const float COST_LOOKAHEAD;
+ static const float COST_FIRST_COMPLETION;
+ static const float COST_COMPLETION;
static const float HAS_PROXIMITY_TERMINAL_COST;
static const float HAS_EDIT_CORRECTION_TERMINAL_COST;
static const float HAS_MULTI_WORD_TERMINAL_COST;
diff --git a/native/jni/src/suggest/policyimpl/typing/typing_weighting.h b/native/jni/src/suggest/policyimpl/typing/typing_weighting.h
index b36605a..0ba439b 100644
--- a/native/jni/src/suggest/policyimpl/typing/typing_weighting.h
+++ b/native/jni/src/suggest/policyimpl/typing/typing_weighting.h
@@ -166,8 +166,8 @@
const bool firstCompletion = dicNode->getInputIndex(0)
== traverseSession->getInputSize();
// TODO: Change the cost for the first completion for the gesture?
- const float cost = firstCompletion ? ScoringParams::COST_FIRST_LOOKAHEAD
- : ScoringParams::COST_LOOKAHEAD;
+ const float cost = firstCompletion ? ScoringParams::COST_FIRST_COMPLETION
+ : ScoringParams::COST_COMPLETION;
return cost;
}
diff --git a/native/jni/tests/utils/autocorrection_threshold_utils_test.cpp b/native/jni/tests/utils/autocorrection_threshold_utils_test.cpp
new file mode 100644
index 0000000..cc8db70
--- /dev/null
+++ b/native/jni/tests/utils/autocorrection_threshold_utils_test.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#include "utils/autocorrection_threshold_utils.h"
+
+#include <gtest/gtest.h>
+
+#include <vector>
+
+namespace latinime {
+namespace {
+
+int CalcEditDistance(const std::vector<int> &before,
+ const std::vector<int> &after) {
+ return AutocorrectionThresholdUtils::editDistance(
+ &before[0], before.size(), &after[0], after.size());
+}
+
+TEST(AutocorrectionThresholdUtilsTest, SameData) {
+ EXPECT_EQ(0, CalcEditDistance({1}, {1}));
+ EXPECT_EQ(0, CalcEditDistance({2, 2}, {2, 2}));
+ EXPECT_EQ(0, CalcEditDistance({3, 3, 3}, {3, 3, 3}));
+}
+
+} // namespace
+} // namespace latinime
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
index bbffc8d..d6d12ea 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java
@@ -25,7 +25,7 @@
@SmallTest
public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase {
- private static final int NUMBER_OF_SUBTYPES = 66;
+ private static final int NUMBER_OF_SUBTYPES = 67;
private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 42;
private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java b/tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java
new file mode 100644
index 0000000..0be1e37
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import static com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper.FORMAT_TYPE_FULL_LOCALE;
+import static com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper.FORMAT_TYPE_LANGUAGE_ONLY;
+import static com.android.inputmethod.keyboard.internal.LanguageOnSpacebarHelper.FORMAT_TYPE_NONE;
+
+import android.content.Context;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.view.inputmethod.InputMethodSubtype;
+
+import com.android.inputmethod.latin.RichInputMethodManager;
+import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
+import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+
+@SmallTest
+public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
+ private final LanguageOnSpacebarHelper mLanguageOnSpacebarHelper =
+ new LanguageOnSpacebarHelper();
+
+ private RichInputMethodManager mRichImm;
+
+ InputMethodSubtype EN_US_QWERTY;
+ InputMethodSubtype EN_GB_QWERTY;
+ InputMethodSubtype FR_AZERTY;
+ InputMethodSubtype FR_CA_QWERTY;
+ InputMethodSubtype FR_CH_SWISS;
+ InputMethodSubtype FR_CH_QWERTY;
+ InputMethodSubtype FR_CH_QWERTZ;
+ InputMethodSubtype ZZ_QWERTY;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ final Context context = getContext();
+ RichInputMethodManager.init(context);
+ mRichImm = RichInputMethodManager.getInstance();
+ SubtypeLocaleUtils.init(context);
+
+ EN_US_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.US.toString(), "qwerty");
+ EN_GB_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.UK.toString(), "qwerty");
+ FR_AZERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.FRENCH.toString(), "azerty");
+ FR_CA_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.CANADA_FRENCH.toString(), "qwerty");
+ FR_CH_SWISS = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "fr_CH", "swiss");
+ FR_CH_QWERTZ = AdditionalSubtypeUtils.createAdditionalSubtype(
+ "fr_CH", "qwertz", null);
+ FR_CH_QWERTY = AdditionalSubtypeUtils.createAdditionalSubtype(
+ "fr_CH", "qwerty", null);
+ ZZ_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
+ }
+
+ private static List<InputMethodSubtype> asList(final InputMethodSubtype ... subtypes) {
+ return Arrays.asList(subtypes);
+ }
+
+ public void testOneSubtype() {
+ mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY));
+ mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
+ assertEquals("one same English (US)", FORMAT_TYPE_NONE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
+ assertEquals("one same NoLanguage", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY));
+
+ mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(FR_AZERTY));
+ mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */);
+ assertEquals("one diff English (US)", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
+ assertEquals("one diff NoLanguage", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY));
+ }
+
+ public void testTwoSubtypes() {
+ mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY, FR_AZERTY));
+
+ mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
+ assertEquals("two same English (US)", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
+ assertEquals("two same French)", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_AZERTY));
+ assertEquals("two same NoLanguage", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY));
+
+ mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */);
+ assertEquals("two diff English (US)", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
+ assertEquals("two diff French", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_AZERTY));
+ assertEquals("two diff NoLanguage", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY));
+ }
+
+ public void testSameLanuageSubtypes() {
+ mLanguageOnSpacebarHelper.updateEnabledSubtypes(
+ asList(EN_US_QWERTY, EN_GB_QWERTY, FR_AZERTY, ZZ_QWERTY));
+
+ mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
+ assertEquals("two same English (US)", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
+ assertEquals("two same English (UK)", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_GB_QWERTY));
+ assertEquals("two same NoLanguage", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY));
+
+ mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */);
+ assertEquals("two diff English (US)", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
+ assertEquals("two diff English (UK)", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_GB_QWERTY));
+ assertEquals("two diff NoLanguage", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY));
+ }
+
+ public void testMultiSameLanuageSubtypes() {
+ mLanguageOnSpacebarHelper.updateEnabledSubtypes(
+ asList(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTY, FR_CH_QWERTZ));
+
+ mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
+ assertEquals("multi same French", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_AZERTY));
+ assertEquals("multi same French (CA)", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CA_QWERTY));
+ assertEquals("multi same French (CH)", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_SWISS));
+ assertEquals("multi same French (CH) (QWERTY)", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_QWERTY));
+ assertEquals("multi same French (CH) (QWERTZ)", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_QWERTZ));
+
+ mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */);
+ assertEquals("multi diff French", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_AZERTY));
+ assertEquals("multi diff French (CA)", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CA_QWERTY));
+ assertEquals("multi diff French (CH)", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_SWISS));
+ assertEquals("multi diff French (CH) (QWERTY)", FORMAT_TYPE_FULL_LOCALE,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_QWERTY));
+ assertEquals("multi diff French (CH) (QWERTZ)", FORMAT_TYPE_LANGUAGE_ONLY,
+ mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(FR_CH_QWERTZ));
+ }
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguageTests.java b/tests/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguageTests.java
deleted file mode 100644
index e03bce1..0000000
--- a/tests/src/com/android/inputmethod/keyboard/internal/NeedsToDisplayLanguageTests.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-
-package com.android.inputmethod.keyboard.internal;
-
-import android.content.Context;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.view.inputmethod.InputMethodSubtype;
-
-import com.android.inputmethod.latin.RichInputMethodManager;
-import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
-
-import java.util.Locale;
-
-@SmallTest
-public class NeedsToDisplayLanguageTests extends AndroidTestCase {
- private final NeedsToDisplayLanguage mNeedsToDisplayLanguage = new NeedsToDisplayLanguage();
-
- private RichInputMethodManager mRichImm;
-
- InputMethodSubtype EN_US;
- InputMethodSubtype FR;
- InputMethodSubtype ZZ;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- final Context context = getContext();
- RichInputMethodManager.init(context);
- mRichImm = RichInputMethodManager.getInstance();
- SubtypeLocaleUtils.init(context);
-
- EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.US.toString(), "qwerty");
- FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.FRENCH.toString(), "azerty");
- ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
- }
-
- public void testOneSubtype() {
- mNeedsToDisplayLanguage.updateEnabledSubtypeCount(1);
-
- mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
- assertFalse("one same English (US)", mNeedsToDisplayLanguage.needsToDisplayLanguage(EN_US));
- assertTrue("one same NoLanguage", mNeedsToDisplayLanguage.needsToDisplayLanguage(ZZ));
-
- mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */);
- assertTrue("one diff English (US)", mNeedsToDisplayLanguage.needsToDisplayLanguage(EN_US));
- assertTrue("one diff NoLanguage", mNeedsToDisplayLanguage.needsToDisplayLanguage(ZZ));
- }
-
- public void testTwoSubtype() {
- mNeedsToDisplayLanguage.updateEnabledSubtypeCount(2);
-
- mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
- assertTrue("two same English (US)", mNeedsToDisplayLanguage.needsToDisplayLanguage(EN_US));
- assertTrue("two same French", mNeedsToDisplayLanguage.needsToDisplayLanguage(FR));
- assertTrue("two same NoLanguage", mNeedsToDisplayLanguage.needsToDisplayLanguage(ZZ));
-
- mNeedsToDisplayLanguage.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */);
- assertTrue("two diff English (US)", mNeedsToDisplayLanguage.needsToDisplayLanguage(EN_US));
- assertTrue("two diff French", mNeedsToDisplayLanguage.needsToDisplayLanguage(ZZ));
- assertTrue("two diff NoLanguage", mNeedsToDisplayLanguage.needsToDisplayLanguage(FR));
- }
-}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java b/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java
new file mode 100644
index 0000000..bcf06f0
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/DevanagariLetterConstants.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.android.inputmethod.keyboard.layout;
+
+import android.os.Build;
+
+/**
+ * This class offers label strings of Devanagari letters that need the dotted circle to draw
+ * its glyph.
+ */
+class DevanagariLetterConstants {
+ private static final boolean NEEDS_DOTTED_CIRCLE =
+ Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN;
+ // U+25CC: "◌" DOTTED CIRCLE
+ private static final String DOTTED_CIRCLE = NEEDS_DOTTED_CIRCLE ? "\u25CC" : "";
+
+ // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
+ static final String SIGN_CANDRABINDU = DOTTED_CIRCLE + "\u0901";
+ // U+0902: "ं" DEVANAGARI SIGN ANUSVARA
+ static final String SIGN_ANUSVARA = DOTTED_CIRCLE + "\u0902";
+ // U+0903: "ः" DEVANAGARI SIGN VISARGA
+ static final String SIGN_VISARGA = DOTTED_CIRCLE + "\u0903";
+ // U+093C: "़" DEVANAGARI SIGN NUKTA
+ static final String SIGN_NUKTA = DOTTED_CIRCLE + "\u093C";
+ // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA
+ static final String SIGN_AVAGRAHA = DOTTED_CIRCLE + "\u093D";
+ // U+093E: "ा" DEVANAGARI VOWEL SIGN AA
+ static final String VOWEL_SIGN_AA = DOTTED_CIRCLE + "\u093E";
+ // U+093F: "ि" DEVANAGARI VOWEL SIGN I
+ static final String VOWEL_SIGN_I = DOTTED_CIRCLE + "\u093F";
+ // U+0940: "ी" DEVANAGARI VOWEL SIGN II
+ static final String VOWEL_SIGN_II = DOTTED_CIRCLE + "\u0940";
+ // U+0941: "ु" DEVANAGARI VOWEL SIGN U
+ static final String VOWEL_SIGN_U = DOTTED_CIRCLE + "\u0941";
+ // U+0942: "ू" DEVANAGARI VOWEL SIGN UU
+ static final String VOWEL_SIGN_UU = DOTTED_CIRCLE + "\u0942";
+ // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R
+ static final String VOWEL_SIGN_VOCALIC_R = DOTTED_CIRCLE + "\u0943";
+ // U+0944: "ॄ" DEVANAGARI VOWEL SIGN VOCALIC RR
+ static final String VOWEL_SIGN_VOCALIC_RR = DOTTED_CIRCLE + "\u0944";
+ // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E
+ static final String VOWEL_SIGN_CANDRA_E = DOTTED_CIRCLE + "\u0945";
+ // U+0947: "े" DEVANAGARI VOWEL SIGN E
+ static final String VOWEL_SIGN_E = DOTTED_CIRCLE + "\u0947";
+ // U+0948: "ै" DEVANAGARI VOWEL SIGN AI
+ static final String VOWEL_SIGN_AI = DOTTED_CIRCLE + "\u0948";
+ // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O
+ static final String VOWEL_SIGN_CANDRA_O = DOTTED_CIRCLE + "\u0949";
+ // U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O
+ static final String VOWEL_SIGN_SHORT_O = DOTTED_CIRCLE + "\u094A";
+ // U+094B: "ो" DEVANAGARI VOWEL SIGN O
+ static final String VOWEL_SIGN_O = DOTTED_CIRCLE + "\u094B";
+ // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU
+ static final String VOWEL_SIGN_AU = DOTTED_CIRCLE + "\u094C";
+ // U+094D: "्" DEVANAGARI SIGN VIRAMA
+ static final String SIGN_VIRAMA = DOTTED_CIRCLE + "\u094D";
+ // U+0970: "॰" DEVANAGARI ABBREVIATION SIGN
+ static final String ABBREVIATION_SIGN = DOTTED_CIRCLE + "\u0970";
+ // U+097D: "ॽ" DEVANAGARI LETTER GLOTTAL STOP
+ static final String LETTER_GLOTTAL_STOP = DOTTED_CIRCLE + "\u097D";
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java b/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java
index 7ff2dcb..c3f4531 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.keyboard.layout;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.*;
+
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
@@ -96,25 +98,37 @@
// U+094C: "ौ" DEVANAGARI VOWEL SIGN AU
// U+094C/U+0902: "ौं" DEVANAGARI VOWEL SIGN AU/DEVANAGARI SIGN ANUSVARA
// U+0967: "१" DEVANAGARI DIGIT ONE
- key("\u094C", joinMoreKeys("\u094C\u0902", "\u0967", "1")),
+ key(VOWEL_SIGN_AU, "\u094C", joinMoreKeys(
+ moreKey(VOWEL_SIGN_AU + "\u0902", "\u094C\u0902"),
+ "\u0967", "1")),
// U+0948: "ै" DEVANAGARI VOWEL SIGN AI
// U+0948/U+0902: "ैं" DEVANAGARI VOWEL SIGN AI/DEVANAGARI SIGN ANUSVARA
// U+0968: "२" DEVANAGARI DIGIT TWO
- key("\u0948", joinMoreKeys("\u0948\u0902", "\u0968", "2")),
+ key(VOWEL_SIGN_AI, "\u0948", joinMoreKeys(
+ moreKey(VOWEL_SIGN_AI + "\u0902", "\u0948\u0902"),
+ "\u0968", "2")),
// U+093E: "ा" DEVANAGARI VOWEL SIGN AA
// U+093E/U+0902: "ां" DEVANAGARI VOWEL SIGN AA/DEVANAGARI SIGN ANUSVARA
// U+093E/U+0901: "ाँ" DEVANAGARI VOWEL SIGN AA/DEVANAGARI SIGN CANDRABINDU
// U+0969: "३" DEVANAGARI DIGIT THREE
- key("\u093E", joinMoreKeys("\u093E\u0902", "\u093E\u0901", "\u0969", "3")),
+ key(VOWEL_SIGN_AA, "\u093E", joinMoreKeys(
+ moreKey(VOWEL_SIGN_AA + "\u0902", "\u093E\u0902"),
+ moreKey(VOWEL_SIGN_AA + "\u0901", "\u093E\u0901"),
+ "\u0969", "3")),
// U+0940: "ी" DEVANAGARI VOWEL SIGN II
// U+0940/U+0902: "ीं" DEVANAGARI VOWEL SIGN II/DEVANAGARI SIGN ANUSVARA
// U+096A: "४" DEVANAGARI DIGIT FOUR
- key("\u0940", joinMoreKeys("\u0940\u0902", "\u096A", "4")),
+ key(VOWEL_SIGN_II, "\u0940", joinMoreKeys(
+ moreKey(VOWEL_SIGN_II + "\u0902", "\u0940\u0902"),
+ "\u096A", "4")),
// U+0942: "ू" DEVANAGARI VOWEL SIGN UU
// U+0942/U+0902: "ूं" DEVANAGARI VOWEL SIGN UU/DEVANAGARI SIGN ANUSVARA
// U+0942/U+0901: "ूँ" DEVANAGARI VOWEL SIGN UU/DEVANAGARI SIGN CANDRABINDU
// U+096B: "५" DEVANAGARI DIGIT FIVE
- key("\u0942", joinMoreKeys("\u0942\u0902", "\u0942\u0901", "\u096B", "5")),
+ key(VOWEL_SIGN_UU, "\u0942", joinMoreKeys(
+ moreKey(VOWEL_SIGN_UU + "\u0902", "\u0942\u0902"),
+ moreKey(VOWEL_SIGN_UU + "\u0901", "\u0942\u0901"),
+ "\u096B", "5")),
// U+092C: "ब" DEVANAGARI LETTER BA
// U+092C/U+0952: "ब॒" DEVANAGARI LETTER BA/DEVANAGARI STRESS SIGN ANUDATTA
// U+096C: "६" DEVANAGARI DIGIT SIX
@@ -150,19 +164,26 @@
// U+094B/U+0902: "қं" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA
// U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O
// U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O
- key("\u094B", joinMoreKeys("\u094B\u0902", "\u0949", "\u094A")),
+ key(VOWEL_SIGN_O, "\u094B", joinMoreKeys(
+ moreKey(VOWEL_SIGN_O + "\u0902", "\u094B\u0902"),
+ moreKey(VOWEL_SIGN_CANDRA_O, "\u0949"),
+ moreKey(VOWEL_SIGN_SHORT_O, "\u094A"))),
// U+0947: "े" DEVANAGARI VOWEL SIGN E
// U+0947/U+0902: "ें" DEVANAGARI VOWEL SIGN E/DEVANAGARI SIGN ANUSVARA
- key("\u0947", moreKey("\u0947\u0902")),
+ key(VOWEL_SIGN_E, "\u0947",
+ moreKey(VOWEL_SIGN_E + "\u0902", "\u0947\u0902")),
// U+094D: "्" DEVANAGARI SIGN VIRAMA
- "\u094D",
+ key(SIGN_VIRAMA, "\u094D"),
// U+093F: "ि" DEVANAGARI VOWEL SIGN I
// U+093F/U+0902: "िं" DEVANAGARI VOWEL SIGN I/DEVANAGARI SIGN ANUSVARA
- key("\u093F", moreKey("\u093F\u0902")),
+ key(VOWEL_SIGN_I, "\u093F",
+ moreKey("\u093F" + SIGN_ANUSVARA, "\u093F\u0902")),
// U+0941: "ु" DEVANAGARI VOWEL SIGN U
// U+0941/U+0902: "ुं" DEVANAGARI VOWEL SIGN U/DEVANAGARI SIGN ANUSVARA
// U+0941/U+0901: "ुँ" DEVANAGARI VOWEL SIGN U/DEVANAGARI SIGN CANDRABINDU
- key("\u0941", joinMoreKeys("\u0941\u0902", "\u0941\u0901")),
+ key(VOWEL_SIGN_U, "\u0941", joinMoreKeys(
+ moreKey(VOWEL_SIGN_U + "\u0902", "\u0941\u0902"),
+ moreKey(VOWEL_SIGN_U + "\u0901", "\u0941\u0901"))),
// U+092A: "प" DEVANAGARI LETTER PA
"\u092A",
// U+0930: "र" DEVANAGARI LETTER RA
@@ -182,8 +203,9 @@
"\u091A","\u091F")
.setKeysOfRow(3,
// U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O
+ key(VOWEL_SIGN_CANDRA_O, "\u0949"),
// U+0902: "ं" DEVANAGARI SIGN ANUSVARA
- "\u0949", "\u0902",
+ key(SIGN_ANUSVARA, "\u0902"),
// U+092E: "म" DEVANAGARI LETTER MA
// U+0950: "ॐ" DEVANAGARI OM
key("\u092E", moreKey("\u0950")),
@@ -207,7 +229,10 @@
// U+097D: "ॽ" DEVANAGARI LETTER GLOTTAL STOP
// U+0970: "॰" DEVANAGARI ABBREVIATION SIGN
// U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA
- key("\u093C", joinMoreKeys("\u097D", "\u0970", "\u093D")))
+ key(SIGN_NUKTA, "\u093C", joinMoreKeys(
+ moreKey(LETTER_GLOTTAL_STOP, "\u097D"),
+ moreKey(ABBREVIATION_SIGN, "\u0970"),
+ moreKey(SIGN_AVAGRAHA, "\u093D"))))
.build();
private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder()
@@ -232,7 +257,7 @@
// U+092D: "भ" DEVANAGARI LETTER BHA
// U+0903: "ः" DEVANAGARI SIGN VISARGA
// U+0918: "घ" DEVANAGARI LETTER GHA
- "\u092D", "\u0903", "\u0918",
+ "\u092D", key(SIGN_VISARGA, "\u0903"), "\u0918",
// U+0927: "ध" DEVANAGARI LETTER DHA
// U+0915/U+094D/U+0937:
// "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA
@@ -285,7 +310,7 @@
"\u0911",
// U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
// U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E
- key("\u0901", moreKey("\u0945")),
+ key(SIGN_CANDRABINDU, "\u0901", moreKey(VOWEL_SIGN_CANDRA_E, "\u0945")),
// U+0923: "ण" DEVANAGARI LETTER NNA
// U+0929: "ऩ" DEVANAGARI LETTER NNNA
"\u0923", "\u0929",
@@ -297,7 +322,7 @@
"\u0936", "\u0937",
// U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R
// U+0944: "ॄ" DEVANAGARI VOWEL SIGN VOCALIC RR
- key("\u0943", moreKey("\u0944")),
+ key(VOWEL_SIGN_VOCALIC_R, "\u0943", moreKey(VOWEL_SIGN_VOCALIC_RR, "\u0944")),
// U+091E: "ञ" DEVANAGARI LETTER NYA
"\u091E")
.build();
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java b/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java
new file mode 100644
index 0000000..afd26e4
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.android.inputmethod.keyboard.layout;
+
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_ANUSVARA;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_CANDRABINDU;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_NUKTA;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_VIRAMA;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.SIGN_VISARGA;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_AA;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_AI;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_AU;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_CANDRA_E;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_CANDRA_O;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_E;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_I;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_II;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_O;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_U;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_UU;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.VOWEL_SIGN_VOCALIC_R;
+
+import com.android.inputmethod.keyboard.layout.Hindi.HindiCustomizer;
+import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols;
+import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
+import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
+import com.android.inputmethod.latin.Constants;
+
+import java.util.Locale;
+
+/**
+ * The Hindi Compact keyboard.
+ */
+public final class HindiCompact extends LayoutBase {
+ private static final String LAYOUT_NAME = "hindi_compact";
+
+ public HindiCompact(final LayoutCustomizer customizer) {
+ super(customizer, HindiSymbols.class, SymbolsShifted.class);
+ }
+
+ @Override
+ public String getName() { return LAYOUT_NAME; }
+
+ public static class HindiCompactCustomizer extends HindiCustomizer {
+ public HindiCompactCustomizer(final Locale locale) { super(locale); }
+
+ @Override
+ public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) {
+ return EMPTY_KEYS;
+ }
+
+ @Override
+ public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
+ // U+0964: "।" DEVANAGARI DANDA
+ final ExpectedKey periodKey = key("\u0964", getPunctuationMoreKeys(isPhone));
+ return isPhone ? joinKeys(periodKey) : joinKeys(",", periodKey);
+ }
+
+ @Override
+ public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) {
+ return isPhone ? HINDI_PHONE_PUNCTUATION_MORE_KEYS : HINDI_TABLET_PUNCTUATION_MORE_KEYS;
+ }
+
+ // Punctuation more keys for phone form factor.
+ private static final ExpectedKey[] HINDI_PHONE_PUNCTUATION_MORE_KEYS = joinKeys(
+ ",", ".", "?", "!", "#", ")", "(", "/", ";",
+ "'", "@", ":", "-", "\"", "+", "%", "&");
+ // Punctuation more keys for tablet form factor.
+ private static final ExpectedKey[] HINDI_TABLET_PUNCTUATION_MORE_KEYS = joinKeys(
+ ",", ".", "'", "#", ")", "(", "/", ";",
+ "@", ":", "-", "\"", "+", "%", "&");
+ }
+
+ @Override
+ ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; }
+
+ @Override
+ ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) {
+ return null;
+ }
+
+ private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
+ .setKeysOfRow(1,
+ // U+0914: "औ" DEVANAGARI LETTER AU
+ // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU
+ // U+0967: "१" DEVANAGARI DIGIT ONE
+ key("\u0914", joinMoreKeys(moreKey(VOWEL_SIGN_AU, "\u094C"), "\u0967", "1")),
+ // U+0910: "ऐ" DEVANAGARI LETTER AI
+ // U+0948: "ै" DEVANAGARI VOWEL SIGN AI
+ // U+0968: "२" DEVANAGARI DIGIT TWO
+ key("\u0910", joinMoreKeys(moreKey(VOWEL_SIGN_AI, "\u0948"), "\u0968", "2")),
+ // U+0906: "आ" DEVANAGARI LETTER AA
+ // U+093E: "ा" DEVANAGARI VOWEL SIGN AA
+ // U+0969: "३" DEVANAGARI DIGIT THREE
+ key("\u0906", joinMoreKeys(moreKey(VOWEL_SIGN_AA, "\u093E"), "\u0969", "3")),
+ // U+0908: "ई" DEVANAGARI LETTER II
+ // U+0940: "ी" DEVANAGARI VOWEL SIGN II
+ // U+096A: "४" DEVANAGARI DIGIT FOUR
+ key("\u0908", joinMoreKeys(moreKey(VOWEL_SIGN_II, "\u0940"), "\u096A", "4")),
+ // U+090A: "ऊ" DEVANAGARI LETTER UU
+ // U+0942: "ू" DEVANAGARI VOWEL SIGN UU
+ // U+096B: "५" DEVANAGARI DIGIT FIVE
+ key("\u090A", joinMoreKeys(moreKey(VOWEL_SIGN_UU, "\u0942"), "\u096B", "5")),
+ // U+092C: "ब" DEVANAGARI LETTER BA
+ // U+092D: "भ" DEVANAGARI LETTER BHA
+ // U+096C: "६" DEVANAGARI DIGIT SIX
+ key("\u092C", joinMoreKeys("\u092D", "\u096C", "6")),
+ // U+0939: "ह" DEVANAGARI LETTER HA
+ // U+096D: "७" DEVANAGARI DIGIT SEVEN
+ key("\u0939", joinMoreKeys("\u096D", "7")),
+ // U+0917: "ग" DEVANAGARI LETTER GA
+ // U+0918: "घ" DEVANAGARI LETTER GHA
+ // U+096E: "८" DEVANAGARI DIGIT EIGHT
+ key("\u0917", joinMoreKeys("\u0918", "\u096E", "8")),
+ // U+0926: "द" DEVANAGARI LETTER DA
+ // U+0927: "ध" DEVANAGARI LETTER DHA
+ // U+096F: "९" DEVANAGARI DIGIT NINE
+ key("\u0926", joinMoreKeys("\u0927", "\u096F", "9")),
+ // U+091C: "ज" DEVANAGARI LETTER JA
+ // U+091D: "झ" DEVANAGARI LETTER JHA
+ // U+091C/U+094D/U+091E:
+ // "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA
+ // U+0966: "०" DEVANAGARI DIGIT ZERO
+ key("\u091C", joinMoreKeys("\u091D", "\u091C\u094D\u091E", "\u0966", "0")),
+ // U+0921: "ड" DEVANAGARI LETTER DDA
+ // U+0922: "ढ" DEVANAGARI LETTER DDHA
+ key("\u0921", moreKey("\u0922")))
+ .setKeysOfRow(2,
+ // U+0913: "ओ" DEVANAGARI LETTER O
+ // U+094B: "ो" DEVANAGARI VOWEL SIGN O
+ key("\u0913", moreKey(VOWEL_SIGN_O, "\u094B")),
+ // U+090F: "ए" DEVANAGARI LETTER E
+ // U+0947: "े" DEVANAGARI VOWEL SIGN E
+ key("\u090F", moreKey(VOWEL_SIGN_E, "\u0947")),
+ // U+0905: "अ" DEVANAGARI LETTER A
+ // U+094D: "्" DEVANAGARI SIGN VIRAMA
+ key("\u0905", moreKey(SIGN_VIRAMA, "\u094D")),
+ // U+0907: "इ" DEVANAGARI LETTER I
+ // U+093F: "ि" DEVANAGARI VOWEL SIGN I
+ key("\u0907", moreKey(VOWEL_SIGN_I, "\u093F")),
+ // U+0909: "उ" DEVANAGARI LETTER U
+ // U+0941: "ु" DEVANAGARI VOWEL SIGN U
+ key("\u0909", moreKey(VOWEL_SIGN_U, "\u0941")),
+ // U+092A: "प" DEVANAGARI LETTER PA
+ // U+092B: "फ" DEVANAGARI LETTER PHA
+ key("\u092A", moreKey("\u092B")),
+ // U+0930: "र" DEVANAGARI LETTER RA
+ // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R
+ // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R
+ key("\u0930", joinMoreKeys("\u090B", moreKey(VOWEL_SIGN_VOCALIC_R, "\u0943"))),
+ // U+0915: "क" DEVANAGARI LETTER KA
+ // U+0916: "ख" DEVANAGARI LETTER KHA
+ key("\u0915", moreKey("\u0916")),
+ // U+0924: "त" DEVANAGARI LETTER TA
+ // U+0925: "थ" DEVANAGARI LETTER THA
+ // U+0924/U+094D/U+0930:
+ // "त्र" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA
+ key("\u0924", joinMoreKeys("\u0925", "\u0924\u094D\u0930")),
+ // U+091A: "च" DEVANAGARI LETTER CA
+ // U+091B: "छ" DEVANAGARI LETTER CHA
+ key("\u091A", moreKey("\u091B")),
+ // U+091F: "ट" DEVANAGARI LETTER TTA
+ // U+0920: "ठ" DEVANAGARI LETTER TTHA
+ key("\u091F", moreKey("\u0920")))
+ .setKeysOfRow(3,
+ // U+0911: "ऑ" DEVANAGARI LETTER CANDRA O
+ // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O
+ key("\u0911", moreKey(VOWEL_SIGN_CANDRA_O, "\u0949")),
+ // U+090D: "ऍ" DEVANAGARI LETTER CANDRA E
+ // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E
+ key("\u090D", moreKey(VOWEL_SIGN_CANDRA_E, "\u0945")),
+ // U+0902: "ं" DEVANAGARI SIGN ANUSVARA
+ // U+0903: "ः" DEVANAGARI SIGN VISARGA
+ // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
+ // U+093C: "़" DEVANAGARI SIGN NUKTA
+ key(SIGN_ANUSVARA, "\u0902", joinMoreKeys(
+ moreKey(SIGN_VISARGA, "\u0903"),
+ moreKey(SIGN_CANDRABINDU, "\u0901"),
+ moreKey(SIGN_NUKTA, "\u093C"))),
+ // U+092E: "म" DEVANAGARI LETTER MA
+ // U+0950: "ॐ" DEVANAGARI OM
+ key("\u092E", moreKey("\u0950")),
+ // U+0928: "न" DEVANAGARI LETTER NA
+ // U+0923: "ण" DEVANAGARI LETTER NNA
+ // U+091E: "ञ" DEVANAGARI LETTER NYA
+ // U+0919: "ङ" DEVANAGARI LETTER NGA
+ key("\u0928", joinMoreKeys("\u0923", "\u091E", "\u0919")),
+ // U+0935: "व" DEVANAGARI LETTER VA
+ // U+0932: "ल" DEVANAGARI LETTER LA
+ "\u0935", "\u0932",
+ // U+0938: "स" DEVANAGARI LETTER SA
+ // U+0936: "श" DEVANAGARI LETTER SHA
+ // U+0937: "ष" DEVANAGARI LETTER SSA
+ // U+0936/U+094D/U+0930:
+ // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA
+ key("\u0938", joinMoreKeys("\u0936", "\u0937", "\u0936\u094D\u0930")),
+ // U+092F: "य" DEVANAGARI LETTER YA
+ // U+0915/U+094D/U+0937:
+ // "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA
+ "\u092F", "\u0915\u094D\u0937")
+ .build();
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java
index 09cc8f9..4123a22 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java
@@ -180,8 +180,7 @@
* @return the array of {@link ExpectedKey} that are "more keys" of the punctuation key.
*/
public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) {
- return isPhone ? PHONE_PUNCTUATION_MORE_KEYS
- : TABLET_PUNCTUATION_MORE_KEYS;
+ return isPhone ? PHONE_PUNCTUATION_MORE_KEYS : TABLET_PUNCTUATION_MORE_KEYS;
}
}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java b/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java
index 7cfe344..7048dbb 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.keyboard.layout;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.*;
+
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.layout.Hindi.HindiCustomizer;
import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols;
@@ -70,13 +72,13 @@
// U+091F: "ट" DEVANAGARI LETTER TTA
// U+0967: "१" DEVANAGARI DIGIT ONE
// U+093C: "़" DEVANAGARI SIGN NUKTA
- key("\u091F", joinMoreKeys("\u0967", "1", "\u093C")),
+ key("\u091F", joinMoreKeys("\u0967", "1", key(SIGN_NUKTA, "\u093C"))),
// U+094C: "ौ" DEVANAGARI VOWEL SIGN AU
// U+0968: "२" DEVANAGARI DIGIT TWO
- key("\u094C", joinMoreKeys("\u0968", "2")),
+ key(VOWEL_SIGN_AU, "\u094C", joinMoreKeys("\u0968", "2")),
// U+0947: "े" DEVANAGARI VOWEL SIGN E
// U+0969: "३" DEVANAGARI DIGIT THREE
- key("\u0947", joinMoreKeys("\u0969", "3")),
+ key(VOWEL_SIGN_E, "\u0947", joinMoreKeys("\u0969", "3")),
// U+0930: "र" DEVANAGARI LETTER RA
// U+096A: "४" DEVANAGARI DIGIT FOUR
key("\u0930", joinMoreKeys("\u096A", "4")),
@@ -88,13 +90,13 @@
key("\u092F", joinMoreKeys("\u096C", "6")),
// U+0941: "ु" DEVANAGARI VOWEL SIGN U
// U+096D: "७" DEVANAGARI DIGIT SEVEN
- key("\u0941", joinMoreKeys("\u096D", "7")),
+ key(VOWEL_SIGN_U, "\u0941", joinMoreKeys("\u096D", "7")),
// U+093F: "ि" DEVANAGARI VOWEL SIGN I
// U+096E: "८" DEVANAGARI DIGIT EIGHT
- key("\u093F", joinMoreKeys("\u096E", "8")),
+ key(VOWEL_SIGN_I, "\u093F", joinMoreKeys("\u096E", "8")),
// U+094B: "ो" DEVANAGARI VOWEL SIGN O
// U+096F: "९" DEVANAGARI DIGIT NINE
- key("\u094B", joinMoreKeys("\u096F", "9")),
+ key(VOWEL_SIGN_O, "\u094B", joinMoreKeys("\u096F", "9")),
// U+092A: "प" DEVANAGARI LETTER PA
// U+0966: "०" DEVANAGARI DIGIT ZERO
key("\u092A", joinMoreKeys("\u0966", "0")),
@@ -102,6 +104,7 @@
"\u0907")
.setKeysOfRow(2,
// U+093E: "ा" DEVANAGARI VOWEL SIGN AA
+ key(VOWEL_SIGN_AA, "\u093E"),
// U+0938: "स" DEVANAGARI LETTER SA
// U+0926: "द" DEVANAGARI LETTER DA
// U+0909: "उ" DEVANAGARI LETTER U
@@ -112,8 +115,8 @@
// U+0932: "ल" DEVANAGARI LETTER LA
// U+090F: "ए" DEVANAGARI LETTER E
// U+0950: "ॐ" DEVANAGARI OM
- "\u093E", "\u0938", "\u0926", "\u0909", "\u0917", "\u0939", "\u091C", "\u0915",
- "\u0932", "\u090F", "\u0950")
+ "\u0938", "\u0926", "\u0909", "\u0917", "\u0939", "\u091C", "\u0915", "\u0932",
+ "\u090F", "\u0950")
.setKeysOfRow(3,
// U+0937: "ष" DEVANAGARI LETTER SSA
// U+0921: "ड" DEVANAGARI LETTER DDA
@@ -127,23 +130,28 @@
// U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA
key("\u0964", moreKey("\u093D")),
// U+094D: "्" DEVANAGARI SIGN VIRAMA
- "\u094D")
+ key(SIGN_VIRAMA, "\u094D"))
.build();
private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder()
.setKeysOfRow(1,
// U+0920: "ठ" DEVANAGARI LETTER TTHA
// U+0914: "औ" DEVANAGARI LETTER AU
+ "\u0920", "\u0914",
// U+0948: "ै" DEVANAGARI VOWEL SIGN AI
+ key(VOWEL_SIGN_AI, "\u0948"),
// U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R
+ key(VOWEL_SIGN_VOCALIC_R, "\u0943"),
// U+0925: "थ" DEVANAGARI LETTER THA
// U+091E: "ञ" DEVANAGARI LETTER NYA
+ "\u0925", "\u091E",
// U+0942: "ू" DEVANAGARI VOWEL SIGN UU
+ key(VOWEL_SIGN_UU, "\u0942"),
// U+0940: "ी" DEVANAGARI VOWEL SIGN II
+ key(VOWEL_SIGN_II, "\u0940"),
// U+0913: "ओ" DEVANAGARI LETTER O
// U+092B: "फ" DEVANAGARI LETTER PHA
// U+0908: "ई" DEVANAGARI LETTER II
- "\u0920", "\u0914", "\u0948", "\u0943", "\u0925", "\u091E", "\u0942", "\u0940",
"\u0913", "\u092B", "\u0908")
.setKeysOfRow(2,
// U+0906: "आ" DEVANAGARI LETTER AA
@@ -158,18 +166,22 @@
// U+0910: "ऐ" DEVANAGARI LETTER AI
// U+0903: "ः" DEVANAGARI SIGN VISARGA
"\u0906", "\u0936", "\u0927", "\u090A", "\u0918", "\u0905", "\u091D", "\u0916",
- "\u0965", "\u0910", "\u0903")
+ "\u0965", "\u0910", key(SIGN_VISARGA, "\u0903"))
.setKeysOfRow(3,
// U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R
// U+0922: "ढ" DEVANAGARI LETTER DDHA
// U+091B: "छ" DEVANAGARI LETTER CHA
+ "\u090B", "\u0922", "\u091B",
// U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
+ key(SIGN_CANDRABINDU, "\u0901"),
// U+092D: "भ" DEVANAGARI LETTER BHA
// U+0923: "ण" DEVANAGARI LETTER NNA
+ "\u092D", "\u0923",
// U+0902: "ं" DEVANAGARI SIGN ANUSVARA
+ key(SIGN_ANUSVARA, "\u0902"),
// U+0919: "ङ" DEVANAGARI LETTER NGA
+ "\u0919",
// U+094D: "्" DEVANAGARI SIGN VIRAMA
- "\u090B", "\u0922", "\u091B", "\u0901", "\u092D", "\u0923", "\u0902", "\u0919",
- "\u094D")
+ key(SIGN_VIRAMA, "\u094D"))
.build();
}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java b/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java
index 1599fd7..4d6cded 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.keyboard.layout;
+import static com.android.inputmethod.keyboard.layout.DevanagariLetterConstants.*;
+
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols;
import com.android.inputmethod.keyboard.layout.NepaliRomanized.NepaliRomanizedCustomizer;
@@ -47,7 +49,7 @@
public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
if (isPhone) {
// U+094D: "्" DEVANAGARI SIGN VIRAMA
- return joinKeys(key("\u094D", PHONE_PUNCTUATION_MORE_KEYS));
+ return joinKeys(key(SIGN_VIRAMA, "\u094D", PHONE_PUNCTUATION_MORE_KEYS));
}
return super.getKeysRightToSpacebar(isPhone);
}
@@ -61,7 +63,8 @@
// U+0947: "े" DEVANAGARI VOWEL SIGN E
// U+0903: "ः" DEVANAGARI SIGN VISARGA
// U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA
- key("\u0947", joinMoreKeys("\u0903", "\u093D")),
+ key(VOWEL_SIGN_E, "\u0947", joinMoreKeys(
+ moreKey(SIGN_VISARGA, "\u0903"), "\u093D")),
// U+0964: "।" DEVANAGARI DANDA
"\u0964",
// U+0930: "र" DEVANAGARI LETTER RA
@@ -71,14 +74,15 @@
builder.addKeysOnTheRightOfRow(3,
// U+0903: "ः" DEVANAGARI SIGN VISARGA
// U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA
- key("\u0903", moreKey("\u093D")),
+ key(SIGN_VISARGA, "\u0903", moreKey("\u093D")),
// U+0947: "े" DEVANAGARI VOWEL SIGN E
+ key(VOWEL_SIGN_E, "\u0947"),
// U+0964: "।" DEVANAGARI DANDA
- "\u0947", "\u0964",
+ "\u0964",
// U+0930: "र" DEVANAGARI LETTER RA
key("\u0930", moreKey("!")),
// U+094D: "्" DEVANAGARI SIGN VIRAMA
- key("\u094D", moreKey("?")));
+ key(SIGN_VIRAMA, "\u094D", moreKey("?")));
}
return builder.build();
}
@@ -93,21 +97,23 @@
if (isPhone) {
builder.addKeysOnTheRightOfRow(3,
// U+0902: "ं" DEVANAGARI SIGN ANUSVARA
+ key(SIGN_ANUSVARA, "\u0902"),
// U+0919: "ङ" DEVANAGARI LETTER NGA
- "\u0902", "\u0919",
+ "\u0919",
// U+0948: "ै" DEVANAGARI VOWEL SIGN AI
// U+0936/U+094D/U+0930:
// "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA
- key("\u0948", moreKey("\u0936\u094D\u0930")));
+ key(VOWEL_SIGN_AI, "\u0948", moreKey("\u0936\u094D\u0930")));
} else {
builder.addKeysOnTheRightOfRow(3,
// U+0902: "ं" DEVANAGARI SIGN ANUSVARA
+ key(SIGN_ANUSVARA, "\u0902"),
// U+0919: "ङ" DEVANAGARI LETTER NGA
- "\u0902", "\u0919",
+ "\u0919",
// U+0948: "ै" DEVANAGARI VOWEL SIGN AI
// U+0936/U+094D/U+0930:
// "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA
- key("\u0948", moreKey("\u0936\u094D\u0930")),
+ key(VOWEL_SIGN_AI, "\u0948", moreKey("\u0936\u094D\u0930")),
// U+0930/U+0941: "रु" DEVANAGARI LETTER RA/DEVANAGARI VOWEL SIGN U
key("\u0930\u0941", moreKey("!")),
"?");
@@ -154,16 +160,20 @@
// U+092C: "ब" DEVANAGARI LETTER BA
// U+0915: "क" DEVANAGARI LETTER KA
// U+092E: "म" DEVANAGARI LETTER MA
+ "\u092C", "\u0915", "\u092E",
// U+093E: "ा" DEVANAGARI VOWEL SIGN AA
+ key(VOWEL_SIGN_AA, "\u093E"),
// U+0928: "न" DEVANAGARI LETTER NA
// U+091C: "ज" DEVANAGARI LETTER JA
// U+0935: "व" DEVANAGARI LETTER VA
// U+092A: "प" DEVANAGARI LETTER PA
+ "\u0928", "\u091C", "\u0935", "\u092A",
// U+093F: "ि" DEVANAGARI VOWEL SIGN I
+ key(VOWEL_SIGN_I, "\u093F"),
// U+0938: "स" DEVANAGARI LETTER SA
+ "\u0938",
// U+0941: "ु" DEVANAGARI VOWEL SIGN U
- "\u092C", "\u0915", "\u092E", "\u093E", "\u0928", "\u091C", "\u0935", "\u092A",
- "\u093F", "\u0938", "\u0941")
+ key(VOWEL_SIGN_U, "\u0941"))
.setKeysOfRow(3,
// U+0936: "श" DEVANAGARI LETTER SHA
// U+0939: "ह" DEVANAGARI LETTER HA
@@ -219,34 +229,41 @@
key("\u090F", moreKey("\u0923")),
// U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R
// U+0913: "ओ" DEVANAGARI LETTER O
- key("\u0943", moreKey("\u0913")))
+ key(VOWEL_SIGN_VOCALIC_R, "\u0943", moreKey("\u0913")))
.setKeysOfRow(2,
// U+0906: "आ" DEVANAGARI LETTER AA
// U+0919/U+094D: "ङ्" DEVANAGARI LETTER NGA/DEVANAGARI SIGN VIRAMA
// U+0921/U+094D/U+0921:
// "ड्ड" DEVANAGARI LETTER DDA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DDA
+ "\u0906", "\u0919\u094D", "\u0921\u094D\u0921",
// U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU
+ key(SIGN_CANDRABINDU, "\u0901"),
// U+0926/U+094D/U+0926:
// "द्द" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DA
// U+091D: "झ" DEVANAGARI LETTER JHA
+ "\u0926\u094D\u0926", "\u091D",
// U+094B: "ो" DEVANAGARI VOWEL SIGN O
+ key(VOWEL_SIGN_O, "\u094B"),
// U+092B: "फ" DEVANAGARI LETTER PHA
+ "\u092B",
// U+0940: "ी" DEVANAGARI VOWEL SIGN II
+ key(VOWEL_SIGN_II, "\u0940"),
// U+091F/U+094D/U+0920:
// "ट्ठ" DEVANAGARI LETTER TTA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER TTHA
+ "\u091F\u094D\u0920",
// U+0942: "ू" DEVANAGARI VOWEL SIGN UU
- "\u0906", "\u0919\u094D", "\u0921\u094D\u0921", "\u0901", "\u0926\u094D\u0926",
- "\u091D", "\u094B", "\u092B", "\u0940", "\u091F\u094D\u0920", "\u0942")
+ key(VOWEL_SIGN_UU, "\u0942"))
.setKeysOfRow(3,
// U+0915/U+094D: "क्" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA
// U+0939/U+094D/U+092E:
// "ह्म" DEVANAGARI LETTER HA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER MA
// U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R
// U+0950: "ॐ" DEVANAGARI OM
+ "\u0915\u094D", "\u0939\u094D\u092E", "\u090B", "\u0950",
// U+094C: "ौ" DEVANAGARI VOWEL SIGN AU
+ key(VOWEL_SIGN_AU, "\u094C"),
// U+0926/U+094D/U+092F:
// "द्य" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER YA
- "\u0915\u094D", "\u0939\u094D\u092E", "\u090B", "\u0950", "\u094C",
"\u0926\u094D\u092F")
.build();
}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java
new file mode 100644
index 0000000..2e676df
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindiCompact.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package com.android.inputmethod.keyboard.layout.tests;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.android.inputmethod.keyboard.layout.HindiCompact;
+import com.android.inputmethod.keyboard.layout.HindiCompact.HindiCompactCustomizer;
+import com.android.inputmethod.keyboard.layout.LayoutBase;
+
+import java.util.Locale;
+
+/**
+ * hi: Hindi/hindi_compact
+ */
+@SmallTest
+public final class TestsHindiCompact extends LayoutTestsBase {
+ private static final Locale LOCALE = new Locale("hi");
+ private static final LayoutBase LAYOUT = new HindiCompact(new HindiCompactCustomizer(LOCALE));
+
+ @Override
+ LayoutBase getLayout() { return LAYOUT; }
+}
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index b366452..d2dd292 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -16,7 +16,10 @@
package com.android.inputmethod.latin;
+import com.android.inputmethod.latin.settings.Settings;
+
import android.test.suitebuilder.annotation.LargeTest;
+import android.text.TextUtils;
import android.view.inputmethod.BaseInputConnection;
@LargeTest
@@ -179,6 +182,8 @@
}
public void testDoubleSpace() {
+ // Set default pref just in case
+ setBooleanPreference(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true, true);
// U+1F607 is an emoji
final String[] STRINGS_TO_TYPE =
new String[] { "this ", "a+ ", "\u1F607 ", ".. ", ") ", "( ", "% " };
@@ -200,6 +205,76 @@
assertEquals("double space make a period", EXPECTED_RESULT, mEditText.getText().toString());
}
+ private void testDoubleSpacePeriodWithSettings(final boolean expectsPeriod,
+ final Object... settingsKeysValues) {
+ final Object[] oldSettings = new Object[settingsKeysValues.length / 2];
+ final String STRING_WITHOUT_PERIOD = "this ";
+ final String STRING_WITH_PERIOD = "this. ";
+ final String EXPECTED_RESULT = expectsPeriod ? STRING_WITH_PERIOD : STRING_WITHOUT_PERIOD;
+ try {
+ for (int i = 0; i < settingsKeysValues.length; i += 2) {
+ if (settingsKeysValues[i + 1] instanceof String) {
+ oldSettings[i / 2] = setStringPreference((String)settingsKeysValues[i],
+ (String)settingsKeysValues[i + 1], "0");
+ } else {
+ oldSettings[i / 2] = setBooleanPreference((String)settingsKeysValues[i],
+ (Boolean)settingsKeysValues[i + 1], false);
+ }
+ }
+ mLatinIME.loadSettings();
+ mEditText.setText("");
+ type(STRING_WITHOUT_PERIOD);
+ assertEquals("double-space-to-period with specific settings "
+ + TextUtils.join(" ", settingsKeysValues),
+ EXPECTED_RESULT, mEditText.getText().toString());
+ } finally {
+ // Restore old settings
+ for (int i = 0; i < settingsKeysValues.length; i += 2) {
+ if (null == oldSettings[i / 2]) {
+ break;
+ } if (oldSettings[i / 2] instanceof String) {
+ setStringPreference((String)settingsKeysValues[i], (String)oldSettings[i / 2],
+ "");
+ } else {
+ setBooleanPreference((String)settingsKeysValues[i], (Boolean)oldSettings[i / 2],
+ false);
+ }
+ }
+ }
+ }
+
+ public void testDoubleSpacePeriod() {
+ // Reset settings to default, else these tests will go flaky.
+ setStringPreference(Settings.PREF_SHOW_SUGGESTIONS_SETTING, "0", "0");
+ setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD, "1", "1");
+ setBooleanPreference(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true, true);
+ testDoubleSpacePeriodWithSettings(true /* expectsPeriod */);
+ // "Suggestion visibility" to "always hide"
+ testDoubleSpacePeriodWithSettings(true, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "2");
+ // "Suggestion visibility" to "portrait only"
+ testDoubleSpacePeriodWithSettings(true, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "1");
+ // "Suggestion visibility" to "always show"
+ testDoubleSpacePeriodWithSettings(true, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "0");
+
+ // "Double-space period" to "off"
+ testDoubleSpacePeriodWithSettings(false, Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, false);
+
+ // "Auto-correction" to "off"
+ testDoubleSpacePeriodWithSettings(true, Settings.PREF_AUTO_CORRECTION_THRESHOLD, "0");
+ // "Auto-correction" to "modest"
+ testDoubleSpacePeriodWithSettings(true, Settings.PREF_AUTO_CORRECTION_THRESHOLD, "1");
+ // "Auto-correction" to "very aggressive"
+ testDoubleSpacePeriodWithSettings(true, Settings.PREF_AUTO_CORRECTION_THRESHOLD, "3");
+
+ // "Suggestion visibility" to "always hide" and "Auto-correction" to "off"
+ testDoubleSpacePeriodWithSettings(true, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "0",
+ Settings.PREF_AUTO_CORRECTION_THRESHOLD, "0");
+ // "Suggestion visibility" to "always hide" and "Auto-correction" to "off"
+ testDoubleSpacePeriodWithSettings(false, Settings.PREF_SHOW_SUGGESTIONS_SETTING, "0",
+ Settings.PREF_AUTO_CORRECTION_THRESHOLD, "0",
+ Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, false);
+ }
+
public void testBackspaceAtStartAfterAutocorrect() {
final String STRING_TO_TYPE = "tgis ";
final int typedLength = STRING_TO_TYPE.length();
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index 690c559..1383ff9 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -65,7 +65,6 @@
protected MyEditText mEditText;
protected View mInputView;
protected InputConnection mInputConnection;
- private boolean mPreviousDebugSetting;
private boolean mPreviousBigramPredictionSettings;
private String mPreviousAutoCorrectSetting;
@@ -185,7 +184,7 @@
mEditText.setEnabled(true);
setupService();
mLatinIME = getService();
- mPreviousDebugSetting = setDebugMode(true);
+ setDebugMode(true);
mPreviousBigramPredictionSettings = setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS,
true, true /* defaultValue */);
mPreviousAutoCorrectSetting = setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD,
@@ -219,7 +218,7 @@
true /* defaultValue */);
setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD, mPreviousAutoCorrectSetting,
DEFAULT_AUTO_CORRECTION_THRESHOLD);
- setDebugMode(mPreviousDebugSetting);
+ setDebugMode(false);
super.tearDown();
}
diff --git a/tools/dicttool/tests/etc/test-dicttool.sh b/tools/dicttool/tests/etc/test-dicttool.sh
index 5eb44fc..f96db68 100755
--- a/tools/dicttool/tests/etc/test-dicttool.sh
+++ b/tools/dicttool/tests/etc/test-dicttool.sh
@@ -18,7 +18,7 @@
echo " source $0" 1>&2
echo " or" 1>&2
echo " . $0" 1>&2
-exit 1
+if [[ ${BASH_SOURCE[0]} != $0 ]]; then return; else exit 1; fi
fi
find out -name "dicttool_aosp*" -exec rm -rf {} \; > /dev/null 2>&1