aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/Android.mk1
-rw-r--r--java/res/drawable-hdpi/more_keys_divider.pngbin0 -> 1034 bytes
-rw-r--r--java/res/drawable-mdpi/more_keys_divider.pngbin0 -> 2940 bytes
-rw-r--r--java/res/drawable-xhdpi/more_keys_divider.pngbin0 -> 1053 bytes
-rw-r--r--java/res/values-be/donottranslate-more-keys.xml4
-rw-r--r--java/res/values-ky/donottranslate-more-keys.xml6
-rw-r--r--java/res/values-mk/donottranslate-more-keys.xml48
-rw-r--r--java/res/values-ru/donottranslate-more-keys.xml2
-rw-r--r--java/res/values-uk/donottranslate-more-keys.xml4
-rw-r--r--java/res/values/donottranslate-more-keys.xml31
-rw-r--r--java/res/values/donottranslate.xml4
-rw-r--r--java/res/values/strings.xml6
-rw-r--r--java/res/xml-el/keyboard_set.xml42
-rw-r--r--java/res/xml-mk/keyboard_set.xml42
-rw-r--r--java/res/xml-sw600dp/rows_greek.xml170
-rw-r--r--java/res/xml-sw600dp/rows_number_normal.xml42
-rw-r--r--java/res/xml-sw600dp/rows_serbian.xml18
-rw-r--r--java/res/xml-sw600dp/rows_slavic.xml16
-rw-r--r--java/res/xml-sw768dp/rows_greek.xml177
-rw-r--r--java/res/xml-sw768dp/rows_number_normal.xml42
-rw-r--r--java/res/xml-sw768dp/rows_serbian.xml17
-rw-r--r--java/res/xml-sw768dp/rows_slavic.xml16
-rw-r--r--java/res/xml/kbd_greek.xml26
-rw-r--r--java/res/xml/key_styles_enter.xml16
-rw-r--r--java/res/xml/key_styles_number.xml15
-rw-r--r--java/res/xml/method.xml17
-rw-r--r--java/res/xml/rows_greek.xml185
-rw-r--r--java/res/xml/rows_number_normal.xml64
-rw-r--r--java/res/xml/rows_phone.xml6
-rw-r--r--java/res/xml/rows_serbian.xml18
-rw-r--r--java/res/xml/rows_slavic.xml20
-rw-r--r--java/res/xml/spellchecker.xml6
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java377
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java11
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java164
-rw-r--r--java/src/com/android/inputmethod/accessibility/FlickGestureDetector.java5
-rw-r--r--java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java18
-rw-r--r--java/src/com/android/inputmethod/compat/AccessibilityEventCompatUtils.java22
-rw-r--r--java/src/com/android/inputmethod/compat/AccessibilityManagerCompatUtils.java (renamed from java/src/com/android/inputmethod/compat/AccessibilityManagerCompatWrapper.java)12
-rw-r--r--java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java5
-rw-r--r--java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java2
-rw-r--r--java/src/com/android/inputmethod/compat/ViewParentCompatUtils.java51
-rw-r--r--java/src/com/android/inputmethod/deprecated/VoiceProxy.java38
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java23
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyDetector.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java17
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardId.java31
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSet.java3
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java19
-rw-r--r--java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java64
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java7
-rw-r--r--java/src/com/android/inputmethod/keyboard/ProximityInfo.java53
-rw-r--r--java/src/com/android/inputmethod/latin/ComposingStateManager.java7
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java73
-rw-r--r--java/src/com/android/inputmethod/latin/LatinImeLogger.java2
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java7
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java66
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java47
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java4
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java76
62 files changed, 1780 insertions, 491 deletions
diff --git a/java/Android.mk b/java/Android.mk
index fd71d82e0..52cc18b26 100644
--- a/java/Android.mk
+++ b/java/Android.mk
@@ -30,6 +30,7 @@ LOCAL_REQUIRED_MODULES := libjni_latinime
LOCAL_STATIC_JAVA_LIBRARIES := android-common
LOCAL_STATIC_JAVA_LIBRARIES += inputmethod-common
+LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
# Do not compress dictionary files to mmap dict data runtime
LOCAL_AAPT_FLAGS := -0 .dict
diff --git a/java/res/drawable-hdpi/more_keys_divider.png b/java/res/drawable-hdpi/more_keys_divider.png
new file mode 100644
index 000000000..a5912f95c
--- /dev/null
+++ b/java/res/drawable-hdpi/more_keys_divider.png
Binary files differ
diff --git a/java/res/drawable-mdpi/more_keys_divider.png b/java/res/drawable-mdpi/more_keys_divider.png
new file mode 100644
index 000000000..a46284f21
--- /dev/null
+++ b/java/res/drawable-mdpi/more_keys_divider.png
Binary files differ
diff --git a/java/res/drawable-xhdpi/more_keys_divider.png b/java/res/drawable-xhdpi/more_keys_divider.png
new file mode 100644
index 000000000..178594bf0
--- /dev/null
+++ b/java/res/drawable-xhdpi/more_keys_divider.png
Binary files differ
diff --git a/java/res/values-be/donottranslate-more-keys.xml b/java/res/values-be/donottranslate-more-keys.xml
index 0917f11ec..1550ddb17 100644
--- a/java/res/values-be/donottranslate-more-keys.xml
+++ b/java/res/values-be/donottranslate-more-keys.xml
@@ -19,7 +19,7 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- U+045E: "ў" CYRILLIC SMALL LETTER SHORT U -->
- <string name="keylabel_for_slavic_shcha">&#x045E;</string>
+ <string name="keylabel_for_cyrillic_shcha">&#x045E;</string>
<!-- U+0456: "і" CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I -->
- <string name="keylabel_for_slavic_i">&#x0456;</string>
+ <string name="keylabel_for_cyrillic_i">&#x0456;</string>
</resources>
diff --git a/java/res/values-ky/donottranslate-more-keys.xml b/java/res/values-ky/donottranslate-more-keys.xml
index 824620987..b67a9f15d 100644
--- a/java/res/values-ky/donottranslate-more-keys.xml
+++ b/java/res/values-ky/donottranslate-more-keys.xml
@@ -19,9 +19,9 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- U+04AF: "ү" CYRILLIC SMALL LETTER STRAIGHT U -->
- <string name="more_keys_for_slavic_u">&#x04AF;</string>
+ <string name="more_keys_for_cyrillic_u">&#x04AF;</string>
<!-- U+04A3: "ң" CYRILLIC SMALL LETTER EN WITH DESCENDER -->
- <string name="more_keys_for_slavic_en">&#x04A3;</string>
+ <string name="more_keys_for_cyrillic_en">&#x04A3;</string>
<!-- U+04E9: "ө" CYRILLIC SMALL LETTER BARRED O -->
- <string name="more_keys_for_slavic_o">&#x04E9;</string>
+ <string name="more_keys_for_cyrillic_o">&#x04E9;</string>
</resources>
diff --git a/java/res/values-mk/donottranslate-more-keys.xml b/java/res/values-mk/donottranslate-more-keys.xml
new file mode 100644
index 000000000..e96a306b6
--- /dev/null
+++ b/java/res/values-mk/donottranslate-more-keys.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- NOTE: Macedonian layouts are based on Serbian ones with the following key replacements. -->
+ <!-- U+0455: "ѕ" CYRILLIC SMALL LETTER DZE -->
+ <string name="keylabel_for_cyrillic_ze">&#x0455;</string>
+ <!-- U+045C: "ќ" CYRILLIC SMALL LETTER KJE -->
+ <string name="keylabel_for_cyrillic_tshe">&#x045C;</string>
+ <!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
+ <string name="keylabel_for_cyrillic_dze">&#x0437;</string>
+ <!-- U+0453: "ѓ" CYRILLIC SMALL LETTER GJE -->
+ <string name="keylabel_for_cyrillic_dje">&#x0453;</string>
+ <!-- U+0450: "ѐ" CYRILLIC SMALL LETTER IE WITH GRAVE -->
+ <string name="more_keys_for_cyrillic_ie">&#x0450;</string>
+ <!-- U+045D: "ѝ" CYRILLIC SMALL LETTER I WITH GRAVE -->
+ <string name="more_keys_for_cyrillic_i">&#x045D;</string>
+ <!-- U+2018: "‘" LEFT SINGLE QUOTATION MARK
+ U+2019: "’" RIGHT SINGLE QUOTATION MARK
+ U+201A: "‚" SINGLE LOW-9 QUOTATION MARK
+ U+201B: "‛" SINGLE HIGH-REVERSED-9 QUOTATION MARK
+ U+201C: "“" LEFT DOUBLE QUOTATION MARK
+ U+201D: "”" RIGHT DOUBLE QUOTATION MARK
+ U+201E: "„" DOUBLE LOW-9 QUOTATION MARK
+ U+201F: "‟" DOUBLE HIGH-REVERSED-9 QUOTATION MARK -->
+ <!-- TODO: Neither DroidSans nor Roboto have the glyph for U+201F DOUBLE HIGH-REVERSED-9 QUOTATION MARK. -->
+ <!-- <string name="more_keys_for_double_quote">!fixedColumnOrder!6,&#x201E;,&#x201C;,&#x201D;,&#x201F;,&#x00AB;,&#x00BB;</string> -->
+ <string name="more_keys_for_double_quote">!fixedColumnOrder!5,&#x201E;,&#x201C;,&#x201D;,&#x00AB;,&#x00BB;</string>
+ <!-- TODO: Neither DroidSans nor Roboto have the glyph for U+201F DOUBLE HIGH-REVERSED-9 QUOTATION MARK. -->
+ <!-- <string name="more_keys_for_tablet_double_quote">!fixedColumnOrder!6,&#x201C;,&#x201D;,&#x201E;,&#x201F;,&#x00AB;,&#x00BB;,&#x2018;,&#x2019;,&#x201A;,&#x201B;</string> -->
+ <string name="more_keys_for_tablet_double_quote">!fixedColumnOrder!5,&#x201E;,&#x201C;,&#x201D;,&#x00AB;,&#x00BB;,&#x2018;,&#x2019;,&#x201A;,&#x201B;</string>
+</resources>
diff --git a/java/res/values-ru/donottranslate-more-keys.xml b/java/res/values-ru/donottranslate-more-keys.xml
index 45c4551a1..a1a22e5aa 100644
--- a/java/res/values-ru/donottranslate-more-keys.xml
+++ b/java/res/values-ru/donottranslate-more-keys.xml
@@ -19,5 +19,5 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- U+0451: "ё" CYRILLIC SMALL LETTER IO -->
- <string name="more_keys_for_slavic_ye">&#x0451;</string>
+ <string name="more_keys_for_cyrillic_ye">&#x0451;</string>
</resources>
diff --git a/java/res/values-uk/donottranslate-more-keys.xml b/java/res/values-uk/donottranslate-more-keys.xml
index 3208a6649..323eaafbb 100644
--- a/java/res/values-uk/donottranslate-more-keys.xml
+++ b/java/res/values-uk/donottranslate-more-keys.xml
@@ -19,7 +19,7 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- U+0456: "і" CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I -->
- <string name="keylabel_for_slavic_yery">&#x0456;</string>
+ <string name="keylabel_for_cyrillic_yery">&#x0456;</string>
<!-- U+0457: "ї" CYRILLIC SMALL LETTER YI -->
- <string name="more_keys_for_slavic_yery">&#x0457;</string>
+ <string name="more_keys_for_cyrillic_yery">&#x0457;</string>
</resources>
diff --git a/java/res/values/donottranslate-more-keys.xml b/java/res/values/donottranslate-more-keys.xml
index 40d81177f..6577acdb9 100644
--- a/java/res/values/donottranslate-more-keys.xml
+++ b/java/res/values/donottranslate-more-keys.xml
@@ -41,20 +41,30 @@
<string name="more_keys_for_scandinavia_row2_10"></string>
<string name="more_keys_for_scandinavia_row2_11"></string>
<!-- U+0449: "щ" CYRILLIC SMALL LETTER SHCHA -->
- <string name="keylabel_for_slavic_shcha">&#x0449;</string>
+ <string name="keylabel_for_cyrillic_shcha">&#x0449;</string>
<!-- U+044B: "ы" CYRILLIC SMALL LETTER YERU -->
- <string name="keylabel_for_slavic_yery">&#x044B;</string>
+ <string name="keylabel_for_cyrillic_yery">&#x044B;</string>
<!-- U+0438: "и" CYRILLIC SMALL LETTER I -->
- <string name="keylabel_for_slavic_i">&#x0438;</string>
- <string name="more_keys_for_slavic_u"></string>
- <string name="more_keys_for_slavic_ye"></string>
- <string name="more_keys_for_slavic_en"></string>
+ <string name="keylabel_for_cyrillic_i">&#x0438;</string>
+ <!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
+ <string name="keylabel_for_cyrillic_ze">&#x0437;</string>
+ <!-- U+045B: "ћ" CYRILLIC SMALL LETTER TSHE -->
+ <string name="keylabel_for_cyrillic_tshe">&#x045B;</string>
+ <!-- U+0455: "ѕ" CYRILLIC SMALL LETTER DZE -->
+ <string name="keylabel_for_cyrillic_dze">&#x0455;</string>
+ <!-- U+0452: "ђ" CYRILLIC SMALL LETTER DJE -->
+ <string name="keylabel_for_cyrillic_dje">&#x0452;</string>
+ <string name="more_keys_for_cyrillic_u"></string>
+ <string name="more_keys_for_cyrillic_ye"></string>
+ <string name="more_keys_for_cyrillic_en"></string>
<!-- U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN -->
- <string name="more_keys_for_slavic_ha">&#x044A;</string>
- <string name="more_keys_for_slavic_yery"></string>
- <string name="more_keys_for_slavic_o"></string>
+ <string name="more_keys_for_cyrillic_ha">&#x044A;</string>
+ <string name="more_keys_for_cyrillic_yery"></string>
+ <string name="more_keys_for_cyrillic_o"></string>
<!-- U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN -->
- <string name="more_keys_for_slavic_soft_sign">&#x044A;</string>
+ <string name="more_keys_for_cyrillic_soft_sign">&#x044A;</string>
+ <string name="more_keys_for_cyrillic_ie"></string>
+ <string name="more_keys_for_cyrillic_i"></string>
<!-- U+00A2: "¢" CENT SIGN
U+00A3: "£" POUND SIGN
U+20AC: "€" EURO SIGN
@@ -115,6 +125,7 @@
<!-- U+207F: "ⁿ" SUPERSCRIPT LATIN SMALL LETTER N
U+2205: "∅" EMPTY SET -->
<string name="more_keys_for_symbols_0">&#x207F;,&#x2205;</string>
+ <string name="more_keys_for_am_pm">!fixedColumnOrder!2,!hasLabels!,\@string/label_time_am,\@string/label_time_pm</string>
<string name="settings_as_more_key">\@icon/settingsKey|\@integer/key_settings</string>
<string name="keylabel_for_comma">,</string>
<string name="more_keys_for_comma"></string>
diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml
index 94da9462f..d6a15deb0 100644
--- a/java/res/values/donottranslate.xml
+++ b/java/res/values/donottranslate.xml
@@ -58,6 +58,10 @@
<!-- U+FF0A: "*" FULLWIDTH ASTERISK
U+FF03: "#" FULLWIDTH NUMBER SIGN -->
<string name="label_to_phone_symbols_key">&#xFF0A;&#xFF03;</string>
+ <!-- Key label for "ante meridiem" -->
+ <string name="label_time_am">"AM"</string>
+ <!-- Key label for "post meridiem" -->
+ <string name="label_time_pm">"PM"</string>
<!-- Always show the suggestion strip -->
<string name="prefs_suggestion_visibility_show_value">0</string>
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index 516c60731..d8a3a689e 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -27,8 +27,10 @@
<!-- Title for Latin keyboard input options dialog [CHAR LIMIT=25] -->
<string name="english_ime_input_options">Input options</string>
- <!-- Title for Latin Keyboard spell checker service -->
- <string name="spell_checker_service_name">Android correction</string>
+ <!-- Name of Android spell checker service -->
+ <string name="spell_checker_service_name">Android spell checker</string>
+ <!-- Name of Android spell checker service. AOSP(Android Open Source Project) should not be translated. -->
+ <string name="aosp_spell_checker_service_name">Android spell checker (AOSP)</string>
<!-- Title for the spell checking service settings screen -->
<string name="android_spell_checker_settings">Spell checking settings</string>
diff --git a/java/res/xml-el/keyboard_set.xml b/java/res/xml-el/keyboard_set.xml
new file mode 100644
index 000000000..19ecb771b
--- /dev/null
+++ b/java/res/xml-el/keyboard_set.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<KeyboardSet
+ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:keyboardLocale="el">
+ <Element
+ latin:elementName="alphabet"
+ latin:elementKeyboard="@xml/kbd_greek" />
+ <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" />
+</KeyboardSet>
diff --git a/java/res/xml-mk/keyboard_set.xml b/java/res/xml-mk/keyboard_set.xml
new file mode 100644
index 000000000..31199cb0a
--- /dev/null
+++ b/java/res/xml-mk/keyboard_set.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<KeyboardSet
+ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:keyboardLocale="mk">
+ <Element
+ latin:elementName="alphabet"
+ latin:elementKeyboard="@xml/kbd_serbian" />
+ <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" />
+</KeyboardSet>
diff --git a/java/res/xml-sw600dp/rows_greek.xml b/java/res/xml-sw600dp/rows_greek.xml
new file mode 100644
index 000000000..c77627e59
--- /dev/null
+++ b/java/res/xml-sw600dp/rows_greek.xml
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+ <include
+ latin:keyboardLayout="@xml/key_styles_common" />
+ <Row
+ latin:keyWidth="9.0%p"
+ >
+ <Key
+ latin:keyLabel=";" />
+ <!-- TODO: Should find a way to compound Greek dialytika tonos and other Greek letters. -->
+ <!--
+ <switch>
+ <case
+ latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted"
+ >
+ U+0385: "΅" GREEK DIALYTIKA TONOS
+ <Key
+ latin:keyLabel="&#x0385;" />
+ </case>
+ <default>
+ -->
+ <!-- U+03C2: "ς" GREEK SMALL LETTER FINAL SIGMA -->
+ <Key
+ latin:keyLabel="&#x03C2;"
+ latin:keyLabelFlags="preserveCase" />
+ <!--
+ </default>
+ </switch>
+ -->
+ <!-- U+03B5: "ε" GREEK SMALL LETTER EPSILON
+ U+03AD: "έ" GREEK SMALL LETTER EPSILON WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03B5;"
+ latin:moreKeys="&#x03AD;" />
+ <!-- U+03C1: "ρ" GREEK SMALL LETTER RHO -->
+ <Key
+ latin:keyLabel="&#x03C1;" />
+ <!-- U+03C4: "τ" GREEK SMALL LETTER TAU -->
+ <Key
+ latin:keyLabel="&#x03C4;" />
+ <!-- U+03C5: "υ" GREEK SMALL LETTER UPSILON
+ U+03CD: "ύ" GREEK SMALL LETTER UPSILON WITH TONOS
+ U+03CB: "ϋ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+ U+03B0: "ΰ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS -->
+ <Key
+ latin:keyLabel="&#x03C5;"
+ latin:moreKeys="&#x03CD;,&#x03CB;,&#x03B0;" />
+ <!-- U+03B8: "θ" GREEK SMALL LETTER THETA -->
+ <Key
+ latin:keyLabel="&#x03B8;" />
+ <!-- U+03B9: "ι" GREEK SMALL LETTER IOTA
+ U+03AF: "ί" GREEK SMALL LETTER IOTA WITH TONOS
+ U+03CA: "ϊ" GREEK SMALL LETTER IOTA WITH DIALYTIKA
+ U+0390: "ΐ" GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS -->
+ <Key
+ latin:keyLabel="&#x03B9;"
+ latin:moreKeys="&#x03AF;,&#x03CA;,&#x0390;" />
+ <!-- U+03BF: "ο" GREEK SMALL LETTER OMICRON
+ U+03CC: "ό" GREEK SMALL LETTER OMICRON WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03BF;"
+ latin:moreKeys="&#x03CC;" />
+ <!-- U+03C0: "π" GREEK SMALL LETTER PI -->
+ <Key
+ latin:keyLabel="&#x03C0;" />
+ <Key
+ latin:keyStyle="deleteKeyStyle"
+ latin:keyXPos="-10.0%p"
+ latin:keyWidth="fillBoth" />
+ </Row>
+ <Row
+ latin:keyWidth="9.0%p"
+ >
+ <!-- U+03B1: "α" GREEK SMALL LETTER ALPHA
+ U+03AC: "ά" GREEK SMALL LETTER ALPHA WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03B1;"
+ latin:moreKeys="&#x03AC;"
+ latin:keyXPos="4.5%p" />
+ <!-- U+03C3: "σ" GREEK SMALL LETTER SIGMA -->
+ <Key
+ latin:keyLabel="&#x03C3;" />
+ <!-- U+03B4: "δ" GREEK SMALL LETTER DELTA -->
+ <Key
+ latin:keyLabel="&#x03B4;" />
+ <!-- U+03C6: "φ" GREEK SMALL LETTER PHI -->
+ <Key
+ latin:keyLabel="&#x03C6;" />
+ <!-- U+03B3: "γ" GREEK SMALL LETTER GAMMA -->
+ <Key
+ latin:keyLabel="&#x03B3;" />
+ <!-- U+03B7: "η" GREEK SMALL LETTER ETA
+ U+03AE: "ή" GREEK SMALL LETTER ETA WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03B7;"
+ latin:moreKeys="&#x03AE;" />
+ <!-- U+03BE: "ξ" GREEK SMALL LETTER XI -->
+ <Key
+ latin:keyLabel="&#x03BE;" />
+ <!-- U+03BA: "κ" GREEK SMALL LETTER KAPPA -->
+ <Key
+ latin:keyLabel="&#x03BA;" />
+ <!-- U+03BB: "λ" GREEK SMALL LETTER LAMDA -->
+ <Key
+ latin:keyLabel="&#x03BB;" />
+ <Key
+ latin:keyStyle="enterKeyStyle"
+ latin:keyXPos="-14.6%p"
+ latin:keyWidth="fillBoth" />
+ </Row>
+ <Row
+ latin:keyWidth="8.9%p"
+ >
+ <Key
+ latin:keyStyle="shiftKeyStyle"
+ latin:keyWidth="10.0%p" />
+ <!-- U+03B6: "ζ" GREEK SMALL LETTER ZETA -->
+ <Key
+ latin:keyLabel="&#x03B6;" />
+ <!-- U+03C7: "χ" GREEK SMALL LETTER CHI -->
+ <Key
+ latin:keyLabel="&#x03C7;" />
+ <!-- U+03C8: "ψ" GREEK SMALL LETTER PSI -->
+ <Key
+ latin:keyLabel="&#x03C8;" />
+ <!-- U+03C9: "ω" GREEK SMALL LETTER OMEGA
+ U+03CE: "ώ" GREEK SMALL LETTER OMEGA WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03C9;"
+ latin:moreKeys="&#x03CE;" />
+ <!-- U+03B2: "β" GREEK SMALL LETTER BETA -->
+ <Key
+ latin:keyLabel="&#x03B2;" />
+ <!-- U+03BD: "ν" GREEK SMALL LETTER NU -->
+ <Key
+ latin:keyLabel="&#x03BD;" />
+ <!-- U+03BC: "μ" GREEK SMALL LETTER MU -->
+ <Key
+ latin:keyLabel="&#x03BC;" />
+ <include
+ latin:keyboardLayout="@xml/keys_comma_period" />
+ <include
+ latin:keyboardLayout="@xml/key_smiley"
+ latin:keyXPos="-8.9%p"
+ latin:keyWidth="fillBoth" />
+ </Row>
+ <include
+ latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>
diff --git a/java/res/xml-sw600dp/rows_number_normal.xml b/java/res/xml-sw600dp/rows_number_normal.xml
index 1c38a6265..3704c5284 100644
--- a/java/res/xml-sw600dp/rows_number_normal.xml
+++ b/java/res/xml-sw600dp/rows_number_normal.xml
@@ -63,10 +63,24 @@
latin:keyLabel="/"
latin:keyStyle="numKeyStyle"
latin:keyWidth="9.25%p" />
- <Key
- latin:keyLabel=","
- latin:keyStyle="numKeyStyle"
- latin:keyWidth="9.25%p" />
+ <switch>
+ <case
+ latin:mode="time|datetime"
+ >
+ <Key
+ latin:keyLabel=","
+ latin:keyLabelFlags="hasPopupHint"
+ latin:moreKeys="@string/more_keys_for_am_pm"
+ latin:keyStyle="numKeyStyle"
+ latin:keyWidth="9.25%p" />
+ </case>
+ <default>
+ <Key
+ latin:keyLabel=","
+ latin:keyStyle="numKeyStyle"
+ latin:keyWidth="9.25%p" />
+ </default>
+ </switch>
<Key
latin:keyLabel="4"
latin:keyStyle="numKeyStyle"
@@ -94,10 +108,22 @@
latin:keyLabel=")"
latin:keyStyle="numKeyStyle"
latin:keyWidth="9.25%p" />
- <Key
- latin:keyLabel="="
- latin:keyStyle="numKeyStyle"
- latin:keyWidth="9.25%p" />
+ <switch>
+ <case
+ latin:mode="time|datetime"
+ >
+ <Key
+ latin:keyLabel=":"
+ latin:keyStyle="numKeyStyle"
+ latin:keyWidth="9.25%p" />
+ </case>
+ <default>
+ <Key
+ latin:keyLabel="="
+ latin:keyStyle="numKeyStyle"
+ latin:keyWidth="9.25%p" />
+ </default>
+ </switch>
<Key
latin:keyLabel="7"
latin:keyStyle="numKeyStyle"
diff --git a/java/res/xml-sw600dp/rows_serbian.xml b/java/res/xml-sw600dp/rows_serbian.xml
index 5730aa050..989fa488c 100644
--- a/java/res/xml-sw600dp/rows_serbian.xml
+++ b/java/res/xml-sw600dp/rows_serbian.xml
@@ -35,22 +35,23 @@
latin:keyLabel="&#x045A;" />
<!-- U+0435: "е" CYRILLIC SMALL LETTER IE -->
<Key
- latin:keyLabel="&#x0435;" />
+ latin:keyLabel="&#x0435;"
+ latin:moreKeys="@string/more_keys_for_cyrillic_ie" />
<!-- U+0440: "р" CYRILLIC SMALL LETTER ER -->
<Key
latin:keyLabel="&#x0440;" />
<!-- U+0442: "т" CYRILLIC SMALL LETTER TE -->
<Key
latin:keyLabel="&#x0442;" />
- <!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
<Key
- latin:keyLabel="&#x0437;" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_ze" />
<!-- U+0443: "у" CYRILLIC SMALL LETTER U -->
<Key
latin:keyLabel="&#x0443;" />
<!-- U+0438: "и" CYRILLIC SMALL LETTER I -->
<Key
- latin:keyLabel="&#x0438;" />
+ latin:keyLabel="&#x0438;"
+ latin:moreKeys="@string/more_keys_for_cyrillic_i" />
<!-- U+043E: "о" CYRILLIC SMALL LETTER O -->
<Key
latin:keyLabel="&#x043E;" />
@@ -98,9 +99,8 @@
<!-- U+0447: "ч" CYRILLIC SMALL LETTER CHE -->
<Key
latin:keyLabel="&#x0447;" />
- <!-- U+045B: "ћ" CYRILLIC SMALL LETTER TSHE -->
<Key
- latin:keyLabel="&#x045B;" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_tshe" />
<Key
latin:keyStyle="enterKeyStyle"
latin:keyXPos="-14.6%p"
@@ -112,9 +112,8 @@
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="8.0%p" />
- <!-- U+0455: "ѕ" CYRILLIC SMALL LETTER DZE -->
<Key
- latin:keyLabel="&#x0455;" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_dze" />
<!-- U+045F: "џ" CYRILLIC SMALL LETTER DZHE -->
<Key
latin:keyLabel="&#x045F;" />
@@ -133,9 +132,8 @@
<!-- U+043C: "м" CYRILLIC SMALL LETTER EM -->
<Key
latin:keyLabel="&#x043C;" />
- <!-- U+0452: "ђ" CYRILLIC SMALL LETTER DJE -->
<Key
- latin:keyLabel="&#x0452;" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_dje" />
<!-- U+0436: "ж" CYRILLIC SMALL LETTER ZHE -->
<Key
latin:keyLabel="&#x0436;" />
diff --git a/java/res/xml-sw600dp/rows_slavic.xml b/java/res/xml-sw600dp/rows_slavic.xml
index 58f0b3900..7ff63bc0e 100644
--- a/java/res/xml-sw600dp/rows_slavic.xml
+++ b/java/res/xml-sw600dp/rows_slavic.xml
@@ -35,18 +35,18 @@
<!-- U+0443: "у" CYRILLIC SMALL LETTER U -->
<Key
latin:keyLabel="&#x0443;"
- latin:moreKeys="@string/more_keys_for_slavic_u" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_u" />
<!-- U+043A: "к" CYRILLIC SMALL LETTER KA -->
<Key
latin:keyLabel="&#x043A;" />
<!-- U+0435: "е" CYRILLIC SMALL LETTER IE -->
<Key
latin:keyLabel="&#x0435;"
- latin:moreKeys="@string/more_keys_for_slavic_ye" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_ye" />
<!-- U+043D: "н" CYRILLIC SMALL LETTER EN -->
<Key
latin:keyLabel="&#x043D;"
- latin:moreKeys="@string/more_keys_for_slavic_en" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_en" />
<!-- U+0433: "г" CYRILLIC SMALL LETTER GHE -->
<Key
latin:keyLabel="&#x0433;" />
@@ -54,7 +54,7 @@
<Key
latin:keyLabel="&#x0448;" />
<Key
- latin:keyLabel="@string/keylabel_for_slavic_shcha" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_shcha" />
<!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
<Key
latin:keyLabel="&#x0437;" />
@@ -77,8 +77,8 @@
latin:keyLabel="&#x0444;"
latin:keyXPos="2.25%p" />
<Key
- latin:keyLabel="@string/keylabel_for_slavic_yery"
- latin:moreKeys="@string/more_keys_for_slavic_yery" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_yery"
+ latin:moreKeys="@string/more_keys_for_cyrillic_yery" />
<!-- U+0432: "в" CYRILLIC SMALL LETTER VE -->
<Key
latin:keyLabel="&#x0432;" />
@@ -94,7 +94,7 @@
<!-- U+043E: "о" CYRILLIC SMALL LETTER O -->
<Key
latin:keyLabel="&#x043E;"
- latin:moreKeys="@string/more_keys_for_slavic_o" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_o" />
<!-- U+043B: "л" CYRILLIC SMALL LETTER EL -->
<Key
latin:keyLabel="&#x043B;" />
@@ -130,7 +130,7 @@
<Key
latin:keyLabel="&#x043C;" />
<Key
- latin:keyLabel="@string/keylabel_for_slavic_i" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_i" />
<!-- U+0442: "т" CYRILLIC SMALL LETTER TE -->
<Key
latin:keyLabel="&#x0442;" />
diff --git a/java/res/xml-sw768dp/rows_greek.xml b/java/res/xml-sw768dp/rows_greek.xml
new file mode 100644
index 000000000..e9a76a588
--- /dev/null
+++ b/java/res/xml-sw768dp/rows_greek.xml
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+ <include
+ latin:keyboardLayout="@xml/key_styles_common" />
+ <Row
+ latin:keyWidth="8.282%p"
+ >
+ <Key
+ latin:keyStyle="tabKeyStyle"
+ latin:keyLabelFlags="alignLeft"
+ latin:keyWidth="7.969%p" />
+ <Key
+ latin:keyLabel=";" />
+ <!-- TODO: Should find a way to compound Greek dialytika tonos and other Greek letters. -->
+ <!--
+ <switch>
+ <case
+ latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted"
+ >
+ U+0385: "΅" GREEK DIALYTIKA TONOS
+ <Key
+ latin:keyLabel="&#x0385;" />
+ </case>
+ <default>
+ -->
+ <!-- U+03C2: "ς" GREEK SMALL LETTER FINAL SIGMA -->
+ <Key
+ latin:keyLabel="&#x03C2;"
+ latin:keyLabelFlags="preserveCase" />
+ <!--
+ </default>
+ </switch>
+ -->
+ <!-- U+03B5: "ε" GREEK SMALL LETTER EPSILON
+ U+03AD: "έ" GREEK SMALL LETTER EPSILON WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03B5;"
+ latin:moreKeys="&#x03AD;" />
+ <!-- U+03C1: "ρ" GREEK SMALL LETTER RHO -->
+ <Key
+ latin:keyLabel="&#x03C1;" />
+ <!-- U+03C4: "τ" GREEK SMALL LETTER TAU -->
+ <Key
+ latin:keyLabel="&#x03C4;" />
+ <!-- U+03C5: "υ" GREEK SMALL LETTER UPSILON
+ U+03CD: "ύ" GREEK SMALL LETTER UPSILON WITH TONOS
+ U+03CB: "ϋ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+ U+03B0: "ΰ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS -->
+ <Key
+ latin:keyLabel="&#x03C5;"
+ latin:moreKeys="&#x03CD;,&#x03CB;,&#x03B0;" />
+ <!-- U+03B8: "θ" GREEK SMALL LETTER THETA -->
+ <Key
+ latin:keyLabel="&#x03B8;" />
+ <!-- U+03B9: "ι" GREEK SMALL LETTER IOTA
+ U+03AF: "ί" GREEK SMALL LETTER IOTA WITH TONOS
+ U+03CA: "ϊ" GREEK SMALL LETTER IOTA WITH DIALYTIKA
+ U+0390: "ΐ" GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS -->
+ <Key
+ latin:keyLabel="&#x03B9;"
+ latin:moreKeys="&#x03AF;,&#x03CA;,&#x0390;" />
+ <!-- U+03BF: "ο" GREEK SMALL LETTER OMICRON
+ U+03CC: "ό" GREEK SMALL LETTER OMICRON WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03BF;"
+ latin:moreKeys="&#x03CC;" />
+ <!-- U+03C0: "π" GREEK SMALL LETTER PI -->
+ <Key
+ latin:keyLabel="&#x03C0;" />
+ <Key
+ latin:keyStyle="deleteKeyStyle"
+ latin:keyXPos="-9.219%p"
+ latin:keyWidth="fillBoth" />
+ </Row>
+ <Row
+ latin:keyWidth="8.125%p"
+ >
+ <Key
+ latin:keyStyle="toSymbolKeyStyle"
+ latin:keyLabelFlags="alignLeft"
+ latin:keyWidth="11.172%p"/>
+ <!-- U+03B1: "α" GREEK SMALL LETTER ALPHA
+ U+03AC: "ά" GREEK SMALL LETTER ALPHA WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03B1;"
+ latin:moreKeys="&#x03AC;" />
+ <!-- U+03C3: "σ" GREEK SMALL LETTER SIGMA -->
+ <Key
+ latin:keyLabel="&#x03C3;" />
+ <!-- U+03B4: "δ" GREEK SMALL LETTER DELTA -->
+ <Key
+ latin:keyLabel="&#x03B4;" />
+ <!-- U+03C6: "φ" GREEK SMALL LETTER PHI -->
+ <Key
+ latin:keyLabel="&#x03C6;" />
+ <!-- U+03B3: "γ" GREEK SMALL LETTER GAMMA -->
+ <Key
+ latin:keyLabel="&#x03B3;" />
+ <!-- U+03B7: "η" GREEK SMALL LETTER ETA
+ U+03AE: "ή" GREEK SMALL LETTER ETA WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03B7;"
+ latin:moreKeys="&#x03AE;" />
+ <!-- U+03BE: "ξ" GREEK SMALL LETTER XI -->
+ <Key
+ latin:keyLabel="&#x03BE;" />
+ <!-- U+03BA: "κ" GREEK SMALL LETTER KAPPA -->
+ <Key
+ latin:keyLabel="&#x03BA;" />
+ <!-- U+03BB: "λ" GREEK SMALL LETTER LAMDA -->
+ <Key
+ latin:keyLabel="&#x03BB;" />
+ <Key
+ latin:keyStyle="enterKeyStyle"
+ latin:keyXPos="-15.704%p"
+ latin:keyWidth="fillBoth" />
+ </Row>
+ <Row
+ latin:keyWidth="8.047%p"
+ >
+ <Key
+ latin:keyStyle="shiftKeyStyle"
+ latin:keyWidth="13.829%p" />
+ <!-- U+03B6: "ζ" GREEK SMALL LETTER ZETA -->
+ <Key
+ latin:keyLabel="&#x03B6;" />
+ <!-- U+03C7: "χ" GREEK SMALL LETTER CHI -->
+ <Key
+ latin:keyLabel="&#x03C7;" />
+ <!-- U+03C8: "ψ" GREEK SMALL LETTER PSI -->
+ <Key
+ latin:keyLabel="&#x03C8;" />
+ <!-- U+03C9: "ω" GREEK SMALL LETTER OMEGA
+ U+03CE: "ώ" GREEK SMALL LETTER OMEGA WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03C9;"
+ latin:moreKeys="&#x03CE;" />
+ <!-- U+03B2: "β" GREEK SMALL LETTER BETA -->
+ <Key
+ latin:keyLabel="&#x03B2;" />
+ <!-- U+03BD: "ν" GREEK SMALL LETTER NU -->
+ <Key
+ latin:keyLabel="&#x03BD;" />
+ <!-- U+03BC: "μ" GREEK SMALL LETTER MU -->
+ <Key
+ latin:keyLabel="&#x03BC;" />
+ <include
+ latin:keyboardLayout="@xml/keys_comma_period" />
+ <Key
+ latin:keyStyle="shiftKeyStyle"
+ latin:keyXPos="-13.750%p"
+ latin:keyWidth="fillBoth" />
+ </Row>
+ <include
+ latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>
diff --git a/java/res/xml-sw768dp/rows_number_normal.xml b/java/res/xml-sw768dp/rows_number_normal.xml
index 60674cd17..8bf1a173f 100644
--- a/java/res/xml-sw768dp/rows_number_normal.xml
+++ b/java/res/xml-sw768dp/rows_number_normal.xml
@@ -65,10 +65,24 @@
latin:keyLabel="/"
latin:keyStyle="numKeyStyle"
latin:keyWidth="8.047%p" />
- <Key
- latin:keyLabel=","
- latin:keyStyle="numKeyStyle"
- latin:keyWidth="8.047%p" />
+ <switch>
+ <case
+ latin:mode="time|datetime"
+ >
+ <Key
+ latin:keyLabel=","
+ latin:keyLabelFlags="hasPopupHint"
+ latin:moreKeys="@string/more_keys_for_am_pm"
+ latin:keyStyle="numKeyStyle"
+ latin:keyWidth="8.047%p" />
+ </case>
+ <default>
+ <Key
+ latin:keyLabel=","
+ latin:keyStyle="numKeyStyle"
+ latin:keyWidth="8.047%p" />
+ </default>
+ </switch>
<Key
latin:keyLabel="4"
latin:keyStyle="numKeyStyle"
@@ -96,10 +110,22 @@
latin:keyLabel=")"
latin:keyStyle="numKeyStyle"
latin:keyWidth="8.047%p" />
- <Key
- latin:keyLabel="="
- latin:keyStyle="numKeyStyle"
- latin:keyWidth="8.047%p" />
+ <switch>
+ <case
+ latin:mode="time|datetime"
+ >
+ <Key
+ latin:keyLabel=":"
+ latin:keyStyle="numKeyStyle"
+ latin:keyWidth="8.047%p" />
+ </case>
+ <default>
+ <Key
+ latin:keyLabel="="
+ latin:keyStyle="numKeyStyle"
+ latin:keyWidth="8.047%p" />
+ </default>
+ </switch>
<Key
latin:keyLabel="7"
latin:keyStyle="numKeyStyle"
diff --git a/java/res/xml-sw768dp/rows_serbian.xml b/java/res/xml-sw768dp/rows_serbian.xml
index 39907c867..62668e5cc 100644
--- a/java/res/xml-sw768dp/rows_serbian.xml
+++ b/java/res/xml-sw768dp/rows_serbian.xml
@@ -37,22 +37,23 @@
latin:keyLabel="&#x045A;" />
<!-- U+0435: "е" CYRILLIC SMALL LETTER IE -->
<Key
- latin:keyLabel="&#x0435;" />
+ latin:keyLabel="&#x0435;"
+ latin:moreKeys="@string/more_keys_for_cyrillic_ie" />
<!-- U+0440: "р" CYRILLIC SMALL LETTER ER -->
<Key
latin:keyLabel="&#x0440;" />
<!-- U+0442: "т" CYRILLIC SMALL LETTER TE -->
<Key
latin:keyLabel="&#x0442;" />
- <!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
<Key
- latin:keyLabel="&#x0437;" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_ze" />
<!-- U+0443: "у" CYRILLIC SMALL LETTER U -->
<Key
latin:keyLabel="&#x0443;" />
<!-- U+0438: "и" CYRILLIC SMALL LETTER I -->
<Key
- latin:keyLabel="&#x0438;" />
+ latin:keyLabel="&#x0438;"
+ latin:moreKeys="@string/more_keys_for_cyrillic_i" />
<!-- U+043E: "о" CYRILLIC SMALL LETTER O -->
<Key
latin:keyLabel="&#x043E;" />
@@ -107,9 +108,8 @@
<!-- U+0447: "ч" CYRILLIC SMALL LETTER CHE -->
<Key
latin:keyLabel="&#x0447;" />
- <!-- U+045B: "ћ" CYRILLIC SMALL LETTER TSHE -->
<Key
- latin:keyLabel="&#x045B;" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_tshe" />
<Key
latin:keyStyle="deleteKeyStyle"
latin:keyXPos="-9.219%p"
@@ -121,9 +121,8 @@
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="13.829%p" />
- <!-- U+0455: "ѕ" CYRILLIC SMALL LETTER DZE -->
<Key
- latin:keyLabel="&#x0455;" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_dze" />
<!-- U+045F: "џ" CYRILLIC SMALL LETTER DZHE -->
<Key
latin:keyLabel="&#x045F;" />
@@ -142,6 +141,8 @@
<!-- U+043C: "м" CYRILLIC SMALL LETTER EM -->
<Key
latin:keyLabel="&#x043C;" />
+ <Key
+ latin:keyLabel="@string/keylabel_for_cyrillic_dje" />
<include
latin:keyboardLayout="@xml/keys_comma_period" />
<Key
diff --git a/java/res/xml-sw768dp/rows_slavic.xml b/java/res/xml-sw768dp/rows_slavic.xml
index 26857aebc..3611ef6b3 100644
--- a/java/res/xml-sw768dp/rows_slavic.xml
+++ b/java/res/xml-sw768dp/rows_slavic.xml
@@ -38,18 +38,18 @@
<!-- U+0443: "у" CYRILLIC SMALL LETTER U -->
<Key
latin:keyLabel="&#x0443;"
- latin:moreKeys="@string/more_keys_for_slavic_u" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_u" />
<!-- U+043A: "к" CYRILLIC SMALL LETTER KA -->
<Key
latin:keyLabel="&#x043A;" />
<!-- U+0435: "е" CYRILLIC SMALL LETTER IE -->
<Key
latin:keyLabel="&#x0435;"
- latin:moreKeys="@string/more_keys_for_slavic_ye" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_ye" />
<!-- U+043D: "н" CYRILLIC SMALL LETTER EN -->
<Key
latin:keyLabel="&#x043D;"
- latin:moreKeys="@string/more_keys_for_slavic_en" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_en" />
<!-- U+0433: "г" CYRILLIC SMALL LETTER GHE -->
<Key
latin:keyLabel="&#x0433;" />
@@ -57,7 +57,7 @@
<Key
latin:keyLabel="&#x0448;" />
<Key
- latin:keyLabel="@string/keylabel_for_slavic_shcha" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_shcha" />
<!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
<Key
latin:keyLabel="&#x0437;" />
@@ -82,8 +82,8 @@
<Key
latin:keyLabel="&#x0444;" />
<Key
- latin:keyLabel="@string/keylabel_for_slavic_yery"
- latin:moreKeys="@string/more_keys_for_slavic_yery" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_yery"
+ latin:moreKeys="@string/more_keys_for_cyrillic_yery" />
<!-- U+0432: "в" CYRILLIC SMALL LETTER VE -->
<Key
latin:keyLabel="&#x0432;" />
@@ -99,7 +99,7 @@
<!-- U+043E: "о" CYRILLIC SMALL LETTER O -->
<Key
latin:keyLabel="&#x043E;"
- latin:moreKeys="@string/more_keys_for_slavic_o" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_o" />
<!-- U+043B: "л" CYRILLIC SMALL LETTER EL -->
<Key
latin:keyLabel="&#x043B;" />
@@ -136,7 +136,7 @@
<Key
latin:keyLabel="&#x043C;" />
<Key
- latin:keyLabel="@string/keylabel_for_slavic_i" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_i" />
<!-- U+0442: "т" CYRILLIC SMALL LETTER TE -->
<Key
latin:keyLabel="&#x0442;" />
diff --git a/java/res/xml/kbd_greek.xml b/java/res/xml/kbd_greek.xml
new file mode 100644
index 000000000..7056efb00
--- /dev/null
+++ b/java/res/xml/kbd_greek.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<Keyboard
+ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+ <include
+ latin:keyboardLayout="@xml/rows_greek" />
+</Keyboard>
diff --git a/java/res/xml/key_styles_enter.xml b/java/res/xml/key_styles_enter.xml
index 61efb89b6..a4c9a3396 100644
--- a/java/res/xml/key_styles_enter.xml
+++ b/java/res/xml/key_styles_enter.xml
@@ -33,6 +33,13 @@
latin:moreKeys="@string/action_previous_as_more_key" />
</case>
<case
+ latin:imeAction="actionNext"
+ latin:navigatePrevious="false"
+ >
+ <key-style
+ latin:styleName="navigateMoreKeysStyle" />
+ </case>
+ <case
latin:imeAction="actionPrevious"
latin:navigateNext="true"
>
@@ -41,6 +48,13 @@
latin:keyLabelFlags="hasPopupHint|preserveCase"
latin:moreKeys="@string/action_next_as_more_key" />
</case>
+ <case
+ latin:imeAction="actionPrevious"
+ latin:navigateNext="false"
+ >
+ <key-style
+ latin:styleName="navigateMoreKeysStyle" />
+ </case>
<!-- imeAction!="actionNext" and imeAction!="actionPrevious" -->
<case
latin:navigateNext="true"
@@ -49,7 +63,7 @@
<key-style
latin:styleName="navigateMoreKeysStyle"
latin:keyLabelFlags="hasPopupHint|preserveCase"
- latin:moreKeys="!fixedColumnOrder!2,@string/action_previous_as_more_key,@string/action_next_as_more_key" />
+ latin:moreKeys="!fixedColumnOrder!2,!needsDividers!,@string/action_previous_as_more_key,@string/action_next_as_more_key" />
</case>
<case
latin:navigateNext="true"
diff --git a/java/res/xml/key_styles_number.xml b/java/res/xml/key_styles_number.xml
index 01f7aee59..1fc21694d 100644
--- a/java/res/xml/key_styles_number.xml
+++ b/java/res/xml/key_styles_number.xml
@@ -43,9 +43,7 @@
latin:parentStyle="numKeyStyle" />
<key-style
latin:styleName="num0KeyStyle"
- latin:code="48"
- latin:keyLabel="0 +"
- latin:keyActionFlags="enableLongPress"
+ latin:keyLabel="0"
latin:parentStyle="numberKeyStyle" />
<key-style
latin:styleName="num1KeyStyle"
@@ -91,10 +89,11 @@
latin:keyLabel="9"
latin:keyHintLabel="WXYZ"
latin:parentStyle="numberKeyStyle" />
- <!-- U+FF0A: "*" FULLWIDTH ASTERISK -->
+ <!-- U+002A: "*" ASTERISK
+ U+FF0A: "*" FULLWIDTH ASTERISK -->
<key-style
latin:styleName="numStarKeyStyle"
- latin:code="42"
+ latin:code="0x002A"
latin:keyLabel="&#xFF0A;"
latin:parentStyle="numKeyStyle" />
<!-- Only for non-tablet device -->
@@ -108,15 +107,17 @@
latin:code="@integer/key_switch_alpha_symbol"
latin:keyLabel="@string/label_to_phone_numeric_key"
latin:parentStyle="numModeKeyStyle" />
+ <!-- U+002C: "," COMMA -->
<key-style
latin:styleName="numPauseKeyStyle"
- latin:code="44"
+ latin:code="0x002C"
latin:keyLabel="@string/label_pause_key"
latin:keyLabelFlags="followKeyHintLabelRatio|autoXScale"
latin:parentStyle="numKeyBaseStyle" />
+ <!-- U+003B: ";" SEMICOLON -->
<key-style
latin:styleName="numWaitKeyStyle"
- latin:code="59"
+ latin:code="0x003B"
latin:keyLabel="@string/label_wait_key"
latin:keyLabelFlags="followKeyHintLabelRatio|autoXScale"
latin:parentStyle="numKeyBaseStyle" />
diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml
index 98dc7667e..8b1a3ef77 100644
--- a/java/res/xml/method.xml
+++ b/java/res/xml/method.xml
@@ -20,8 +20,9 @@
<!-- The attributes in this XML file provide configuration information -->
<!-- for the Input Method Manager. -->
-<!-- Keyboard: en_US, en_GB, ar, be, bg, cs, da, de, de(QWERTY), es, es_US, et, fi, fr, fr_CA,
- fr_CH, hr, hu, it, iw, ka, ky, lt, lv, nb, nl, pl, pt, ro, ru, sk, sl, sr, sv, tr, uk, vi -->
+<!-- Keyboard: en_US, en_GB, ar, be, bg, cs, da, de, de(QWERTY), el, es, es_US, et, fi, fr, fr_CA,
+ fr_CH, hr, hu, it, iw, ka, ky, lt, lv, mk, nb, nl, pl, pt, ro, ru, sk, sl, sr, sv, tr, uk,
+ vi -->
<!-- TODO: use <lang>_keyboard icon instead of a common keyboard icon. -->
<!-- If IME doesn't have an applicable subtype, the first subtype will be used as a default
subtype.-->
@@ -84,6 +85,12 @@
/>
<subtype android:icon="@drawable/ic_subtype_keyboard"
android:label="@string/subtype_generic"
+ android:imeSubtypeLocale="el"
+ android:imeSubtypeMode="keyboard"
+ android:imeSubtypeExtraValue="SupportTouchPositionCorrection"
+ />
+ <subtype android:icon="@drawable/ic_subtype_keyboard"
+ android:label="@string/subtype_generic"
android:imeSubtypeLocale="es"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="AsciiCapable,SupportTouchPositionCorrection"
@@ -169,6 +176,12 @@
/>
<subtype android:icon="@drawable/ic_subtype_keyboard"
android:label="@string/subtype_generic"
+ android:imeSubtypeLocale="mk"
+ android:imeSubtypeMode="keyboard"
+ android:imeSubtypeExtraValue="SupportTouchPositionCorrection"
+ />
+ <subtype android:icon="@drawable/ic_subtype_keyboard"
+ android:label="@string/subtype_generic"
android:imeSubtypeLocale="nb"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="AsciiCapable,SupportTouchPositionCorrection"
diff --git a/java/res/xml/rows_greek.xml b/java/res/xml/rows_greek.xml
new file mode 100644
index 000000000..1602c507e
--- /dev/null
+++ b/java/res/xml/rows_greek.xml
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<merge
+ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+>
+ <include
+ latin:keyboardLayout="@xml/key_styles_common" />
+ <Row
+ latin:keyWidth="10%p"
+ >
+ <Key
+ latin:keyLabel=";"
+ latin:keyHintLabel="1"
+ latin:additionalMoreKeys="1" />
+ <!-- TODO: Should find a way to compound Greek dialytika tonos and other Greek letters. -->
+ <!--
+ <switch>
+ <case
+ latin:keyboardSetElement="alphabetManualShifted|alphabetShiftLockShifted"
+ >
+ U+0385: "΅" GREEK DIALYTIKA TONOS
+ <Key
+ latin:keyLabel="&#x0385;"
+ latin:keyHintLabel="2"
+ latin:additionalMoreKeys="2" />
+ </case>
+ <default>
+ -->
+ <!-- U+03C2: "ς" GREEK SMALL LETTER FINAL SIGMA -->
+ <Key
+ latin:keyLabel="&#x03C2;"
+ latin:keyLabelFlags="preserveCase"
+ latin:keyHintLabel="2"
+ latin:additionalMoreKeys="2" />
+ <!--
+ </default>
+ </switch>
+ -->
+ <!-- U+03B5: "ε" GREEK SMALL LETTER EPSILON
+ U+03AD: "έ" GREEK SMALL LETTER EPSILON WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03B5;"
+ latin:keyHintLabel="3"
+ latin:additionalMoreKeys="3"
+ latin:moreKeys="&#x03AD;" />
+ <!-- U+03C1: "ρ" GREEK SMALL LETTER RHO -->
+ <Key
+ latin:keyLabel="&#x03C1;"
+ latin:keyHintLabel="4"
+ latin:additionalMoreKeys="4" />
+ <!-- U+03C4: "τ" GREEK SMALL LETTER TAU -->
+ <Key
+ latin:keyLabel="&#x03C4;"
+ latin:keyHintLabel="5"
+ latin:additionalMoreKeys="5" />
+ <!-- U+03C5: "υ" GREEK SMALL LETTER UPSILON
+ U+03CD: "ύ" GREEK SMALL LETTER UPSILON WITH TONOS
+ U+03CB: "ϋ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+ U+03B0: "ΰ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS -->
+ <Key
+ latin:keyLabel="&#x03C5;"
+ latin:keyHintLabel="6"
+ latin:additionalMoreKeys="6"
+ latin:moreKeys="&#x03CD;,&#x03CB;,&#x03B0;" />
+ <!-- U+03B8: "θ" GREEK SMALL LETTER THETA -->
+ <Key
+ latin:keyLabel="&#x03B8;"
+ latin:keyHintLabel="7"
+ latin:additionalMoreKeys="7" />
+ <!-- U+03B9: "ι" GREEK SMALL LETTER IOTA
+ U+03AF: "ί" GREEK SMALL LETTER IOTA WITH TONOS
+ U+03CA: "ϊ" GREEK SMALL LETTER IOTA WITH DIALYTIKA
+ U+0390: "ΐ" GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS -->
+ <Key
+ latin:keyLabel="&#x03B9;"
+ latin:keyHintLabel="8"
+ latin:additionalMoreKeys="8"
+ latin:moreKeys="&#x03AF;,&#x03CA;,&#x0390;" />
+ <!-- U+03BF: "ο" GREEK SMALL LETTER OMICRON
+ U+03CC: "ό" GREEK SMALL LETTER OMICRON WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03BF;"
+ latin:keyHintLabel="9"
+ latin:additionalMoreKeys="9"
+ latin:moreKeys="&#x03CC;" />
+ <!-- U+03C0: "π" GREEK SMALL LETTER PI -->
+ <Key
+ latin:keyLabel="&#x03C0;"
+ latin:keyHintLabel="0"
+ latin:additionalMoreKeys="0"
+ latin:keyWidth="fillRight" />
+ </Row>
+ <Row
+ latin:keyWidth="10%p"
+ >
+ <!-- U+03B1: "α" GREEK SMALL LETTER ALPHA
+ U+03AC: "ά" GREEK SMALL LETTER ALPHA WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03B1;"
+ latin:moreKeys="&#x03AC;"
+ latin:keyXPos="5%p" />
+ <!-- U+03C3: "σ" GREEK SMALL LETTER SIGMA -->
+ <Key
+ latin:keyLabel="&#x03C3;" />
+ <!-- U+03B4: "δ" GREEK SMALL LETTER DELTA -->
+ <Key
+ latin:keyLabel="&#x03B4;" />
+ <!-- U+03C6: "φ" GREEK SMALL LETTER PHI -->
+ <Key
+ latin:keyLabel="&#x03C6;" />
+ <!-- U+03B3: "γ" GREEK SMALL LETTER GAMMA -->
+ <Key
+ latin:keyLabel="&#x03B3;" />
+ <!-- U+03B7: "η" GREEK SMALL LETTER ETA
+ U+03AE: "ή" GREEK SMALL LETTER ETA WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03B7;"
+ latin:moreKeys="&#x03AE;" />
+ <!-- U+03BE: "ξ" GREEK SMALL LETTER XI -->
+ <Key
+ latin:keyLabel="&#x03BE;" />
+ <!-- U+03BA: "κ" GREEK SMALL LETTER KAPPA -->
+ <Key
+ latin:keyLabel="&#x03BA;" />
+ <!-- U+03BB: "λ" GREEK SMALL LETTER LAMDA -->
+ <Key
+ latin:keyLabel="&#x03BB;" />
+ <!-- Here is 5%p space -->
+ </Row>
+ <Row
+ latin:keyWidth="10%p"
+ >
+ <Key
+ latin:keyStyle="shiftKeyStyle"
+ latin:keyWidth="15%p"
+ latin:visualInsetsRight="1%p" />
+ <!-- U+03B6: "ζ" GREEK SMALL LETTER ZETA -->
+ <Key
+ latin:keyLabel="&#x03B6;" />
+ <!-- U+03C7: "χ" GREEK SMALL LETTER CHI -->
+ <Key
+ latin:keyLabel="&#x03C7;" />
+ <!-- U+03C8: "ψ" GREEK SMALL LETTER PSI -->
+ <Key
+ latin:keyLabel="&#x03C8;" />
+ <!-- U+03C9: "ω" GREEK SMALL LETTER OMEGA
+ U+03CE: "ώ" GREEK SMALL LETTER OMEGA WITH TONOS -->
+ <Key
+ latin:keyLabel="&#x03C9;"
+ latin:moreKeys="&#x03CE;" />
+ <!-- U+03B2: "β" GREEK SMALL LETTER BETA -->
+ <Key
+ latin:keyLabel="&#x03B2;" />
+ <!-- U+03BD: "ν" GREEK SMALL LETTER NU -->
+ <Key
+ latin:keyLabel="&#x03BD;" />
+ <!-- U+03BC: "μ" GREEK SMALL LETTER MU -->
+ <Key
+ latin:keyLabel="&#x03BC;" />
+ <Key
+ latin:keyStyle="deleteKeyStyle"
+ latin:keyWidth="fillRight"
+ latin:visualInsetsLeft="1%p" />
+ </Row>
+ <include
+ latin:keyboardLayout="@xml/row_qwerty4" />
+</merge>
diff --git a/java/res/xml/rows_number_normal.xml b/java/res/xml/rows_number_normal.xml
index b581fb5cd..6f9429cd8 100644
--- a/java/res/xml/rows_number_normal.xml
+++ b/java/res/xml/rows_number_normal.xml
@@ -46,10 +46,32 @@
<Key
latin:keyLabel="6"
latin:keyStyle="numKeyStyle" />
- <Key
- latin:keyLabel=","
- latin:keyStyle="numFunctionalKeyStyle"
- latin:keyWidth="fillRight" />
+ <switch>
+ <case
+ latin:mode="date"
+ >
+ <Key
+ latin:keyLabel="."
+ latin:keyStyle="numFunctionalKeyStyle"
+ latin:keyWidth="fillRight" />
+ </case>
+ <case
+ latin:mode="time|datetime"
+ >
+ <Key
+ latin:keyLabel="."
+ latin:keyLabelFlags="hasPopupHint"
+ latin:moreKeys="@string/more_keys_for_am_pm"
+ latin:keyStyle="numFunctionalKeyStyle"
+ latin:keyWidth="fillRight" />
+ </case>
+ <default>
+ <Key
+ latin:keyLabel=","
+ latin:keyStyle="numFunctionalKeyStyle"
+ latin:keyWidth="fillRight" />
+ </default>
+ </switch>
</Row>
<Row>
<Key
@@ -71,9 +93,37 @@
<Key
latin:keyLabel="0"
latin:keyStyle="numKeyStyle" />
- <Key
- latin:keyLabel="."
- latin:keyStyle="numKeyStyle" />
+ <switch>
+ <case
+ latin:mode="date"
+ >
+ <Key
+ latin:keyLabel="/"
+ latin:keyStyle="numKeyStyle" />
+ </case>
+ <case
+ latin:mode="time"
+ >
+ <Key
+ latin:keyLabel=":"
+ latin:keyStyle="numKeyStyle" />
+ </case>
+ <case
+ latin:mode="datetime"
+ >
+ <!-- U+002F: "/" SOLIDUS -->
+ <Key
+ latin:code="0x002F"
+ latin:keyLabel="/ :"
+ latin:moreKeys="!embeddedMoreKey!,:"
+ latin:keyStyle="numKeyStyle" />
+ </case>
+ <default>
+ <Key
+ latin:keyLabel="."
+ latin:keyStyle="numKeyStyle" />
+ </default>
+ </switch>
<Key
latin:keyStyle="enterKeyStyle"
latin:keyWidth="fillRight" />
diff --git a/java/res/xml/rows_phone.xml b/java/res/xml/rows_phone.xml
index 60296d061..630b24ea4 100644
--- a/java/res/xml/rows_phone.xml
+++ b/java/res/xml/rows_phone.xml
@@ -63,8 +63,12 @@
<Row>
<Key
latin:keyStyle="numPhoneToSymbolKeyStyle" />
+ <!-- U+0030: "0" DIGIT ZERO -->
<Key
- latin:keyStyle="num0KeyStyle" />
+ latin:keyStyle="num0KeyStyle"
+ latin:code="0x0030"
+ latin:keyLabel="0 +"
+ latin:moreKeys="!embeddedMoreKey!,+" />
<Key
latin:keyStyle="numSpaceKeyStyle" />
<Key
diff --git a/java/res/xml/rows_serbian.xml b/java/res/xml/rows_serbian.xml
index cf52fe0cc..ed33dc751 100644
--- a/java/res/xml/rows_serbian.xml
+++ b/java/res/xml/rows_serbian.xml
@@ -40,7 +40,8 @@
<Key
latin:keyLabel="&#x0435;"
latin:keyHintLabel="3"
- latin:additionalMoreKeys="3" />
+ latin:additionalMoreKeys="3"
+ latin:moreKeys="@string/more_keys_for_cyrillic_ie" />
<!-- U+0440: "р" CYRILLIC SMALL LETTER ER -->
<Key
latin:keyLabel="&#x0440;"
@@ -51,9 +52,8 @@
latin:keyLabel="&#x0442;"
latin:keyHintLabel="5"
latin:additionalMoreKeys="5" />
- <!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
<Key
- latin:keyLabel="&#x0437;"
+ latin:keyLabel="@string/keylabel_for_cyrillic_ze"
latin:keyHintLabel="6"
latin:additionalMoreKeys="6" />
<!-- U+0443: "у" CYRILLIC SMALL LETTER U -->
@@ -65,7 +65,8 @@
<Key
latin:keyLabel="&#x0438;"
latin:keyHintLabel="8"
- latin:additionalMoreKeys="8" />
+ latin:additionalMoreKeys="8"
+ latin:moreKeys="@string/more_keys_for_cyrillic_i" />
<!-- U+043E: "о" CYRILLIC SMALL LETTER O -->
<Key
latin:keyLabel="&#x043E;"
@@ -114,9 +115,8 @@
<!-- U+0447: "ч" CYRILLIC SMALL LETTER CHE -->
<Key
latin:keyLabel="&#x0447;" />
- <!-- U+045B: "ћ" CYRILLIC SMALL LETTER TSHE -->
<Key
- latin:keyLabel="&#x045B;"
+ latin:keyLabel="@string/keylabel_for_cyrillic_tshe"
latin:keyWidth="fillRight" />
</Row>
<Row
@@ -125,9 +125,8 @@
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="11.75%p" />
- <!-- U+0455: "ѕ" CYRILLIC SMALL LETTER DZE -->
<Key
- latin:keyLabel="&#x0455;" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_dze" />
<!-- U+045F: "џ" CYRILLIC SMALL LETTER DZHE -->
<Key
latin:keyLabel="&#x045F;" />
@@ -146,9 +145,8 @@
<!-- U+043C: "м" CYRILLIC SMALL LETTER EM -->
<Key
latin:keyLabel="&#x043C;" />
- <!-- U+0452: "ђ" CYRILLIC SMALL LETTER DJE -->
<Key
- latin:keyLabel="&#x0452;" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_dje" />
<!-- U+0436: "ж" CYRILLIC SMALL LETTER ZHE -->
<Key
latin:keyLabel="&#x0436;" />
diff --git a/java/res/xml/rows_slavic.xml b/java/res/xml/rows_slavic.xml
index 4099edd3f..d75f2091a 100644
--- a/java/res/xml/rows_slavic.xml
+++ b/java/res/xml/rows_slavic.xml
@@ -41,7 +41,7 @@
latin:keyLabel="&#x0443;"
latin:keyHintLabel="3"
latin:additionalMoreKeys="3"
- latin:moreKeys="@string/more_keys_for_slavic_u" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_u" />
<!-- U+043A: "к" CYRILLIC SMALL LETTER KA -->
<Key
latin:keyLabel="&#x043A;"
@@ -52,13 +52,13 @@
latin:keyLabel="&#x0435;"
latin:keyHintLabel="5"
latin:additionalMoreKeys="5"
- latin:moreKeys="@string/more_keys_for_slavic_ye" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_ye" />
<!-- U+043D: "н" CYRILLIC SMALL LETTER EN -->
<Key
latin:keyLabel="&#x043D;"
latin:keyHintLabel="6"
latin:additionalMoreKeys="6"
- latin:moreKeys="@string/more_keys_for_slavic_en" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_en" />
<!-- U+0433: "г" CYRILLIC SMALL LETTER GHE -->
<Key
latin:keyLabel="&#x0433;"
@@ -70,7 +70,7 @@
latin:keyHintLabel="8"
latin:additionalMoreKeys="8" />
<Key
- latin:keyLabel="@string/keylabel_for_slavic_shcha"
+ latin:keyLabel="@string/keylabel_for_cyrillic_shcha"
latin:keyHintLabel="9"
latin:additionalMoreKeys="9" />
<!-- U+0437: "з" CYRILLIC SMALL LETTER ZE -->
@@ -81,7 +81,7 @@
<!-- U+0445: "х" CYRILLIC SMALL LETTER HA -->
<Key
latin:keyLabel="&#x0445;"
- latin:moreKeys="@string/more_keys_for_slavic_ha"
+ latin:moreKeys="@string/more_keys_for_cyrillic_ha"
latin:keyWidth="fillRight" />
</Row>
<Row
@@ -91,8 +91,8 @@
<Key
latin:keyLabel="&#x0444;" />
<Key
- latin:keyLabel="@string/keylabel_for_slavic_yery"
- latin:moreKeys="@string/more_keys_for_slavic_yery" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_yery"
+ latin:moreKeys="@string/more_keys_for_cyrillic_yery" />
<!-- U+0432: "в" CYRILLIC SMALL LETTER VE -->
<Key
latin:keyLabel="&#x0432;" />
@@ -108,7 +108,7 @@
<!-- U+043E: "о" CYRILLIC SMALL LETTER O -->
<Key
latin:keyLabel="&#x043E;"
- latin:moreKeys="@string/more_keys_for_slavic_o" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_o" />
<!-- U+043B: "л" CYRILLIC SMALL LETTER EL -->
<Key
latin:keyLabel="&#x043B;" />
@@ -142,14 +142,14 @@
<Key
latin:keyLabel="&#x043C;" />
<Key
- latin:keyLabel="@string/keylabel_for_slavic_i" />
+ latin:keyLabel="@string/keylabel_for_cyrillic_i" />
<!-- U+0442: "т" CYRILLIC SMALL LETTER TE -->
<Key
latin:keyLabel="&#x0442;" />
<!-- U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN -->
<Key
latin:keyLabel="&#x044C;"
- latin:moreKeys="@string/more_keys_for_slavic_soft_sign" />
+ latin:moreKeys="@string/more_keys_for_cyrillic_soft_sign" />
<!-- U+0431: "б" CYRILLIC SMALL LETTER BE -->
<Key
latin:keyLabel="&#x0431;" />
diff --git a/java/res/xml/spellchecker.xml b/java/res/xml/spellchecker.xml
index b48dc52cd..2e4448c44 100644
--- a/java/res/xml/spellchecker.xml
+++ b/java/res/xml/spellchecker.xml
@@ -17,11 +17,11 @@
*/
-->
-<!-- The attributes in this XML file provide the configuration information -->
-<!-- for the spell checker -->
+<!-- The attributes in this XML file provide the configuration information
+ for the spell checker -->
<spell-checker xmlns:android="http://schemas.android.com/apk/res/android"
- android:label="@string/spell_checker_service_name"
+ android:label="@string/aosp_spell_checker_service_name"
android:settingsActivity="com.android.inputmethod.latin.spellcheck.SpellCheckerSettingsActivity">
<subtype
android:label="@string/subtype_generic"
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
new file mode 100644
index 000000000..dc7c12ba6
--- /dev/null
+++ b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
@@ -0,0 +1,377 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.accessibility;
+
+import android.graphics.Rect;
+import android.inputmethodservice.InputMethodService;
+import android.support.v4.view.ViewCompat;
+import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
+import android.support.v4.view.accessibility.AccessibilityNodeProviderCompat;
+import android.support.v4.view.accessibility.AccessibilityRecordCompat;
+import android.util.Log;
+import android.util.SparseArray;
+import android.view.View;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.inputmethod.EditorInfo;
+
+import com.android.inputmethod.keyboard.Key;
+import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.keyboard.KeyboardView;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Exposes a virtual view sub-tree for {@link KeyboardView} and generates
+ * {@link AccessibilityEvent}s for individual {@link Key}s.
+ * <p>
+ * A virtual sub-tree is composed of imaginary {@link View}s that are reported
+ * as a part of the view hierarchy for accessibility purposes. This enables
+ * custom views that draw complex content to report them selves as a tree of
+ * virtual views, thus conveying their logical structure.
+ * </p>
+ */
+public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat {
+ private static final String TAG = AccessibilityEntityProvider.class.getSimpleName();
+
+ private final KeyboardView mKeyboardView;
+ private final InputMethodService mInputMethodService;
+ private final KeyCodeDescriptionMapper mKeyCodeDescriptionMapper;
+ private final AccessibilityUtils mAccessibilityUtils;
+
+ /** A map of integer IDs to {@link Key}s. */
+ private final SparseArray<Key> mVirtualViewIdToKey = new SparseArray<Key>();
+
+ /** Temporary rect used to calculate in-screen bounds. */
+ private final Rect mTempBoundsInScreen = new Rect();
+
+ /** The parent view's cached on-screen location. */
+ private final int[] mParentLocation = new int[2];
+
+ public AccessibilityEntityProvider(KeyboardView keyboardView, InputMethodService inputMethod) {
+ mKeyboardView = keyboardView;
+ mInputMethodService = inputMethod;
+
+ mKeyCodeDescriptionMapper = KeyCodeDescriptionMapper.getInstance();
+ mAccessibilityUtils = AccessibilityUtils.getInstance();
+
+ assignVirtualViewIds();
+ updateParentLocation();
+
+ // Ensure that the on-screen bounds are cleared when the layout changes.
+ mKeyboardView.getViewTreeObserver().addOnGlobalLayoutListener(mGlobalLayoutListener);
+ }
+
+ /**
+ * Creates and populates an {@link AccessibilityEvent} for the specified key
+ * and event type.
+ *
+ * @param key A key on the host keyboard view.
+ * @param eventType The event type to create.
+ * @return A populated {@link AccessibilityEvent} for the key.
+ * @see AccessibilityEvent
+ */
+ public AccessibilityEvent createAccessibilityEvent(Key key, int eventType) {
+ final int virtualViewId = generateVirtualViewIdForKey(key);
+ final String keyDescription = getKeyDescription(key);
+
+ final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
+ event.setPackageName(mKeyboardView.getContext().getPackageName());
+ event.setClassName(key.getClass().getName());
+ event.getText().add(keyDescription);
+
+ final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
+ record.setSource(mKeyboardView, virtualViewId);
+
+ return event;
+ }
+
+ /**
+ * Returns an {@link AccessibilityNodeInfoCompat} representing a virtual
+ * view, i.e. a descendant of the host View, with the given <code>virtualViewId</code> or
+ * the host View itself if <code>virtualViewId</code> equals to {@link View#NO_ID}.
+ * <p>
+ * A virtual descendant is an imaginary View that is reported as a part of
+ * the view hierarchy for accessibility purposes. This enables custom views
+ * that draw complex content to report them selves as a tree of virtual
+ * views, thus conveying their logical structure.
+ * </p>
+ * <p>
+ * The implementer is responsible for obtaining an accessibility node info
+ * from the pool of reusable instances and setting the desired properties of
+ * the node info before returning it.
+ * </p>
+ *
+ * @param virtualViewId A client defined virtual view id.
+ * @return A populated {@link AccessibilityNodeInfoCompat} for a virtual
+ * descendant or the host View.
+ * @see AccessibilityNodeInfoCompat
+ */
+ @Override
+ public AccessibilityNodeInfoCompat createAccessibilityNodeInfo(int virtualViewId) {
+ AccessibilityNodeInfoCompat info = null;
+
+ if (virtualViewId == View.NO_ID) {
+ // We are requested to create an AccessibilityNodeInfo describing
+ // this View, i.e. the root of the virtual sub-tree.
+ info = AccessibilityNodeInfoCompat.obtain(mKeyboardView);
+ ViewCompat.onInitializeAccessibilityNodeInfo(mKeyboardView, info);
+
+ // Add the virtual children of the root View.
+ // TODO(alanv): Need to assign a unique ID to each key.
+ final Keyboard keyboard = mKeyboardView.getKeyboard();
+ final Set<Key> keys = keyboard.mKeys;
+ for (Key key : keys) {
+ final int childVirtualViewId = generateVirtualViewIdForKey(key);
+ info.addChild(mKeyboardView, childVirtualViewId);
+ }
+ } else {
+ // Find the view that corresponds to the given id.
+ final Key key = mVirtualViewIdToKey.get(virtualViewId);
+ if (key == null) {
+ Log.e(TAG, "Invalid virtual view ID: " + virtualViewId);
+ return null;
+ }
+
+ final String keyDescription = getKeyDescription(key);
+ final Rect boundsInParent = key.mHitBox;
+
+ // Calculate the key's in-screen bounds.
+ mTempBoundsInScreen.set(boundsInParent);
+ mTempBoundsInScreen.offset(mParentLocation[0], mParentLocation[1]);
+
+ final Rect boundsInScreen = mTempBoundsInScreen;
+
+ // Obtain and initialize an AccessibilityNodeInfo with
+ // information about the virtual view.
+ info = AccessibilityNodeInfoCompat.obtain();
+ info.addAction(AccessibilityNodeInfoCompat.ACTION_SELECT);
+ info.addAction(AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION);
+ info.setPackageName(mKeyboardView.getContext().getPackageName());
+ info.setClassName(key.getClass().getName());
+ info.setBoundsInParent(boundsInParent);
+ info.setBoundsInScreen(boundsInScreen);
+ info.setParent(mKeyboardView);
+ info.setSource(mKeyboardView, virtualViewId);
+ info.setBoundsInScreen(boundsInScreen);
+ info.setText(keyDescription);
+ }
+
+ return info;
+ }
+
+ /**
+ * Performs an accessibility action on a virtual view, i.e. a descendant of
+ * the host View, with the given <code>virtualViewId</code> or the host View itself if
+ * <code>virtualViewId</code> equals to {@link View#NO_ID}.
+ *
+ * @param action The action to perform.
+ * @param virtualViewId A client defined virtual view id.
+ * @return True if the action was performed.
+ * @see #createAccessibilityNodeInfo(int)
+ * @see AccessibilityNodeInfoCompat
+ */
+ @Override
+ public boolean performAccessibilityAction(int action, int virtualViewId) {
+ if (virtualViewId == View.NO_ID) {
+ // Perform the action on the host View.
+ switch (action) {
+ case AccessibilityNodeInfoCompat.ACTION_SELECT:
+ if (!mKeyboardView.isSelected()) {
+ mKeyboardView.setSelected(true);
+ return mKeyboardView.isSelected();
+ }
+ break;
+ case AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION:
+ if (mKeyboardView.isSelected()) {
+ mKeyboardView.setSelected(false);
+ return !mKeyboardView.isSelected();
+ }
+ break;
+ }
+ } else {
+ // Find the view that corresponds to the given id.
+ final Key child = mVirtualViewIdToKey.get(virtualViewId);
+ if (child == null)
+ return false;
+
+ // Perform the action on a virtual view.
+ switch (action) {
+ case AccessibilityNodeInfoCompat.ACTION_SELECT:
+ // TODO: Provide some focus indicator.
+ return true;
+ case AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION:
+ // TODO: Provide some clear focus indicator.
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Finds {@link AccessibilityNodeInfoCompat}s by text. The match is case
+ * insensitive containment. The search is relative to the virtual view, i.e.
+ * a descendant of the host View, with the given <code>virtualViewId</code> or the host
+ * View itself <code>virtualViewId</code> equals to {@link View#NO_ID}.
+ *
+ * @param virtualViewId A client defined virtual view id which defined the
+ * root of the tree in which to perform the search.
+ * @param text The searched text.
+ * @return A list of node info.
+ * @see #createAccessibilityNodeInfo(int)
+ * @see AccessibilityNodeInfoCompat
+ */
+ @Override
+ public List<AccessibilityNodeInfoCompat> findAccessibilityNodeInfosByText(
+ String text, int virtualViewId) {
+ final String searchedLowerCase = text.toLowerCase();
+ final Keyboard keyboard = mKeyboardView.getKeyboard();
+
+ List<AccessibilityNodeInfoCompat> results = null;
+
+ if (virtualViewId == View.NO_ID) {
+ for (Key key : keyboard.mKeys) {
+ results = findByTextAndPopulate(searchedLowerCase, key, results);
+ }
+ } else {
+ final Key key = mVirtualViewIdToKey.get(virtualViewId);
+
+ results = findByTextAndPopulate(searchedLowerCase, key, results);
+ }
+
+ if (results == null) {
+ return Collections.emptyList();
+ }
+
+ return results;
+ }
+
+ /**
+ * Helper method for {@link #findAccessibilityNodeInfosByText(String, int)}.
+ * Takes a current set of results and matches a specified key against a
+ * lower-case search string. Returns an updated list of results.
+ *
+ * @param searchedLowerCase The lower-case search string.
+ * @param key The key to compare against.
+ * @param results The current list of results, or {@code null} if no results
+ * found.
+ * @return An updated list of results, or {@code null} if no results found.
+ */
+ private List<AccessibilityNodeInfoCompat> findByTextAndPopulate(String searchedLowerCase,
+ Key key, List<AccessibilityNodeInfoCompat> results) {
+ if (!keyContainsText(key, searchedLowerCase)) {
+ return results;
+ }
+
+ final int childVirtualViewId = generateVirtualViewIdForKey(key);
+ final AccessibilityNodeInfoCompat nodeInfo = createAccessibilityNodeInfo(
+ childVirtualViewId);
+
+ if (results == null) {
+ results = new LinkedList<AccessibilityNodeInfoCompat>();
+ }
+
+ results.add(nodeInfo);
+
+ return results;
+ }
+
+ /**
+ * Returns whether a key's current description contains the lower-case
+ * search text.
+ *
+ * @param key The key to compare against.
+ * @param textLowerCase The lower-case search string.
+ * @return {@code true} if the key contains the search text.
+ */
+ private boolean keyContainsText(Key key, String textLowerCase) {
+ if (key == null) {
+ return false;
+ }
+
+ final String description = getKeyDescription(key);
+
+ if (description == null) {
+ return false;
+ }
+
+ return description.toLowerCase().contains(textLowerCase);
+ }
+
+ /**
+ * Returns the context-specific description for a {@link Key}.
+ *
+ * @param key The key to describe.
+ * @return The context-specific description of the key.
+ */
+ private String getKeyDescription(Key key) {
+ final EditorInfo editorInfo = mInputMethodService.getCurrentInputEditorInfo();
+ final boolean shouldObscure = mAccessibilityUtils.shouldObscureInput(editorInfo);
+ final String keyDescription = mKeyCodeDescriptionMapper.getDescriptionForKey(
+ mKeyboardView.getContext(), mKeyboardView.getKeyboard(), key, shouldObscure);
+
+ return keyDescription;
+ }
+
+ /**
+ * Assigns virtual view IDs to keyboard keys and populates the related maps.
+ */
+ private void assignVirtualViewIds() {
+ final Keyboard keyboard = mKeyboardView.getKeyboard();
+ if (keyboard == null) {
+ return;
+ }
+
+ mVirtualViewIdToKey.clear();
+
+ final Set<Key> keySet = keyboard.mKeys;
+ for (Key key : keySet) {
+ final int virtualViewId = generateVirtualViewIdForKey(key);
+ mVirtualViewIdToKey.put(virtualViewId, key);
+ }
+ }
+
+ /**
+ * Updates the parent's on-screen location.
+ */
+ private void updateParentLocation() {
+ mKeyboardView.getLocationOnScreen(mParentLocation);
+ }
+
+ /**
+ * Generates a virtual view identifier for the specified key.
+ *
+ * @param key The key to identify.
+ * @return A virtual view identifier.
+ */
+ private static int generateVirtualViewIdForKey(Key key) {
+ // The key code is unique within an instance of a Keyboard.
+ return key.mCode;
+ }
+
+ private final OnGlobalLayoutListener mGlobalLayoutListener = new OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ assignVirtualViewIds();
+ updateParentLocation();
+ }
+ };
+}
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
index 9caed00c9..41da2aa4c 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
@@ -21,13 +21,14 @@ import android.inputmethodservice.InputMethodService;
import android.media.AudioManager;
import android.os.SystemClock;
import android.provider.Settings;
+import android.support.v4.view.MotionEventCompat;
import android.util.Log;
import android.view.MotionEvent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.EditorInfo;
-import com.android.inputmethod.compat.AccessibilityManagerCompatWrapper;
+import com.android.inputmethod.compat.AccessibilityManagerCompatUtils;
import com.android.inputmethod.compat.AudioManagerCompatWrapper;
import com.android.inputmethod.compat.InputTypeCompatUtils;
import com.android.inputmethod.compat.MotionEventCompatUtils;
@@ -44,7 +45,6 @@ public class AccessibilityUtils {
private Context mContext;
private AccessibilityManager mAccessibilityManager;
- private AccessibilityManagerCompatWrapper mCompatManager;
private AudioManagerCompatWrapper mAudioManager;
/*
@@ -77,7 +77,6 @@ public class AccessibilityUtils {
mContext = context;
mAccessibilityManager = (AccessibilityManager) context
.getSystemService(Context.ACCESSIBILITY_SERVICE);
- mCompatManager = new AccessibilityManagerCompatWrapper(mAccessibilityManager);
final AudioManager audioManager = (AudioManager) context
.getSystemService(Context.AUDIO_SERVICE);
@@ -94,7 +93,7 @@ public class AccessibilityUtils {
public boolean isTouchExplorationEnabled() {
return ENABLE_ACCESSIBILITY
&& mAccessibilityManager.isEnabled()
- && mCompatManager.isTouchExplorationEnabled();
+ && AccessibilityManagerCompatUtils.isTouchExplorationEnabled(mAccessibilityManager);
}
/**
@@ -110,13 +109,13 @@ public class AccessibilityUtils {
return action == MotionEventCompatUtils.ACTION_HOVER_ENTER
|| action == MotionEventCompatUtils.ACTION_HOVER_EXIT
- || action == MotionEventCompatUtils.ACTION_HOVER_MOVE;
+ || action == MotionEventCompat.ACTION_HOVER_MOVE;
}
/**
* Returns whether the device should obscure typed password characters.
* Typically this means speaking "dot" in place of non-control characters.
- *
+ *
* @return {@code true} if the device should obscure password characters.
*/
public boolean shouldObscureInput(EditorInfo editorInfo) {
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index 2294a18a0..2401d93c6 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -20,13 +20,16 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.inputmethodservice.InputMethodService;
-import android.util.Log;
+import android.support.v4.view.AccessibilityDelegateCompat;
+import android.support.v4.view.MotionEventCompat;
+import android.support.v4.view.ViewCompat;
+import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.view.MotionEvent;
+import android.view.View;
import android.view.accessibility.AccessibilityEvent;
-import android.view.inputmethod.EditorInfo;
-import com.android.inputmethod.compat.AccessibilityEventCompatUtils;
import com.android.inputmethod.compat.MotionEventCompatUtils;
+import com.android.inputmethod.compat.ViewParentCompatUtils;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
@@ -34,14 +37,14 @@ import com.android.inputmethod.keyboard.LatinKeyboardView;
import com.android.inputmethod.keyboard.PointerTracker;
import com.android.inputmethod.latin.R;
-public class AccessibleKeyboardViewProxy {
- private static final String TAG = AccessibleKeyboardViewProxy.class.getSimpleName();
+public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
private static final AccessibleKeyboardViewProxy sInstance = new AccessibleKeyboardViewProxy();
private InputMethodService mInputMethod;
private FlickGestureDetector mGestureDetector;
private LatinKeyboardView mView;
private AccessibleKeyboardActionListener mListener;
+ private AccessibilityEntityProvider mAccessibilityNodeProvider;
private Key mLastHoverKey = null;
@@ -54,10 +57,6 @@ public class AccessibleKeyboardViewProxy {
return sInstance;
}
- public static void setView(LatinKeyboardView view) {
- sInstance.mView = view;
- }
-
private AccessibleKeyboardViewProxy() {
// Not publicly instantiable.
}
@@ -73,34 +72,39 @@ public class AccessibleKeyboardViewProxy {
mGestureDetector = new KeyboardFlickGestureDetector(inputMethod);
}
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- if (mView == null) {
- Log.e(TAG, "No keyboard view set!");
- return false;
+ /**
+ * Sets the view wrapped by this proxy.
+ *
+ * @param view The view to wrap.
+ */
+ public void setView(LatinKeyboardView view) {
+ if (view == null) {
+ // Ignore null views.
+ return;
}
- switch (event.getEventType()) {
- case AccessibilityEventCompatUtils.TYPE_VIEW_HOVER_ENTER:
- final Key key = mLastHoverKey;
+ mView = view;
- if (key == null)
- break;
-
- final EditorInfo info = mInputMethod.getCurrentInputEditorInfo();
- final boolean shouldObscure = AccessibilityUtils.getInstance().shouldObscureInput(info);
- final CharSequence description = KeyCodeDescriptionMapper.getInstance()
- .getDescriptionForKey(mView.getContext(), mView.getKeyboard(), key,
- shouldObscure);
-
- if (description == null)
- return false;
-
- event.getText().add(description);
+ // Ensure that the view has an accessibility delegate.
+ ViewCompat.setAccessibilityDelegate(view, this);
+ }
- break;
+ /**
+ * Proxy method for View.getAccessibilityNodeProvider(). This method is
+ * called in SDK version 15 and higher to obtain the virtual node hierarchy
+ * provider.
+ *
+ * @return The accessibility node provider for the current keyboard.
+ */
+ @Override
+ public AccessibilityEntityProvider getAccessibilityNodeProvider(View host) {
+ // Instantiate the provide only when requested. Since the system
+ // will call this method multiple times it is a good practice to
+ // cache the provider instance.
+ if (mAccessibilityNodeProvider == null) {
+ mAccessibilityNodeProvider = new AccessibilityEntityProvider(mView, mInputMethod);
}
-
- return true;
+ return mAccessibilityNodeProvider;
}
/**
@@ -123,46 +127,94 @@ public class AccessibleKeyboardViewProxy {
* @param event The touch exploration hover event.
* @return {@code true} if the event was handled
*/
- /*package*/ boolean onHoverEventInternal(MotionEvent event, PointerTracker tracker) {
+ /* package */boolean onHoverEventInternal(MotionEvent event, PointerTracker tracker) {
final int x = (int) event.getX();
final int y = (int) event.getY();
+ final Key key = tracker.getKeyOn(x, y);
+ final Key previousKey = mLastHoverKey;
+
+ mLastHoverKey = key;
switch (event.getAction()) {
case MotionEventCompatUtils.ACTION_HOVER_ENTER:
- case MotionEventCompatUtils.ACTION_HOVER_MOVE:
- final Key key = tracker.getKeyOn(x, y);
-
- if (key != mLastHoverKey) {
- fireKeyHoverEvent(mLastHoverKey, false);
- mLastHoverKey = key;
- fireKeyHoverEvent(mLastHoverKey, true);
+ case MotionEventCompatUtils.ACTION_HOVER_EXIT:
+ return onHoverKey(key, event);
+ case MotionEventCompat.ACTION_HOVER_MOVE:
+ if (key != previousKey) {
+ return onTransitionKey(key, previousKey, event);
+ } else {
+ return onHoverKey(key, event);
}
-
- return true;
}
return false;
}
- private void fireKeyHoverEvent(Key key, boolean entering) {
- if (mListener == null) {
- Log.e(TAG, "No accessible keyboard action listener set!");
- return;
+ /**
+ * Simulates a transition between two {@link Key}s by sending a HOVER_EXIT
+ * on the previous key, a HOVER_ENTER on the current key, and a HOVER_MOVE
+ * on the current key.
+ *
+ * @param currentKey The currently hovered key.
+ * @param previousKey The previously hovered key.
+ * @param event The event that triggered the transition.
+ * @return {@code true} if the event was handled.
+ */
+ private boolean onTransitionKey(Key currentKey, Key previousKey, MotionEvent event) {
+ final int savedAction = event.getAction();
+
+ event.setAction(MotionEventCompatUtils.ACTION_HOVER_EXIT);
+ onHoverKey(previousKey, event);
+
+ event.setAction(MotionEventCompatUtils.ACTION_HOVER_ENTER);
+ onHoverKey(currentKey, event);
+
+ event.setAction(MotionEventCompat.ACTION_HOVER_MOVE);
+ final boolean handled = onHoverKey(currentKey, event);
+
+ event.setAction(savedAction);
+
+ return handled;
+ }
+
+ /**
+ * Handles a hover event on a key. If {@link Key} extended View, this would
+ * be analogous to calling View.onHoverEvent(MotionEvent).
+ *
+ * @param key The currently hovered key.
+ * @param event The hover event.
+ * @return {@code true} if the event was handled.
+ */
+ private boolean onHoverKey(Key key, MotionEvent event) {
+ // Null keys can't receive events.
+ if (key == null) {
+ return false;
}
- if (mView == null) {
- Log.e(TAG, "No keyboard view set!");
- return;
+ switch (event.getAction()) {
+ case MotionEventCompatUtils.ACTION_HOVER_ENTER:
+ sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_ENTER);
+ break;
+ case MotionEventCompatUtils.ACTION_HOVER_EXIT:
+ sendAccessibilityEventForKey(key, AccessibilityEventCompat.TYPE_VIEW_HOVER_EXIT);
+ break;
}
- if (key == null)
- return;
+ return true;
+ }
- if (entering) {
- mView.sendAccessibilityEvent(AccessibilityEventCompatUtils.TYPE_VIEW_HOVER_ENTER);
- } else {
- mView.sendAccessibilityEvent(AccessibilityEventCompatUtils.TYPE_VIEW_HOVER_EXIT);
- }
+ /**
+ * Populates and sends an {@link AccessibilityEvent} for the specified key.
+ *
+ * @param key The key to send an event for.
+ * @param eventType The type of event to send.
+ */
+ private void sendAccessibilityEventForKey(Key key, int eventType) {
+ final AccessibilityEntityProvider nodeProvider = getAccessibilityNodeProvider(null);
+ final AccessibilityEvent event = nodeProvider.createAccessibilityEvent(key, eventType);
+
+ // Propagates the event up the view hierarchy.
+ ViewParentCompatUtils.requestSendAccessibilityEvent(mView.getParent(), mView, event);
}
private class KeyboardFlickGestureDetector extends FlickGestureDetector {
diff --git a/java/src/com/android/inputmethod/accessibility/FlickGestureDetector.java b/java/src/com/android/inputmethod/accessibility/FlickGestureDetector.java
index db12f76ad..eaa4ddff6 100644
--- a/java/src/com/android/inputmethod/accessibility/FlickGestureDetector.java
+++ b/java/src/com/android/inputmethod/accessibility/FlickGestureDetector.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.accessibility;
import android.content.Context;
import android.os.Message;
+import android.support.v4.view.MotionEventCompat;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
@@ -32,7 +33,7 @@ import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
* properties:
* <ul>
* <li>Begins with a {@link MotionEventCompatUtils#ACTION_HOVER_ENTER} event
- * <li>Contains any number of {@link MotionEventCompatUtils#ACTION_HOVER_MOVE}
+ * <li>Contains any number of {@link MotionEventCompat#ACTION_HOVER_MOVE}
* events
* <li>Ends with a {@link MotionEventCompatUtils#ACTION_HOVER_EXIT} event
* <li>Maximum duration of 250 milliseconds
@@ -128,7 +129,7 @@ public abstract class FlickGestureDetector {
final float distanceSquare = calculateDistanceSquare(mCachedHoverEnter, event);
switch (event.getAction()) {
- case MotionEventCompatUtils.ACTION_HOVER_MOVE:
+ case MotionEventCompat.ACTION_HOVER_MOVE:
// Consume all valid move events before timeout.
return true;
case MotionEventCompatUtils.ACTION_HOVER_EXIT:
diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
index f0dba4a02..3d861c231 100644
--- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
+++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.accessibility;
import android.content.Context;
import android.text.TextUtils;
+import android.util.Log;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
@@ -27,6 +28,8 @@ import com.android.inputmethod.latin.R;
import java.util.HashMap;
public class KeyCodeDescriptionMapper {
+ private static final String TAG = KeyCodeDescriptionMapper.class.getSimpleName();
+
// The resource ID of the string spoken for obscured keys
private static final int OBSCURED_KEY_RES_ID = R.string.spoken_description_dot;
@@ -87,12 +90,12 @@ public class KeyCodeDescriptionMapper {
* @return a character sequence describing the action performed by pressing
* the key
*/
- public CharSequence getDescriptionForKey(Context context, Keyboard keyboard, Key key,
+ public String getDescriptionForKey(Context context, Keyboard keyboard, Key key,
boolean shouldObscure) {
final int code = key.mCode;
if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
- final CharSequence description = getDescriptionForSwitchAlphaSymbol(context, keyboard);
+ final String description = getDescriptionForSwitchAlphaSymbol(context, keyboard);
if (description != null)
return description;
}
@@ -128,7 +131,7 @@ public class KeyCodeDescriptionMapper {
* @return a character sequence describing the action performed by pressing
* the key
*/
- private CharSequence getDescriptionForSwitchAlphaSymbol(Context context, Keyboard keyboard) {
+ private String getDescriptionForSwitchAlphaSymbol(Context context, Keyboard keyboard) {
final KeyboardId keyboardId = keyboard.mId;
final int elementId = keyboardId.mElementId;
final int resId;
@@ -152,10 +155,7 @@ public class KeyCodeDescriptionMapper {
resId = R.string.spoken_description_to_numeric;
break;
default:
- resId = -1;
- }
-
- if (resId < 0) {
+ Log.e(TAG, "Missing description for keyboard element ID:" + elementId);
return null;
}
@@ -169,7 +169,7 @@ public class KeyCodeDescriptionMapper {
* @param keyboard The keyboard on which the key resides.
* @return A context-sensitive description of the "Shift" key.
*/
- private CharSequence getDescriptionForShiftKey(Context context, Keyboard keyboard) {
+ private String getDescriptionForShiftKey(Context context, Keyboard keyboard) {
final KeyboardId keyboardId = keyboard.mId;
final int elementId = keyboardId.mElementId;
final int resId;
@@ -212,7 +212,7 @@ public class KeyCodeDescriptionMapper {
* @return a character sequence describing the action performed by pressing
* the key
*/
- private CharSequence getDescriptionForKeyCode(Context context, Keyboard keyboard, Key key,
+ private String getDescriptionForKeyCode(Context context, Keyboard keyboard, Key key,
boolean shouldObscure) {
final int code = key.mCode;
diff --git a/java/src/com/android/inputmethod/compat/AccessibilityEventCompatUtils.java b/java/src/com/android/inputmethod/compat/AccessibilityEventCompatUtils.java
deleted file mode 100644
index 2fa9d87d8..000000000
--- a/java/src/com/android/inputmethod/compat/AccessibilityEventCompatUtils.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2011 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.compat;
-
-public class AccessibilityEventCompatUtils {
- public static final int TYPE_VIEW_HOVER_ENTER = 0x80;
- public static final int TYPE_VIEW_HOVER_EXIT = 0x100;
-}
diff --git a/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatUtils.java
index a30af0faf..41b6a074d 100644
--- a/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatWrapper.java
+++ b/java/src/com/android/inputmethod/compat/AccessibilityManagerCompatUtils.java
@@ -20,17 +20,15 @@ import android.view.accessibility.AccessibilityManager;
import java.lang.reflect.Method;
-public class AccessibilityManagerCompatWrapper {
+public class AccessibilityManagerCompatUtils {
private static final Method METHOD_isTouchExplorationEnabled = CompatUtils.getMethod(
AccessibilityManager.class, "isTouchExplorationEnabled");
- private final AccessibilityManager mManager;
-
- public AccessibilityManagerCompatWrapper(AccessibilityManager manager) {
- mManager = manager;
+ private AccessibilityManagerCompatUtils() {
+ // This class is non-instantiable.
}
- public boolean isTouchExplorationEnabled() {
- return (Boolean) CompatUtils.invoke(mManager, false, METHOD_isTouchExplorationEnabled);
+ public static boolean isTouchExplorationEnabled(AccessibilityManager receiver) {
+ return (Boolean) CompatUtils.invoke(receiver, false, METHOD_isTouchExplorationEnabled);
}
}
diff --git a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
index 0e5f8c80a..7e216e5c8 100644
--- a/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
+++ b/java/src/com/android/inputmethod/compat/InputMethodManagerCompatWrapper.java
@@ -150,7 +150,7 @@ public class InputMethodManagerCompatWrapper {
private InputMethodInfoCompatWrapper getLatinImeInputMethodInfo() {
if (TextUtils.isEmpty(mLatinImePackageName))
return null;
- return Utils.getInputMethodInfo(this, mLatinImePackageName);
+ return Utils.getInputMethodInfo(mLatinImePackageName);
}
private static InputMethodSubtypeCompatWrapper getLastResortSubtype(String mode) {
@@ -239,8 +239,7 @@ public class InputMethodManagerCompatWrapper {
// The code below are based on {@link InputMethodManager#showInputMethodMenuInternal}.
- final InputMethodInfoCompatWrapper myImi = Utils.getInputMethodInfo(
- this, mLatinImePackageName);
+ final InputMethodInfoCompatWrapper myImi = Utils.getInputMethodInfo(mLatinImePackageName);
final List<InputMethodSubtypeCompatWrapper> myImsList = getEnabledInputMethodSubtypeList(
myImi, true);
final InputMethodSubtypeCompatWrapper currentIms = getCurrentInputMethodSubtype();
diff --git a/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java b/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java
index 8518a4a78..eca922e68 100644
--- a/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/MotionEventCompatUtils.java
@@ -17,7 +17,7 @@
package com.android.inputmethod.compat;
public class MotionEventCompatUtils {
- public static final int ACTION_HOVER_MOVE = 0x7;
+ // TODO(alanv): Remove after these are added to MotionEventCompat.
public static final int ACTION_HOVER_ENTER = 0x9;
public static final int ACTION_HOVER_EXIT = 0xA;
}
diff --git a/java/src/com/android/inputmethod/compat/ViewParentCompatUtils.java b/java/src/com/android/inputmethod/compat/ViewParentCompatUtils.java
new file mode 100644
index 000000000..d19bc3af1
--- /dev/null
+++ b/java/src/com/android/inputmethod/compat/ViewParentCompatUtils.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.compat;
+
+import android.view.View;
+import android.view.ViewParent;
+import android.view.accessibility.AccessibilityEvent;
+
+import java.lang.reflect.Method;
+
+public class ViewParentCompatUtils {
+ private static final Method METHOD_requestSendAccessibilityEvent = CompatUtils.getMethod(
+ ViewParent.class, "requestSendAccessibilityEvent", View.class,
+ AccessibilityEvent.class);
+
+ /**
+ * Called by a child to request from its parent to send an {@link AccessibilityEvent}.
+ * The child has already populated a record for itself in the event and is delegating
+ * to its parent to send the event. The parent can optionally add a record for itself.
+ * <p>
+ * Note: An accessibility event is fired by an individual view which populates the
+ * event with a record for its state and requests from its parent to perform
+ * the sending. The parent can optionally add a record for itself before
+ * dispatching the request to its parent. A parent can also choose not to
+ * respect the request for sending the event. The accessibility event is sent
+ * by the topmost view in the view tree.</p>
+ *
+ * @param child The child which requests sending the event.
+ * @param event The event to be sent.
+ * @return True if the event was sent.
+ */
+ public static boolean requestSendAccessibilityEvent(
+ ViewParent receiver, View child, AccessibilityEvent event) {
+ return (Boolean) CompatUtils.invoke(
+ receiver, false, METHOD_requestSendAccessibilityEvent, child, event);
+ }
+}
diff --git a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java
index 5c4e9af68..700709d50 100644
--- a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java
+++ b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java
@@ -435,44 +435,6 @@ public class VoiceProxy implements VoiceInput.UiListener {
}
}
- /**
- * Tries to apply any voice alternatives for the word if this was a spoken word and
- * there are voice alternatives.
- * @param touching The word that the cursor is touching, with position information
- * @return true if an alternative was found, false otherwise.
- */
- public boolean applyVoiceAlternatives(EditingUtils.SelectedWord touching) {
- if (!VOICE_INSTALLED) {
- return false;
- }
- // Search for result in spoken word alternatives
- String selectedWord = touching.mWord.toString().trim();
- if (!mWordToSuggestions.containsKey(selectedWord)) {
- selectedWord = selectedWord.toLowerCase();
- }
- if (mWordToSuggestions.containsKey(selectedWord)) {
- mShowingVoiceSuggestions = true;
- List<CharSequence> suggestions = mWordToSuggestions.get(selectedWord);
- SuggestedWords.Builder builder = new SuggestedWords.Builder();
- // If the first letter of touching is capitalized, make all the suggestions
- // start with a capital letter.
- if (Character.isUpperCase(touching.mWord.charAt(0))) {
- for (CharSequence word : suggestions) {
- String str = word.toString();
- word = Character.toUpperCase(str.charAt(0)) + str.substring(1);
- builder.addWord(word);
- }
- } else {
- builder.addWords(suggestions, null);
- }
- builder.setTypedWordValid(true).setHasMinimalSuggestion(true);
- mService.setSuggestions(builder.build());
-// mService.setCandidatesViewShown(true);
- return true;
- }
- return false;
- }
-
public void handleBackspace() {
if (!VOICE_INSTALLED) {
return;
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index f1611d9ee..79c7ce0fd 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -108,9 +108,13 @@ public class Key {
private static final int MORE_KEYS_COLUMN_MASK = 0x000000ff;
private static final int MORE_KEYS_FLAGS_FIXED_COLUMN_ORDER = 0x80000000;
private static final int MORE_KEYS_FLAGS_HAS_LABELS = 0x40000000;
+ private static final int MORE_KEYS_FLAGS_NEEDS_DIVIDERS = 0x40000000;
+ private static final int MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY = 0x20000000;
private static final String MORE_KEYS_AUTO_COLUMN_ORDER = "!autoColumnOrder!";
private static final String MORE_KEYS_FIXED_COLUMN_ORDER = "!fixedColumnOrder!";
private static final String MORE_KEYS_HAS_LABELS = "!hasLabels!";
+ private static final String MORE_KEYS_NEEDS_DIVIDERS = "!needsDividers!";
+ private static final String MORE_KEYS_EMBEDDED_MORE_KEY = "!embeddedMoreKey!";
/** Background type that represents different key background visual than normal one. */
public final int mBackgroundType;
@@ -253,6 +257,12 @@ public class Key {
if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_HAS_LABELS)) {
moreKeysColumn |= MORE_KEYS_FLAGS_HAS_LABELS;
}
+ if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_NEEDS_DIVIDERS)) {
+ moreKeysColumn |= MORE_KEYS_FLAGS_NEEDS_DIVIDERS;
+ }
+ if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_EMBEDDED_MORE_KEY)) {
+ moreKeysColumn |= MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY;
+ }
mMoreKeysColumnAndFlags = moreKeysColumn;
final String[] additionalMoreKeys = style.getStringArray(
@@ -539,12 +549,17 @@ public class Key {
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_HAS_LABELS) != 0;
}
- public Drawable getIcon(KeyboardIconsSet iconSet) {
- return iconSet.getIconDrawable(mIconId);
+ public boolean needsDividersInMoreKeys() {
+ return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
}
- public Drawable getDisabledIcon(KeyboardIconsSet iconSet) {
- return iconSet.getIconDrawable(mDisabledIconId);
+ public boolean hasEmbeddedMoreKey() {
+ return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY) != 0;
+ }
+
+ public Drawable getIcon(KeyboardIconsSet iconSet) {
+ final int iconId = mEnabled ? mIconId : mDisabledIconId;
+ return iconSet.getIconDrawable(iconId);
}
public Drawable getPreviewIcon(KeyboardIconsSet iconSet) {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
index 0ce98d2f1..10cf1d1f4 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -267,7 +267,7 @@ public class KeyDetector {
addDelimiter = false;
} else {
if (addDelimiter) sb.append(", ");
- sb.append(code);
+ sb.append(Keyboard.printableCode(code));
addDelimiter = true;
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 30ed59e18..c6cdf7986 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -85,8 +85,6 @@ public class Keyboard {
public static final int CODE_CLOSING_SQUARE_BRACKET = ']';
public static final int CODE_CLOSING_CURLY_BRACKET = '}';
public static final int CODE_CLOSING_ANGLE_BRACKET = '>';
- public static final int CODE_DIGIT0 = '0';
- public static final int CODE_PLUS = '+';
private static final int MINIMUM_LETTER_CODE = CODE_TAB;
/** Special keys code. Must be negative.
@@ -185,18 +183,11 @@ public class Keyboard {
}
// TODO: Remove this method.
- public boolean isShiftLocked() {
- return mId.isAlphabetShiftLockedKeyboard();
- }
-
- // TODO: Remove this method.
public boolean isShiftedOrShiftLocked() {
- return mId.isAlphabetShiftedOrShiftLockedKeyboard();
- }
-
- // TODO: Remove this method.
- public boolean isManualShifted() {
- return mId.isAlphabetManualShiftedKeyboard();
+ // Alphabet mode have unshifted, manual shifted, automatic shifted, shift locked, and
+ // shift lock shifted element. So that unshifed element is the only one that is NOT in
+ // shifted or shift locked state.
+ return mId.isAlphabetKeyboard() && mId.mElementId != KeyboardId.ELEMENT_ALPHABET;
}
public static boolean isLetterCode(int code) {
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index ed4a89e0f..f5752962e 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -36,6 +36,9 @@ public class KeyboardId {
public static final int MODE_IM = 3;
public static final int MODE_PHONE = 4;
public static final int MODE_NUMBER = 5;
+ public static final int MODE_DATE = 6;
+ public static final int MODE_TIME = 7;
+ public static final int MODE_DATETIME = 8;
public static final int ELEMENT_ALPHABET = 0;
public static final int ELEMENT_ALPHABET_MANUAL_SHIFTED = 1;
@@ -123,31 +126,6 @@ public class KeyboardId {
return mElementId < ELEMENT_SYMBOLS;
}
- public boolean isAlphabetShiftLockedKeyboard() {
- return mElementId == ELEMENT_ALPHABET_SHIFT_LOCKED
- || mElementId == ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED;
- }
-
- public boolean isAlphabetShiftedOrShiftLockedKeyboard() {
- return isAlphabetKeyboard() && mElementId != ELEMENT_ALPHABET;
- }
-
- public boolean isAlphabetManualShiftedKeyboard() {
- return mElementId == ELEMENT_ALPHABET_MANUAL_SHIFTED;
- }
-
- public boolean isSymbolsKeyboard() {
- return mElementId == ELEMENT_SYMBOLS || mElementId == ELEMENT_SYMBOLS_SHIFTED;
- }
-
- public boolean isPhoneKeyboard() {
- return mElementId == ELEMENT_PHONE || mElementId == ELEMENT_PHONE_SYMBOLS;
- }
-
- public boolean isPhoneShiftKeyboard() {
- return mElementId == ELEMENT_PHONE_SYMBOLS;
- }
-
public boolean navigateNext() {
return EditorInfoCompatUtils.hasFlagNavigateNext(mEditorInfo.imeOptions);
}
@@ -242,6 +220,9 @@ public class KeyboardId {
case MODE_IM: return "im";
case MODE_PHONE: return "phone";
case MODE_NUMBER: return "number";
+ case MODE_DATE: return "date";
+ case MODE_TIME: return "time";
+ case MODE_DATETIME: return "datetime";
default: return null;
}
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java
index 6e62f743b..ee882edc0 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java
@@ -131,6 +131,9 @@ public class KeyboardSet {
}
break;
case KeyboardId.MODE_NUMBER:
+ case KeyboardId.MODE_DATE:
+ case KeyboardId.MODE_TIME:
+ case KeyboardId.MODE_DATETIME:
keyboardSetElementId = KeyboardId.ELEMENT_NUMBER;
break;
default:
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 622e5831f..e1c6f2604 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -379,7 +379,7 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
// This always needs to be set since the accessibility state can
// potentially change without the input view being re-created.
- AccessibleKeyboardViewProxy.setView(mKeyboardView);
+ AccessibleKeyboardViewProxy.getInstance().setView(mKeyboardView);
return mCurrentInputView;
}
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index d65253ede..78e0ee230 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -849,7 +849,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
final KeyPreviewDrawParams params = mKeyPreviewDrawParams;
final int keyDrawX = key.mX + key.mVisualInsetsLeft;
final int keyDrawWidth = key.mWidth - key.mVisualInsetsLeft - key.mVisualInsetsRight;
- // What we show as preview should match what we show on key top in onBufferDraw().
+ // What we show as preview should match what we show on a key top in onBufferDraw().
if (key.mLabel != null) {
// TODO Should take care of temporaryShiftLabel here.
previewText.setCompoundDrawables(null, null, null, null);
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 432959508..8a2f89257 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -34,7 +34,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
-import android.view.accessibility.AccessibilityEvent;
import android.widget.PopupWindow;
import com.android.inputmethod.accessibility.AccessibilityUtils;
@@ -42,6 +41,7 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
+import com.android.inputmethod.keyboard.internal.KeySpecParser;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
@@ -481,11 +481,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
*/
protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
final int primaryCode = parentKey.mCode;
- final Keyboard keyboard = getKeyboard();
- if (primaryCode == Keyboard.CODE_DIGIT0 && keyboard.mId.isPhoneKeyboard()) {
+ if (parentKey.hasEmbeddedMoreKey()) {
+ final int embeddedCode = KeySpecParser.getCode(getResources(), parentKey.mMoreKeys[0]);
tracker.onLongPressed();
- // Long pressing on 0 in phone number keypad gives you a '+'.
- invokeCodeInput(Keyboard.CODE_PLUS);
+ invokeCodeInput(embeddedCode);
invokeReleaseKey(primaryCode);
KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode);
return true;
@@ -732,16 +731,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
VoiceProxy.getInstance().onAttachedToWindow();
}
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) {
- return AccessibleKeyboardViewProxy.getInstance().dispatchPopulateAccessibilityEvent(
- event) || super.dispatchPopulateAccessibilityEvent(event);
- }
-
- return super.dispatchPopulateAccessibilityEvent(event);
- }
-
/**
* Receives hover events from the input framework. This method overrides
* View.dispatchHoverEvent(MotionEvent) on SDK version ICS or higher. On
diff --git a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
index abbdfddfe..9f735cff7 100644
--- a/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/MoreKeysKeyboard.java
@@ -17,8 +17,10 @@
package com.android.inputmethod.keyboard;
import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
import com.android.inputmethod.keyboard.internal.KeySpecParser;
+import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.Utils;
@@ -36,8 +38,10 @@ public class MoreKeysKeyboard extends Keyboard {
public static class Builder extends Keyboard.Builder<Builder.MoreKeysKeyboardParams> {
private final Key mParentKey;
+ private final Drawable mDivider;
private static final float LABEL_PADDING_RATIO = 0.2f;
+ private static final float DIVIDER_RATIO = 0.2f;
public static class MoreKeysKeyboardParams extends Keyboard.Params {
public boolean mIsFixedOrder;
@@ -47,6 +51,8 @@ public class MoreKeysKeyboard extends Keyboard {
public int mTopKeys;
public int mLeftKeys;
public int mRightKeys; // includes default key.
+ public int mDividerWidth;
+ public int mColumnWidth;
public MoreKeysKeyboardParams() {
super();
@@ -62,9 +68,11 @@ public class MoreKeysKeyboard extends Keyboard {
* @param coordXInParent coordinate x of the key preview in parent keyboard.
* @param parentKeyboardWidth parent keyboard width in pixel.
* @param isFixedColumnOrder if true, more keys should be laid out in fixed order.
+ * @param dividerWidth width of divider, zero for no dividers.
*/
public void setParameters(int numKeys, int maxColumns, int keyWidth, int rowHeight,
- int coordXInParent, int parentKeyboardWidth, boolean isFixedColumnOrder) {
+ int coordXInParent, int parentKeyboardWidth, boolean isFixedColumnOrder,
+ int dividerWidth) {
mIsFixedOrder = isFixedColumnOrder;
if (parentKeyboardWidth / keyWidth < maxColumns) {
throw new IllegalArgumentException(
@@ -116,7 +124,9 @@ public class MoreKeysKeyboard extends Keyboard {
// Adjustment of the top row.
mTopRowAdjustment = mIsFixedOrder ? getFixedOrderTopRowAdjustment()
: getAutoOrderTopRowAdjustment();
- mBaseWidth = mOccupiedWidth = mNumColumns * mDefaultKeyWidth;
+ mDividerWidth = dividerWidth;
+ mColumnWidth = mDefaultKeyWidth + mDividerWidth;
+ mBaseWidth = mOccupiedWidth = mNumColumns * mColumnWidth - mDividerWidth;
// Need to subtract the bottom row's gutter only.
mBaseHeight = mOccupiedHeight = mNumRows * mDefaultRowHeight - mVerticalGap
+ mTopPadding + mBottomPadding;
@@ -214,13 +224,13 @@ public class MoreKeysKeyboard extends Keyboard {
}
public int getDefaultKeyCoordX() {
- return mLeftKeys * mDefaultKeyWidth;
+ return mLeftKeys * mColumnWidth;
}
public int getX(int n, int row) {
- final int x = getColumnPos(n) * mDefaultKeyWidth + getDefaultKeyCoordX();
+ final int x = getColumnPos(n) * mColumnWidth + getDefaultKeyCoordX();
if (isTopRow(row)) {
- return x + mTopRowAdjustment * (mDefaultKeyWidth / 2);
+ return x + mTopRowAdjustment * (mColumnWidth / 2);
}
return x;
}
@@ -267,9 +277,19 @@ public class MoreKeysKeyboard extends Keyboard {
width = getMaxKeyWidth(view, parentKey, mParams.mDefaultKeyWidth);
height = parentKeyboard.mMostCommonKeyHeight;
}
+ final int dividerWidth;
+ if (parentKey.needsDividersInMoreKeys()) {
+ mDivider = mResources.getDrawable(R.drawable.more_keys_divider);
+ // TODO: Drawable itself should have an alpha value.
+ mDivider.setAlpha(128);
+ dividerWidth = (int)(width * DIVIDER_RATIO);
+ } else {
+ mDivider = null;
+ dividerWidth = 0;
+ }
mParams.setParameters(parentKey.mMoreKeys.length, parentKey.getMoreKeysColumn(),
width, height, parentKey.mX + parentKey.mWidth / 2, view.getMeasuredWidth(),
- parentKey.isFixedColumnOrderMoreKeys());
+ parentKey.isFixedColumnOrderMoreKeys(), dividerWidth);
}
private static int getMaxKeyWidth(KeyboardView view, Key parentKey, int minKeyWidth) {
@@ -295,6 +315,21 @@ public class MoreKeysKeyboard extends Keyboard {
return maxWidth;
}
+ private static class MoreKeyDivider extends Key.Spacer {
+ private final Drawable mIcon;
+
+ public MoreKeyDivider(MoreKeysKeyboardParams params, Drawable icon, int x, int y) {
+ super(params, x, y, params.mDividerWidth, params.mDefaultRowHeight);
+ mIcon = icon;
+ }
+
+ @Override
+ public Drawable getIcon(KeyboardIconsSet iconSet) {
+ // KeyboardIconsSet is unused. Use the icon that has been passed to the constructor.
+ return mIcon;
+ }
+ }
+
@Override
public MoreKeysKeyboard build() {
final MoreKeysKeyboardParams params = mParams;
@@ -306,11 +341,22 @@ public class MoreKeysKeyboard extends Keyboard {
for (int n = 0; n < moreKeys.length; n++) {
final String moreKeySpec = moreKeys[n];
final int row = n / params.mNumColumns;
- final Key key = new Key(mResources, params, moreKeySpec, params.getX(n, row),
- params.getY(row), params.mDefaultKeyWidth, params.mDefaultRowHeight,
- moreKeyFlags);
+ final int x = params.getX(n, row);
+ final int y = params.getY(row);
+ final Key key = new Key(mResources, params, moreKeySpec, x, y,
+ params.mDefaultKeyWidth, params.mDefaultRowHeight, moreKeyFlags);
params.markAsEdgeKey(key, row);
params.onAddKey(key);
+
+ final int pos = params.getColumnPos(n);
+ // The "pos" value represents the offset from the default position. Negative means
+ // left of the default position.
+ if (params.mDividerWidth > 0 && pos != 0) {
+ final int dividerX = (pos > 0) ? x - params.mDividerWidth
+ : x + params.mDefaultKeyWidth;
+ final Key divider = new MoreKeyDivider(params, mDivider, dividerX, y);
+ params.onAddKey(divider);
+ }
}
return new MoreKeysKeyboard(params);
}
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index c45308419..f8f17bdd9 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -722,13 +722,6 @@ public class PointerTracker {
final int[] codes = mKeyDetector.newCodeArray();
mKeyDetector.getKeyAndNearbyCodes(x, y, codes);
- // Swap the first and second values in the codes array if the primary code is not the
- // first value but the second value in the array. This happens when key debouncing is
- // in effect.
- if (codes.length >= 2 && codes[0] != code && codes[1] == code) {
- codes[1] = codes[0];
- codes[0] = code;
- }
callListenerOnCodeInput(key, code, codes, x, y);
callListenerOnRelease(key, code, false);
}
diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
index 41e7ef435..f96f71e8a 100644
--- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
+++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java
@@ -119,38 +119,37 @@ public class ProximityInfo {
sweetSpotCenterYs = new float[keyCount];
sweetSpotRadii = new float[keyCount];
calculateSweetSpotParams = true;
+ int i = 0;
+ for (final Key key : keys) {
+ keyXCoordinates[i] = key.mX;
+ keyYCoordinates[i] = key.mY;
+ keyWidths[i] = key.mWidth;
+ keyHeights[i] = key.mHeight;
+ keyCharCodes[i] = key.mCode;
+ if (calculateSweetSpotParams) {
+ final Rect hitBox = key.mHitBox;
+ final int row = hitBox.top / mKeyHeight;
+ if (row < touchPositionCorrection.mRadii.length) {
+ final float hitBoxCenterX = (hitBox.left + hitBox.right) * 0.5f;
+ final float hitBoxCenterY = (hitBox.top + hitBox.bottom) * 0.5f;
+ final float hitBoxWidth = hitBox.right - hitBox.left;
+ final float hitBoxHeight = hitBox.bottom - hitBox.top;
+ final float x = touchPositionCorrection.mXs[row];
+ final float y = touchPositionCorrection.mYs[row];
+ final float radius = touchPositionCorrection.mRadii[row];
+ sweetSpotCenterXs[i] = hitBoxCenterX + x * hitBoxWidth;
+ sweetSpotCenterYs[i] = hitBoxCenterY + y * hitBoxHeight;
+ sweetSpotRadii[i] = radius * (float) Math.sqrt(
+ hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight);
+ }
+ }
+ i++;
+ }
} else {
sweetSpotCenterXs = sweetSpotCenterYs = sweetSpotRadii = null;
calculateSweetSpotParams = false;
}
- int i = 0;
- for (final Key key : keys) {
- keyXCoordinates[i] = key.mX;
- keyYCoordinates[i] = key.mY;
- keyWidths[i] = key.mWidth;
- keyHeights[i] = key.mHeight;
- keyCharCodes[i] = key.mCode;
- if (calculateSweetSpotParams) {
- final Rect hitBox = key.mHitBox;
- final int row = hitBox.top / mKeyHeight;
- if (row < touchPositionCorrection.mRadii.length) {
- final float hitBoxCenterX = (hitBox.left + hitBox.right) * 0.5f;
- final float hitBoxCenterY = (hitBox.top + hitBox.bottom) * 0.5f;
- final float hitBoxWidth = hitBox.right - hitBox.left;
- final float hitBoxHeight = hitBox.bottom - hitBox.top;
- final float x = touchPositionCorrection.mXs[row];
- final float y = touchPositionCorrection.mYs[row];
- final float radius = touchPositionCorrection.mRadii[row];
- sweetSpotCenterXs[i] = hitBoxCenterX + x * hitBoxWidth;
- sweetSpotCenterYs[i] = hitBoxCenterY + y * hitBoxHeight;
- sweetSpotRadii[i] = radius * (float) Math.sqrt(
- hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight);
- }
- }
- i++;
- }
-
mNativeProximityInfo = setProximityInfoNative(MAX_PROXIMITY_CHARS_SIZE,
keyboardWidth, keyboardHeight, mGridWidth, mGridHeight, proximityCharsArray,
keyCount, keyXCoordinates, keyYCoordinates, keyWidths, keyHeights, keyCharCodes,
diff --git a/java/src/com/android/inputmethod/latin/ComposingStateManager.java b/java/src/com/android/inputmethod/latin/ComposingStateManager.java
index 27f509a29..8811f2023 100644
--- a/java/src/com/android/inputmethod/latin/ComposingStateManager.java
+++ b/java/src/com/android/inputmethod/latin/ComposingStateManager.java
@@ -53,13 +53,6 @@ public class ComposingStateManager {
}
}
- public synchronized boolean isComposing() {
- // TODO: use the composing flag in WordComposer instead of maintaining it
- // here separately. Even better, do away with this class and manage the auto
- // correction indicator in the same place as the suggestions.
- return mIsComposing;
- }
-
public synchronized boolean isAutoCorrectionIndicatorOn() {
return mAutoCorrectionIndicatorOn;
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 953d87beb..64b9f3364 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -979,7 +979,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
.setTypedWordValid(false)
.setHasMinimalSuggestion(false);
// When in fullscreen mode, show completions generated by the application
- setSuggestions(builder.build());
+ final SuggestedWords words = builder.build();
+ final boolean isAutoCorrection = false;
+ setSuggestions(words, isAutoCorrection);
+ setAutoCorrectionIndicator(isAutoCorrection);
// TODO: is this the right thing to do? What should we auto-correct to in
// this case? This says to keep whatever the user typed.
mWordComposer.setAutoCorrection(mWordComposer.getTypedWord());
@@ -1111,12 +1114,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// and the composingStateManager about it.
private void resetEntireInputState() {
resetComposingState(true /* alsoResetLastComposedWord */);
+ mComposingStateManager.onFinishComposingText();
updateSuggestions();
final InputConnection ic = getCurrentInputConnection();
if (ic != null) {
ic.finishComposingText();
}
- mComposingStateManager.onFinishComposingText();
mVoiceProxy.setVoiceInputHighlighted(false);
}
@@ -1533,8 +1536,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// it entirely and resume suggestions on the previous word, we'd like to still
// have touch coordinates for it.
resetComposingState(false /* alsoResetLastComposedWord */);
- clearSuggestions();
mComposingStateManager.onFinishComposingText();
+ clearSuggestions();
}
}
if (isComposingWord) {
@@ -1712,35 +1715,32 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
public void clearSuggestions() {
- setSuggestions(SuggestedWords.EMPTY);
+ setSuggestions(SuggestedWords.EMPTY, false);
+ setAutoCorrectionIndicator(false);
}
- public void setSuggestions(SuggestedWords words) {
+ public void setSuggestions(final SuggestedWords words, final boolean isAutoCorrection) {
if (mSuggestionsView != null) {
mSuggestionsView.setSuggestions(words);
- mKeyboardSwitcher.onAutoCorrectionStateChanged(
- words.hasWordAboveAutoCorrectionScoreThreshold());
+ mKeyboardSwitcher.onAutoCorrectionStateChanged(isAutoCorrection);
}
+ }
+ private void setAutoCorrectionIndicator(final boolean newAutoCorrectionIndicator) {
// Put a blue underline to a word in TextView which will be auto-corrected.
final InputConnection ic = getCurrentInputConnection();
if (ic != null) {
final boolean oldAutoCorrectionIndicator =
mComposingStateManager.isAutoCorrectionIndicatorOn();
- final boolean newAutoCorrectionIndicator = Utils.willAutoCorrect(words);
if (oldAutoCorrectionIndicator != newAutoCorrectionIndicator) {
mComposingStateManager.setAutoCorrectionIndicatorOn(newAutoCorrectionIndicator);
if (DEBUG) {
Log.d(TAG, "Flip the indicator. " + oldAutoCorrectionIndicator
+ " -> " + newAutoCorrectionIndicator);
- if (mComposingStateManager.isComposing() && newAutoCorrectionIndicator
- != mComposingStateManager.isAutoCorrectionIndicatorOn()) {
- throw new RuntimeException("Couldn't flip the indicator!");
- }
}
- final CharSequence textWithUnderline =
- getTextWithUnderline(mWordComposer.getTypedWord());
- if (!TextUtils.isEmpty(textWithUnderline)) {
+ if (mWordComposer.isComposingWord()) {
+ final CharSequence textWithUnderline =
+ getTextWithUnderline(mWordComposer.getTypedWord());
ic.setComposingText(textWithUnderline, 1);
}
}
@@ -1827,28 +1827,28 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
builder.addTypedWordAndPreviousSuggestions(typedWord, previousSuggestions);
}
}
+ if (Utils.shouldBlockAutoCorrectionBySafetyNet(builder, mSuggest)) {
+ builder.setShouldBlockAutoCorrectionBySafetyNet();
+ }
showSuggestions(builder.build(), typedWord);
}
- public void showSuggestions(SuggestedWords suggestedWords, CharSequence typedWord) {
- final boolean shouldBlockAutoCorrectionBySafetyNet =
- Utils.shouldBlockAutoCorrectionBySafetyNet(suggestedWords, mSuggest);
- if (shouldBlockAutoCorrectionBySafetyNet) {
- suggestedWords.setShouldBlockAutoCorrection();
- }
- setSuggestions(suggestedWords);
+ public void showSuggestions(final SuggestedWords suggestedWords, final CharSequence typedWord) {
+ final CharSequence autoCorrection;
if (suggestedWords.size() > 0) {
- if (shouldBlockAutoCorrectionBySafetyNet) {
- mWordComposer.setAutoCorrection(typedWord);
- } else if (suggestedWords.hasAutoCorrectionWord()) {
- mWordComposer.setAutoCorrection(suggestedWords.getWord(1));
+ if (!suggestedWords.mShouldBlockAutoCorrectionBySafetyNet
+ && suggestedWords.hasAutoCorrectionWord()) {
+ autoCorrection = suggestedWords.getWord(1);
} else {
- mWordComposer.setAutoCorrection(typedWord);
+ autoCorrection = typedWord;
}
} else {
- // TODO: replace with mWordComposer.deleteAutoCorrection()?
- mWordComposer.setAutoCorrection(null);
+ autoCorrection = null;
}
+ mWordComposer.setAutoCorrection(autoCorrection);
+ final boolean isAutoCorrection = suggestedWords.willAutoCorrect();
+ setSuggestions(suggestedWords, isAutoCorrection);
+ setAutoCorrectionIndicator(isAutoCorrection);
setSuggestionStripShown(isSuggestionsStripVisible());
}
@@ -1885,7 +1885,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
@Override
public void pickSuggestionManually(final int index, final CharSequence suggestion) {
mComposingStateManager.onFinishComposingText();
- final SuggestedWords suggestions = mSuggestionsView.getSuggestions();
+ final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions();
mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion,
mSettingsValues.mWordSeparators);
@@ -1896,12 +1896,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mSuggestionsView.clear();
}
mKeyboardSwitcher.updateShiftState();
+ resetComposingState(true /* alsoResetLastComposedWord */);
final InputConnection ic = getCurrentInputConnection();
if (ic != null) {
- ic.beginBatchEdit();
final CompletionInfo completionInfo = mApplicationSpecifiedCompletions[index];
ic.commitCompletion(completionInfo);
- ic.endBatchEdit();
}
return;
}
@@ -1910,8 +1909,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (suggestion.length() == 1 && isShowingPunctuationList()) {
// Word separators are suggested before the user inputs something.
// So, LatinImeLogger logs "" as a user's input.
- LatinImeLogger.logOnManualSuggestion(
- "", suggestion.toString(), index, suggestions.mWords);
+ LatinImeLogger.logOnManualSuggestion("", suggestion.toString(), index, suggestedWords);
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
final int primaryCode = suggestion.charAt(0);
onCodeInput(primaryCode, new int[] { primaryCode },
@@ -1922,7 +1920,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// We need to log before we commit, because the word composer will store away the user
// typed word.
LatinImeLogger.logOnManualSuggestion(mWordComposer.getTypedWord().toString(),
- suggestion.toString(), index, suggestions.mWords);
+ suggestion.toString(), index, suggestedWords);
mExpectingUpdateSelection = true;
commitChosenWord(suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK,
LastComposedWord.NOT_A_SEPARATOR);
@@ -2021,7 +2019,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
public void setPunctuationSuggestions() {
- setSuggestions(mSettingsValues.mSuggestPuncList);
+ setSuggestions(mSettingsValues.mSuggestPuncList, false);
+ setAutoCorrectionIndicator(false);
setSuggestionStripShown(isSuggestionsStripVisible());
}
@@ -2414,7 +2413,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
switch (position) {
case 0:
Intent intent = CompatUtils.getInputLanguageSelectionIntent(
- Utils.getInputMethodId(mImm, getPackageName()),
+ Utils.getInputMethodId(getPackageName()),
Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
index e3dadf250..5390ee39e 100644
--- a/java/src/com/android/inputmethod/latin/LatinImeLogger.java
+++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java
@@ -44,7 +44,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
}
public static void logOnManualSuggestion(
- String before, String after, int position, List<CharSequence> suggestions) {
+ String before, String after, int position, SuggestedWords suggestedWords) {
}
public static void logOnAutoCorrection(String before, String after, int separatorCode) {
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index dfcb6450e..3029057be 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -329,10 +329,9 @@ public class Settings extends InputMethodSettingsActivity
@Override
public boolean onPreferenceClick(Preference pref) {
if (pref == mInputLanguageSelection) {
- startActivity(CompatUtils.getInputLanguageSelectionIntent(
- Utils.getInputMethodId(
- InputMethodManagerCompatWrapper.getInstance(),
- getActivityInternal().getApplicationInfo().packageName), 0));
+ final String imeId = Utils.getInputMethodId(
+ getActivityInternal().getApplicationInfo().packageName);
+ startActivity(CompatUtils.getInputLanguageSelectionIntent(imeId, 0));
return true;
}
return false;
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index ed6359cfa..aad975e46 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -20,22 +20,25 @@ import android.text.TextUtils;
import android.view.inputmethod.CompletionInfo;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
public class SuggestedWords {
- public static final SuggestedWords EMPTY = new SuggestedWords(null, false, false, false, null);
+ public static final SuggestedWords EMPTY = new SuggestedWords(null, false, false, false, false,
+ null);
- public final List<CharSequence> mWords;
+ private final List<CharSequence> mWords;
public final boolean mTypedWordValid;
public final boolean mHasAutoCorrectionCandidate;
public final boolean mIsPunctuationSuggestions;
+ public final boolean mShouldBlockAutoCorrectionBySafetyNet;
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
- private boolean mShouldBlockAutoCorrection;
- private SuggestedWords(List<CharSequence> words, boolean typedWordValid,
+ SuggestedWords(List<CharSequence> words, boolean typedWordValid,
boolean hasAutoCorrectionCandidate, boolean isPunctuationSuggestions,
+ boolean shouldBlockAutoCorrectionBySafetyNet,
List<SuggestedWordInfo> suggestedWordInfoList) {
if (words != null) {
mWords = words;
@@ -45,8 +48,8 @@ public class SuggestedWords {
mTypedWordValid = typedWordValid;
mHasAutoCorrectionCandidate = hasAutoCorrectionCandidate;
mIsPunctuationSuggestions = isPunctuationSuggestions;
+ mShouldBlockAutoCorrectionBySafetyNet = shouldBlockAutoCorrectionBySafetyNet;
mSuggestedWordInfoList = suggestedWordInfoList;
- mShouldBlockAutoCorrection = false;
}
public int size() {
@@ -65,20 +68,20 @@ public class SuggestedWords {
return mHasAutoCorrectionCandidate && size() > 1 && !mTypedWordValid;
}
- public boolean hasWordAboveAutoCorrectionScoreThreshold() {
- return mHasAutoCorrectionCandidate && ((size() > 1 && !mTypedWordValid) || mTypedWordValid);
+ public boolean willAutoCorrect() {
+ return !mTypedWordValid && mHasAutoCorrectionCandidate
+ && !mShouldBlockAutoCorrectionBySafetyNet;
}
- public boolean isPunctuationSuggestions() {
- return mIsPunctuationSuggestions;
- }
-
- public void setShouldBlockAutoCorrection() {
- mShouldBlockAutoCorrection = true;
- }
-
- public boolean shouldBlockAutoCorrection() {
- return mShouldBlockAutoCorrection;
+ @Override
+ public String toString() {
+ // Pretty-print method to help debug
+ return "SuggestedWords:"
+ + " mTypedWordValid=" + mTypedWordValid
+ + " mHasAutoCorrectionCandidate=" + mHasAutoCorrectionCandidate
+ + " mIsPunctuationSuggestions=" + mIsPunctuationSuggestions
+ + " mShouldBlockAutoCorrectionBySafetyNet=" + mShouldBlockAutoCorrectionBySafetyNet
+ + " mWords=" + Arrays.toString(mWords.toArray());
}
public static class Builder {
@@ -86,6 +89,7 @@ public class SuggestedWords {
private boolean mTypedWordValid;
private boolean mHasMinimalSuggestion;
private boolean mIsPunctuationSuggestions;
+ private boolean mShouldBlockAutoCorrectionBySafetyNet;
private List<SuggestedWordInfo> mSuggestedWordInfoList =
new ArrayList<SuggestedWordInfo>();
@@ -150,6 +154,11 @@ public class SuggestedWords {
return this;
}
+ public Builder setShouldBlockAutoCorrectionBySafetyNet() {
+ mShouldBlockAutoCorrectionBySafetyNet = true;
+ return this;
+ }
+
// Should get rid of the first one (what the user typed previously) from suggestions
// and replace it with what the user currently typed.
public Builder addTypedWordAndPreviousSuggestions(CharSequence typedWord,
@@ -175,7 +184,8 @@ public class SuggestedWords {
public SuggestedWords build() {
return new SuggestedWords(mWords, mTypedWordValid, mHasMinimalSuggestion,
- mIsPunctuationSuggestions, mSuggestedWordInfoList);
+ mIsPunctuationSuggestions, mShouldBlockAutoCorrectionBySafetyNet,
+ mSuggestedWordInfoList);
}
public int size() {
@@ -186,18 +196,20 @@ public class SuggestedWords {
return mWords.get(pos);
}
+ public boolean isTypedWordValid() {
+ return mTypedWordValid;
+ }
+
@Override
public String toString() {
// Pretty-print method to help debug
- final StringBuilder sb = new StringBuilder("StringBuilder: mTypedWordValid = "
- + mTypedWordValid + " ; mHasMinimalSuggestion = " + mHasMinimalSuggestion
- + " ; mIsPunctuationSuggestions = " + mIsPunctuationSuggestions
- + " --- ");
- for (CharSequence s : mWords) {
- sb.append(s);
- sb.append(" ; ");
- }
- return sb.toString();
+ return "SuggestedWords.Builder:"
+ + " mTypedWordValid=" + mTypedWordValid
+ + " mHasMinimalSuggestion=" + mHasMinimalSuggestion
+ + " mIsPunctuationSuggestions=" + mIsPunctuationSuggestions
+ + " mShouldBlockAutoCorrectionBySafetyNet="
+ + mShouldBlockAutoCorrectionBySafetyNet
+ + " mWords=" + Arrays.toString(mWords.toArray());
}
}
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index 6d63e95f6..33d4b877e 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -171,12 +171,16 @@ public class Utils {
return keyboardCount > 1;
}
- public static String getInputMethodId(InputMethodManagerCompatWrapper imm, String packageName) {
- return getInputMethodInfo(imm, packageName).getId();
+ public static String getInputMethodId(String packageName) {
+ return getInputMethodInfo(packageName).getId();
}
- public static InputMethodInfoCompatWrapper getInputMethodInfo(
- InputMethodManagerCompatWrapper imm, String packageName) {
+ public static InputMethodInfoCompatWrapper getInputMethodInfo(String packageName) {
+ final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance();
+ if (imm == null) {
+ throw new RuntimeException("Input method manager not found");
+ }
+
for (final InputMethodInfoCompatWrapper imi : imm.getEnabledInputMethodList()) {
if (imi.getPackageName().equals(packageName))
return imi;
@@ -186,19 +190,25 @@ public class Utils {
// TODO: Resolve the inconsistencies between the native auto correction algorithms and
// this safety net
- public static boolean shouldBlockAutoCorrectionBySafetyNet(SuggestedWords suggestions,
- Suggest suggest) {
+ public static boolean shouldBlockAutoCorrectionBySafetyNet(
+ SuggestedWords.Builder suggestedWordsBuilder, Suggest suggest) {
// Safety net for auto correction.
// Actually if we hit this safety net, it's actually a bug.
- if (suggestions.size() <= 1 || suggestions.mTypedWordValid) return false;
+ if (suggestedWordsBuilder.size() <= 1 || suggestedWordsBuilder.isTypedWordValid()) {
+ return false;
+ }
// If user selected aggressive auto correction mode, there is no need to use the safety
// net.
- if (suggest.isAggressiveAutoCorrectionMode()) return false;
- final CharSequence typedWord = suggestions.getWord(0);
+ if (suggest.isAggressiveAutoCorrectionMode()) {
+ return false;
+ }
+ final CharSequence typedWord = suggestedWordsBuilder.getWord(0);
// If the length of typed word is less than MINIMUM_SAFETY_NET_CHAR_LENGTH,
// we should not use net because relatively edit distance can be big.
- if (typedWord.length() < MINIMUM_SAFETY_NET_CHAR_LENGTH) return false;
- final CharSequence suggestionWord = suggestions.getWord(1);
+ if (typedWord.length() < MINIMUM_SAFETY_NET_CHAR_LENGTH) {
+ return false;
+ }
+ final CharSequence suggestionWord = suggestedWordsBuilder.getWord(1);
final int typedWordLength = typedWord.length();
final int maxEditDistanceOfNativeDictionary =
(typedWordLength < 5 ? 2 : typedWordLength / 2) + 1;
@@ -563,8 +573,16 @@ public class Utils {
switch (inputType & InputType.TYPE_MASK_CLASS) {
case InputType.TYPE_CLASS_NUMBER:
- case InputType.TYPE_CLASS_DATETIME:
return KeyboardId.MODE_NUMBER;
+ case InputType.TYPE_CLASS_DATETIME:
+ switch (variation) {
+ case InputType.TYPE_DATETIME_VARIATION_DATE:
+ return KeyboardId.MODE_DATE;
+ case InputType.TYPE_DATETIME_VARIATION_TIME:
+ return KeyboardId.MODE_TIME;
+ default: // InputType.TYPE_DATETIME_VARIATION_NORMAL
+ return KeyboardId.MODE_DATETIME;
+ }
case InputType.TYPE_CLASS_PHONE:
return KeyboardId.MODE_PHONE;
case InputType.TYPE_CLASS_TEXT:
@@ -766,11 +784,6 @@ public class Utils {
return s.toUpperCase(locale).charAt(0) + s.substring(1);
}
- public static boolean willAutoCorrect(SuggestedWords suggestions) {
- return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate
- && !suggestions.shouldBlockAutoCorrection();
- }
-
public static class Stats {
public static void onNonSeparator(final char code, final int x,
final int y) {
diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
index 0bd6abe09..cb1b49c67 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
@@ -34,7 +34,7 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
public class MoreSuggestions extends Keyboard {
public static final int SUGGESTION_CODE_BASE = 1024;
- private MoreSuggestions(Builder.MoreSuggestionsParam params) {
+ MoreSuggestions(Builder.MoreSuggestionsParam params) {
super(params);
}
@@ -63,7 +63,7 @@ public class MoreSuggestions extends Keyboard {
paint.setAntiAlias(true);
final Resources res = view.getContext().getResources();
mDivider = res.getDrawable(R.drawable.more_suggestions_divider);
- // TODO: Drawable itself should has an alpha value.
+ // TODO: Drawable itself should have an alpha value.
mDivider.setAlpha(128);
mDividerWidth = mDivider.getIntrinsicWidth();
final int padding = (int) res.getDimension(
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java
index 40d782640..d3362940f 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java
@@ -62,7 +62,6 @@ import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
-import com.android.inputmethod.latin.Utils;
import java.util.ArrayList;
import java.util.List;
@@ -95,7 +94,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
private final TextView mPreviewText;
private Listener mListener;
- private SuggestedWords mSuggestions = SuggestedWords.EMPTY;
+ private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;
private final SuggestionsViewParams mParams;
private static final float MIN_TEXT_XSCALE = 0.70f;
@@ -259,10 +258,10 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
return a.getFraction(index, 1000, 1000, 1) / 1000.0f;
}
- private CharSequence getStyledSuggestionWord(SuggestedWords suggestions, int pos) {
- final CharSequence word = suggestions.getWord(pos);
- final boolean isAutoCorrect = pos == 1 && Utils.willAutoCorrect(suggestions);
- final boolean isTypedWordValid = pos == 0 && suggestions.mTypedWordValid;
+ private CharSequence getStyledSuggestionWord(SuggestedWords suggestedWords, int pos) {
+ final CharSequence word = suggestedWords.getWord(pos);
+ final boolean isAutoCorrect = pos == 1 && suggestedWords.willAutoCorrect();
+ final boolean isTypedWordValid = pos == 0 && suggestedWords.mTypedWordValid;
if (!isAutoCorrect && !isTypedWordValid)
return word;
@@ -279,10 +278,10 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
return spannedWord;
}
- private int getWordPosition(int index, SuggestedWords suggestions) {
+ private int getWordPosition(int index, SuggestedWords suggestedWords) {
// TODO: This works for 3 suggestions. Revisit this algorithm when there are 5 or more
// suggestions.
- final int centerPos = Utils.willAutoCorrect(suggestions) ? 1 : 0;
+ final int centerPos = suggestedWords.willAutoCorrect() ? 1 : 0;
if (index == mCenterSuggestionIndex) {
return centerPos;
} else if (index == centerPos) {
@@ -292,14 +291,14 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
}
}
- private int getSuggestionTextColor(int index, SuggestedWords suggestions, int pos) {
+ private int getSuggestionTextColor(int index, SuggestedWords suggestedWords, int pos) {
// TODO: Need to revisit this logic with bigram suggestions
final boolean isSuggested = (pos != 0);
final int color;
- if (index == mCenterSuggestionIndex && Utils.willAutoCorrect(suggestions)) {
+ if (index == mCenterSuggestionIndex && suggestedWords.willAutoCorrect()) {
color = mColorAutoCorrect;
- } else if (index == mCenterSuggestionIndex && suggestions.mTypedWordValid) {
+ } else if (index == mCenterSuggestionIndex && suggestedWords.mTypedWordValid) {
color = mColorValidTypedWord;
} else if (isSuggested) {
color = mColorSuggested;
@@ -307,14 +306,14 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
color = mColorTypedWord;
}
if (LatinImeLogger.sDBG) {
- if (index == mCenterSuggestionIndex && suggestions.mHasAutoCorrectionCandidate
- && suggestions.shouldBlockAutoCorrection()) {
+ if (index == mCenterSuggestionIndex && suggestedWords.mHasAutoCorrectionCandidate
+ && suggestedWords.mShouldBlockAutoCorrectionBySafetyNet) {
return 0xFFFF0000;
}
}
- final SuggestedWordInfo info = (pos < suggestions.size())
- ? suggestions.getInfo(pos) : null;
+ final SuggestedWordInfo info = (pos < suggestedWords.size())
+ ? suggestedWords.getInfo(pos) : null;
if (info != null && info.isObsoleteSuggestedWord()) {
return applyAlpha(color, mAlphaObsoleted);
} else {
@@ -334,19 +333,19 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
params.gravity = Gravity.CENTER;
}
- public void layout(SuggestedWords suggestions, ViewGroup stripView, ViewGroup placer,
+ public void layout(SuggestedWords suggestedWords, ViewGroup stripView, ViewGroup placer,
int stripWidth) {
- if (suggestions.isPunctuationSuggestions()) {
- layoutPunctuationSuggestions(suggestions, stripView);
+ if (suggestedWords.mIsPunctuationSuggestions) {
+ layoutPunctuationSuggestions(suggestedWords, stripView);
return;
}
final int countInStrip = mSuggestionsCountInStrip;
- setupTexts(suggestions, countInStrip);
- mMoreSuggestionsAvailable = (suggestions.size() > countInStrip);
+ setupTexts(suggestedWords, countInStrip);
+ mMoreSuggestionsAvailable = (suggestedWords.size() > countInStrip);
int x = 0;
for (int index = 0; index < countInStrip; index++) {
- final int pos = getWordPosition(index, suggestions);
+ final int pos = getWordPosition(index, suggestedWords);
if (index != 0) {
final View divider = mDividers.get(pos);
@@ -369,7 +368,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
// Disable this suggestion if the suggestion is null or empty.
word.setEnabled(!TextUtils.isEmpty(styled));
- word.setTextColor(getSuggestionTextColor(index, suggestions, pos));
+ word.setTextColor(getSuggestionTextColor(index, suggestedWords, pos));
final int width = getSuggestionWidth(index, stripWidth);
final CharSequence text = getEllipsizedText(styled, width, word.getPaint());
final float scaleX = word.getTextScaleX();
@@ -381,7 +380,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
x += word.getMeasuredWidth();
if (DBG) {
- final CharSequence debugInfo = getDebugInfo(suggestions, pos);
+ final CharSequence debugInfo = getDebugInfo(suggestedWords, pos);
if (debugInfo != null) {
final TextView info = mInfos.get(pos);
info.setText(debugInfo);
@@ -413,11 +412,11 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
}
}
- private void setupTexts(SuggestedWords suggestions, int countInStrip) {
+ private void setupTexts(SuggestedWords suggestedWords, int countInStrip) {
mTexts.clear();
- final int count = Math.min(suggestions.size(), countInStrip);
+ final int count = Math.min(suggestedWords.size(), countInStrip);
for (int pos = 0; pos < count; pos++) {
- final CharSequence styled = getStyledSuggestionWord(suggestions, pos);
+ final CharSequence styled = getStyledSuggestionWord(suggestedWords, pos);
mTexts.add(styled);
}
for (int pos = count; pos < countInStrip; pos++) {
@@ -426,8 +425,9 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
}
}
- private void layoutPunctuationSuggestions(SuggestedWords suggestions, ViewGroup stripView) {
- final int countInStrip = Math.min(suggestions.size(), PUNCTUATIONS_IN_STRIP);
+ private void layoutPunctuationSuggestions(SuggestedWords suggestedWords,
+ ViewGroup stripView) {
+ final int countInStrip = Math.min(suggestedWords.size(), PUNCTUATIONS_IN_STRIP);
for (int index = 0; index < countInStrip; index++) {
if (index != 0) {
// Add divider if this isn't the left most suggestion in suggestions strip.
@@ -437,7 +437,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
final TextView word = mWords.get(index);
word.setEnabled(true);
word.setTextColor(mColorAutoCorrect);
- final CharSequence text = suggestions.getWord(index);
+ final CharSequence text = suggestedWords.getWord(index);
word.setText(text);
word.setTextScaleX(1.0f);
word.setCompoundDrawables(null, null, null, null);
@@ -636,13 +636,13 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
mKeyboardView = (KeyboardView)inputView.findViewById(R.id.keyboard_view);
}
- public void setSuggestions(SuggestedWords suggestions) {
- if (suggestions == null || suggestions.size() == 0)
+ public void setSuggestions(SuggestedWords suggestedWords) {
+ if (suggestedWords == null || suggestedWords.size() == 0)
return;
clear();
- mSuggestions = suggestions;
- mParams.layout(mSuggestions, mSuggestionsStrip, this, getWidth());
+ mSuggestedWords = suggestedWords;
+ mParams.layout(mSuggestedWords, mSuggestionsStrip, this, getWidth());
}
@@ -665,7 +665,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
}
public SuggestedWords getSuggestions() {
- return mSuggestions;
+ return mSuggestedWords;
}
public void clear() {
@@ -688,7 +688,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
@Override
public boolean onCustomRequest(int requestCode) {
final int index = requestCode;
- final CharSequence word = mSuggestions.getWord(index);
+ final CharSequence word = mSuggestedWords.getWord(index);
mListener.pickSuggestionManually(index, word);
dismissMoreSuggestions();
return true;
@@ -733,7 +733,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
final int maxWidth = stripWidth - container.getPaddingLeft()
- container.getPaddingRight();
final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder;
- builder.layout(mSuggestions, params.mSuggestionsCountInStrip, maxWidth,
+ builder.layout(mSuggestedWords, params.mSuggestionsCountInStrip, maxWidth,
(int)(maxWidth * params.mMinMoreSuggestionsWidth),
params.mMaxMoreSuggestionsRow);
mMoreSuggestionsView.setKeyboard(builder.build());
@@ -835,10 +835,10 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
if (!(tag instanceof Integer))
return;
final int index = (Integer) tag;
- if (index >= mSuggestions.size())
+ if (index >= mSuggestedWords.size())
return;
- final CharSequence word = mSuggestions.getWord(index);
+ final CharSequence word = mSuggestedWords.getWord(index);
mListener.pickSuggestionManually(index, word);
}