diff options
103 files changed, 1436 insertions, 1074 deletions
diff --git a/java/res/values-ar/donottranslate-more-keys.xml b/java/res/values-ar/donottranslate-more-keys.xml index 6a14a3c55..9a7a0267a 100644 --- a/java/res/values-ar/donottranslate-more-keys.xml +++ b/java/res/values-ar/donottranslate-more-keys.xml @@ -102,8 +102,43 @@ <string name="more_keys_for_bullet">♪</string> <!-- \u066d: ARABIC FIVE POINTED STAR --> <string name="more_keys_for_star">★,\u066d</string> - <!-- \ufd3e: ORNATE LEFT PARENTHESIS --> - <string name="more_keys_for_left_parenthesis">[,{,<,\ufd3e</string> - <!-- \ufd3f: ORNATE RIGHT PARENTHESIS --> - <string name="more_keys_for_right_parenthesis">],},>,\ufd3f</string> + <!-- The all letters need to be mirrored are found at + http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt --> + <string name="output_text_for_left_parenthesis">)</string> + <string name="output_text_for_right_parenthesis">(</string> + <!-- \ufd3e: ORNATE LEFT PARENTHESIS + \ufd3f: ORNATE RIGHT PARENTHESIS --> + <string name="more_keys_for_left_parenthesis">[|],{|},<|>,\ufd3e|\ufd3f</string> + <string name="more_keys_for_right_parenthesis">]|[,}|{,>|<,\ufd3f|\ufd3e</string> + <string name="output_text_for_less_than">></string> + <string name="output_text_for_greater_than"><</string> + <!-- \u2264: LESS-THAN OR EQUAL TO + \u2265: GREATER-THAN EQUAL TO + \u00ab: LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + \u00bb: RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + \u2039: SINGLE LEFT-POINTING ANGLE QUOTATION MARK + \u203a: SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + The following characters don't need BIDI mirroring. + \u2018: LEFT SINGLE QUOTATION MARK + \u2019: RIGHT SINGLE QUOTATION MARK + \u201a: SINGLE LOW-9 QUOTATION MARK + \u201b: SINGLE HIGH-REVERSED-9 QUOTATION MARK + \u201c: LEFT DOUBLE QUOTATION MARK + \u201d: RIGHT DOUBLE QUOTATION MARK + \u201e: DOUBLE LOW-9 QUOTATION MARK + \u201f: DOUBLE HIGH-REVERSED-9 QUOTATION MARK --> + <string name="more_keys_for_less_than">\u2264|\u2265,\u00ab|\u00bb,\u2039|\u203a</string> + <string name="more_keys_for_greater_than">\u2265|\u2264,\u00bb|\u00ab,\u203a|\u2039</string> + <string name="output_text_for_left_square_bracket">]</string> + <string name="output_text_for_right_square_bracket">[</string> + <string name="output_text_for_left_curly_bracket">}</string> + <string name="output_text_for_right_curly_bracket">{</string> + <!-- Note: Neither DroidSans nor Roboto have a glyph for DOUBLE HIGH-REVERSED-9 QUOTATION MARK. --> + <!-- <string name="more_keys_for_double_quote">\u201c,\u201d,\u201e,\u201f,\u00ab,\u00bb</string> --> + <!-- The 4-more keys will be displayed in order of "3,1,2,4". --> + <string name="more_keys_for_double_quote">\u201d,\u00ab|\u00bb,\u201c,\u00bb|\u00ab</string> + <!-- Note: Neither DroidSans nor Roboto have a glyph for DOUBLE HIGH-REVERSED-9 QUOTATION MARK. --> + <!-- <string name="more_keys_for_tablet_double_quote">\u201c,\u201d,\u201e,\u201f,\u00ab,\u00bb,\u2018,\u2019,\u201a,\u201b</string> --> + <!-- The 8-more keys with maxMoreKeysColumn=4 will be displayed in order of "3,1,2,4|7,5,6,8". --> + <string name="more_keys_for_tablet_double_quote">\u201d,\u00ab|\u00bb,\u201c,\u00bb|\u00ab,\u2019,\u201a,\u2018,\u201b</string> </resources> diff --git a/java/res/values-ar/donottranslate.xml b/java/res/values-ar/donottranslate.xml new file mode 100644 index 000000000..a9aad4e3c --- /dev/null +++ b/java/res/values-ar/donottranslate.xml @@ -0,0 +1,25 @@ +<?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"> + <!-- The all letters need to be mirrored are found at + http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt --> + <!-- Symbols that are suggested between words --> + <string name="suggested_punctuations">!,?,\\,,:,;,\u0022,(|),)|(,\u0027,-,/,@,_</string> +</resources> diff --git a/java/res/values-en/additional-proximitychars.xml b/java/res/values-en/additional-proximitychars.xml new file mode 100644 index 000000000..0e1276796 --- /dev/null +++ b/java/res/values-en/additional-proximitychars.xml @@ -0,0 +1,62 @@ +<?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"> + + <string-array name="additional_proximitychars"> + <!-- Empty entry terminates the proximity chars array. --> + + <!-- Additional proximity chars for a --> + <item>a</item> + <item>e</item> + <item>i</item> + <item>o</item> + <item>u</item> + <item></item> + <!-- Additional proximity chars for e --> + <item>e</item> + <item>a</item> + <item>i</item> + <item>o</item> + <item>u</item> + <item></item> + <!-- Additional proximity chars for i --> + <item>i</item> + <item>a</item> + <item>e</item> + <item>o</item> + <item>u</item> + <item></item> + <!-- Additional proximity chars for o --> + <item>o</item> + <item>a</item> + <item>e</item> + <item>i</item> + <item>u</item> + <item></item> + <!-- Additional proximity chars for u --> + <item>u</item> + <item>a</item> + <item>e</item> + <item>i</item> + <item>o</item> + <item></item> + </string-array> + +</resources>
\ No newline at end of file diff --git a/java/res/values-iw/donottranslate-more-keys.xml b/java/res/values-iw/donottranslate-more-keys.xml index 829486f7b..6fc336002 100644 --- a/java/res/values-iw/donottranslate-more-keys.xml +++ b/java/res/values-iw/donottranslate-more-keys.xml @@ -20,4 +20,41 @@ <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <string name="more_keys_for_star">★</string> <string name="more_keys_for_plus">±,﬩</string> + <!-- The all letters need to be mirrored are found at + http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt --> + <string name="output_text_for_left_parenthesis">)</string> + <string name="output_text_for_right_parenthesis">(</string> + <string name="more_keys_for_left_parenthesis">[|],{|},<|></string> + <string name="more_keys_for_right_parenthesis">]|[,}|{,>|<</string> + <string name="output_text_for_less_than">></string> + <string name="output_text_for_greater_than"><</string> + <!-- \u2264: LESS-THAN OR EQUAL TO + \u2265: GREATER-THAN EQUAL TO + \u00ab: LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + \u00bb: RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + \u2039: SINGLE LEFT-POINTING ANGLE QUOTATION MARK + \u203a: SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + The following characters don't need BIDI mirroring. + \u2018: LEFT SINGLE QUOTATION MARK + \u2019: RIGHT SINGLE QUOTATION MARK + \u201a: SINGLE LOW-9 QUOTATION MARK + \u201b: SINGLE HIGH-REVERSED-9 QUOTATION MARK + \u201c: LEFT DOUBLE QUOTATION MARK + \u201d: RIGHT DOUBLE QUOTATION MARK + \u201e: DOUBLE LOW-9 QUOTATION MARK + \u201f: DOUBLE HIGH-REVERSED-9 QUOTATION MARK --> + <string name="more_keys_for_less_than">\u2264|\u2265,\u00ab|\u00bb,\u2039|\u203a</string> + <string name="more_keys_for_greater_than">\u2265|\u2264,\u00bb|\u00ab,\u203a|\u2039</string> + <string name="output_text_for_left_square_bracket">]</string> + <string name="output_text_for_right_square_bracket">[</string> + <string name="output_text_for_left_curly_bracket">}</string> + <string name="output_text_for_right_curly_bracket">{</string> + <!-- Note: Neither DroidSans nor Roboto have a glyph for DOUBLE HIGH-REVERSED-9 QUOTATION MARK. --> + <!-- <string name="more_keys_for_double_quote">\u201c,\u201d,\u201e,\u201f,\u00ab,\u00bb</string> --> + <!-- The 4-more keys will be displayed in order of "3,1,2,4". --> + <string name="more_keys_for_double_quote">\u201d,\u00ab|\u00bb,\u201c,\u00bb|\u00ab</string> + <!-- Note: Neither DroidSans nor Roboto have a glyph for DOUBLE HIGH-REVERSED-9 QUOTATION MARK. --> + <!-- <string name="more_keys_for_tablet_double_quote">\u201c,\u201d,\u201e,\u201f,\u00ab,\u00bb,\u2018,\u2019,\u201a,\u201b</string> --> + <!-- The 8-more keys with maxMoreKeysColumn=4 will be displayed in order of "3,1,2,4|7,5,6,8". --> + <string name="more_keys_for_tablet_double_quote">\u201d,\u00ab|\u00bb,\u201c,\u00bb|\u00ab,\u2019,\u201a,\u2018,\u201b</string> </resources> diff --git a/java/res/values-iw/donottranslate.xml b/java/res/values-iw/donottranslate.xml new file mode 100644 index 000000000..a9aad4e3c --- /dev/null +++ b/java/res/values-iw/donottranslate.xml @@ -0,0 +1,25 @@ +<?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"> + <!-- The all letters need to be mirrored are found at + http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt --> + <!-- Symbols that are suggested between words --> + <string name="suggested_punctuations">!,?,\\,,:,;,\u0022,(|),)|(,\u0027,-,/,@,_</string> +</resources> diff --git a/java/res/xml-ar/kbd_symbols.xml b/java/res/values/additional-proximitychars.xml index c1905b875..03d10d5d8 100644 --- a/java/res/xml-ar/kbd_symbols.xml +++ b/java/res/values/additional-proximitychars.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2011, The Android Open Source Project +** 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. @@ -17,11 +17,7 @@ ** limitations under the License. */ --> - -<Keyboard - xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:isRtlKeyboard="true" -> - <include - latin:keyboardLayout="@xml/rows_symbols" /> -</Keyboard> +<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string-array name="additional_proximitychars"> + </string-array> +</resources> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index a5bf6f69a..dd2206da8 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -202,8 +202,6 @@ <attr name="verticalGap" format="dimension|fraction" /> <!-- More keys keyboard layout template --> <attr name="moreKeysTemplate" format="reference" /> - <!-- True if the keyboard is Right-To-Left --> - <attr name="isRtlKeyboard" format="boolean" /> <!-- Icon set for key top and key preview. --> <attr name="iconShiftKey" format="reference" /> <attr name="iconDeleteKey" format="reference" /> @@ -249,6 +247,7 @@ <flag name="isRepeatable" value="0x01" /> <flag name="noKeyPreview" value="0x02" /> <flag name="altCodeWhileTyping" value="0x04" /> + <flag name="enableLongPress" value="0x08" /> </attr> <!-- The string of characters to output when this key is pressed. --> <attr name="keyOutputText" format="string" /> @@ -341,7 +340,7 @@ <enum name="symbols" value="5" /> <enum name="symbolsShifted" value="6" /> <enum name="phone" value="7" /> - <enum name="phoneShifted" value="8" /> + <enum name="phoneSymbols" value="8" /> <enum name="number" value="9" /> </attr> <!-- This should be aligned with KeyboardId.MODE_* --> @@ -403,7 +402,7 @@ <enum name="symbols" value="5" /> <enum name="symbolsShifted" value="6" /> <enum name="phone" value="7" /> - <enum name="phoneShifted" value="8" /> + <enum name="phoneSymbols" value="8" /> <enum name="number" value="9" /> </attr> <attr name="elementKeyboard" format="reference"/> diff --git a/java/res/values/donottranslate-more-keys.xml b/java/res/values/donottranslate-more-keys.xml index 07f4bf38b..d7b1ff5e7 100644 --- a/java/res/values/donottranslate-more-keys.xml +++ b/java/res/values/donottranslate-more-keys.xml @@ -54,7 +54,7 @@ <string name="more_keys_for_currency_euro">¢,£,$,¥,₱</string> <string name="more_keys_for_currency_pound">¢,$,€,¥,₱</string> <string name="more_keys_for_currency_general">¢,$,€,£,¥,₱</string> - <string name="more_keys_for_smiley">":-)|:-) ,:-(|:-( ,;-)|;-) ,:-P|:-P ,=-O|=-O ,:-*|:-* ,:O|:O ,B-)|B-) ,:-$|:-$ ,:-!|:-! ,:-[|:-[ ,O:-)|O:-) ,:-\\\\\\\\|:-\\\\\\\\ ,:\'(|:\'( ,:-D|:-D "</string> + <string name="more_keys_for_smiley">":-)|:-) ,:-(|:-( ,;-)|;-) ,:-P|:-P ,=-O|=-O ,:-*|:-* ,:O|:O ,B-)|B-) ,:-$|:-$ ,:-!|:-! ,:-[|:-[ ,O:-)|O:-) ,:-\\\\|:-\\\\ ,:\'(|:\'( ,:-D|:-D "</string> <string name="more_keys_for_punctuation">"\\,,\?,!,:,-,\',\",(,),/,;,+,&,\@"</string> <integer name="mini_keyboard_column_for_punctuation">7</integer> <string name="keyhintlabel_for_punctuation"></string> @@ -112,6 +112,43 @@ <string name="more_keys_for_bullet">♪,♥,♠,♦,♣</string> <string name="more_keys_for_star">†,‡,★</string> <string name="more_keys_for_plus">±</string> + <!-- The all letters need to be mirrored are found at + http://www.unicode.org/Public/6.1.0/ucd/BidiMirroring.txt --> + <string name="output_text_for_left_parenthesis">(</string> + <string name="output_text_for_right_parenthesis">)</string> <string name="more_keys_for_left_parenthesis">[,{,<</string> <string name="more_keys_for_right_parenthesis">],},></string> + <string name="output_text_for_less_than"><</string> + <string name="output_text_for_greater_than">></string> + <!-- \u2264: LESS-THAN OR EQUAL TO + \u2265: GREATER-THAN EQUAL TO + \u00ab: LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + \u00bb: RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + \u2039: SINGLE LEFT-POINTING ANGLE QUOTATION MARK + \u203a: SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + The following characters don't need BIDI mirroring. + \u2018: LEFT SINGLE QUOTATION MARK + \u2019: RIGHT SINGLE QUOTATION MARK + \u201a: SINGLE LOW-9 QUOTATION MARK + \u201b: SINGLE HIGH-REVERSED-9 QUOTATION MARK + \u201c: LEFT DOUBLE QUOTATION MARK + \u201d: RIGHT DOUBLE QUOTATION MARK + \u201e: DOUBLE LOW-9 QUOTATION MARK + \u201f: DOUBLE HIGH-REVERSED-9 QUOTATION MARK --> + <string name="more_keys_for_less_than">\u2264,\u00ab,\u2039</string> + <string name="more_keys_for_greater_than">\u2265,\u00bb,\u203a</string> + <string name="output_text_for_left_square_bracket">[</string> + <string name="output_text_for_right_square_bracket">]</string> + <string name="output_text_for_left_curly_bracket">{</string> + <string name="output_text_for_right_curly_bracket">}</string> + <!-- The 4-more keys will be displayed in order of "3,1,2,4". --> + <string name="more_keys_for_single_quote">\u2019,\u201a,\u2018,\u201b</string> + <!-- Note: Neither DroidSans nor Roboto have a glyph for DOUBLE HIGH-REVERSED-9 QUOTATION MARK. --> + <!-- <string name="more_keys_for_double_quote">\u201c,\u201d,\u201e,\u201f,\u00ab,\u00bb</string> --> + <!-- The 4-more keys will be displayed in order of "3,1,2,4". --> + <string name="more_keys_for_double_quote">\u201d,\u00ab,\u201c,\u00bb</string> + <!-- Note: Neither DroidSans nor Roboto have a glyph for DOUBLE HIGH-REVERSED-9 QUOTATION MARK. --> + <!-- <string name="more_keys_for_tablet_double_quote">\u201c,\u201d,\u201e,\u201f,\u00ab,\u00bb,\u2018,\u2019,\u201a,\u201b</string> --> + <!-- The 8-more keys with maxMoreKeysColumn=4 will be displayed in order of "3,1,2,4|7,5,6,8". --> + <string name="more_keys_for_tablet_double_quote">\u201d,\u00ab,\u201c,\u00bb,\u2019,\u201a,\u2018,\u201b</string> </resources> diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index 8bd25c00d..cd5e3d8ea 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -19,7 +19,7 @@ --> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <!-- Symbols that are suggested between words --> - <string name="suggested_punctuations">!?,:;\u0022()\u0027-/@_</string> + <string name="suggested_punctuations">!,?,\\,,:,;,\u0022,(,),\u0027,-,/,@,_</string> <!-- Symbols that should be swapped with a magic space --> <string name="magic_space_swapping_symbols">.,;:!?)]}\u0022</string> <!-- Symbols that should strip a magic space --> diff --git a/java/res/values/keycodes.xml b/java/res/values/keycodes.xml index b3f71d2bb..2a91a3d6d 100644 --- a/java/res/values/keycodes.xml +++ b/java/res/values/keycodes.xml @@ -25,7 +25,6 @@ <integer name="key_space">32</integer> <integer name="key_shift">-1</integer> <integer name="key_switch_alpha_symbol">-2</integer> - <integer name="key_capslock">-3</integer> <integer name="key_output_text">-4</integer> <integer name="key_delete">-5</integer> <integer name="key_settings">-6</integer> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index f7d8b4533..a67ddf7c2 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -181,47 +181,6 @@ <!-- Spoken description for the "Return" keyboard key. --> <string name="spoken_description_return">Return</string> - <!-- Spoken description for the "," keyboard key. --> - <string name="spoken_description_comma">Comma</string> - <!-- Spoken description for the "." keyboard key. --> - <string name="spoken_description_period">Period</string> - <!-- Spoken description for the "(" keyboard key. --> - <string name="spoken_description_left_parenthesis">Left parenthesis</string> - <!-- Spoken description for the ")" keyboard key. --> - <string name="spoken_description_right_parenthesis">Right parenthesis</string> - <!-- Spoken description for the ":" keyboard key. --> - <string name="spoken_description_colon">Colon</string> - <!-- Spoken description for the ";" keyboard key. --> - <string name="spoken_description_semicolon">Semicolon</string> - <!-- Spoken description for the "!" keyboard key. --> - <string name="spoken_description_exclamation_mark">Exclamation mark</string> - <!-- Spoken description for the "?" keyboard key. --> - <string name="spoken_description_question_mark">Question mark</string> - <!-- Spoken description for the """ keyboard key. --> - <string name="spoken_description_double_quote">Double quote</string> - <!-- Spoken description for the "'" keyboard key. --> - <string name="spoken_description_single_quote">Single quote</string> - <!-- Spoken description for the "\u2022" (BULLET) keyboard key. --> - <string name="spoken_description_dot">Dot</string> - <!-- Spoken description for the "\u221a" (SQUARE ROOT) keyboard key. --> - <string name="spoken_description_square_root">Square root</string> - <!-- Spoken description for the "\u03C0" (GREEK SMALL LETTER PI) keyboard key. --> - <string name="spoken_description_pi">Pi</string> - <!-- Spoken description for the "\u0394" (GREEK CAPITAL LETTER DELTA) keyboard key. --> - <string name="spoken_description_delta">Delta</string> - <!-- Spoken description for the "\u2122" (TRADE MARK SIGN) keyboard key. --> - <string name="spoken_description_trademark">Trademark</string> - <!-- Spoken description for the "\u2105" (CARE OF) keyboard key. --> - <string name="spoken_description_care_of">Care of</string> - <!-- Spoken description for the "*" keyboard key. --> - <string name="spoken_description_star">Star</string> - <!-- Spoken description for the "#" keyboard key. --> - <string name="spoken_description_pound">Pound</string> - <!-- Spoken description for the "\u2026" (HORIZONTAL ELLIPSIS) keyboard key. --> - <string name="spoken_description_ellipsis">Ellipsis</string> - <!-- Spoken description for the "\u201E" (DOUBLE LOW-9 QUOTATION MARK) keyboard key. --> - <string name="spoken_description_low_double_quote">Low double quote</string> - <!-- Voice related labels --> <!-- Title of the warning dialog that shows when a user initiates voice input for diff --git a/java/res/xml-ar/keyboard_set.xml b/java/res/xml-ar/keyboard_set.xml index a8aac169b..7b70f633c 100644 --- a/java/res/xml-ar/keyboard_set.xml +++ b/java/res/xml-ar/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-be/keyboard_set.xml b/java/res/xml-be/keyboard_set.xml index c8ee9c162..042264aae 100644 --- a/java/res/xml-be/keyboard_set.xml +++ b/java/res/xml-be/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-bg/keyboard_set.xml b/java/res/xml-bg/keyboard_set.xml index 5a759648d..49914d54b 100644 --- a/java/res/xml-bg/keyboard_set.xml +++ b/java/res/xml-bg/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-cs/keyboard_set.xml b/java/res/xml-cs/keyboard_set.xml index 6b476df82..b4535164b 100644 --- a/java/res/xml-cs/keyboard_set.xml +++ b/java/res/xml-cs/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-da/keyboard_set.xml b/java/res/xml-da/keyboard_set.xml index cf930dd05..cf01ae6f5 100644 --- a/java/res/xml-da/keyboard_set.xml +++ b/java/res/xml-da/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-de-rZZ/keyboard_set.xml b/java/res/xml-de-rZZ/keyboard_set.xml index 585dc3d6a..635884d1d 100644 --- a/java/res/xml-de-rZZ/keyboard_set.xml +++ b/java/res/xml-de-rZZ/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-de/keyboard_set.xml b/java/res/xml-de/keyboard_set.xml index 059174ccd..485e63f06 100644 --- a/java/res/xml-de/keyboard_set.xml +++ b/java/res/xml-de/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-es/keyboard_set.xml b/java/res/xml-es/keyboard_set.xml index ec40a5a9b..2944a83ad 100644 --- a/java/res/xml-es/keyboard_set.xml +++ b/java/res/xml-es/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-et/keyboard_set.xml b/java/res/xml-et/keyboard_set.xml index 80a9d8fab..1c23db3d8 100644 --- a/java/res/xml-et/keyboard_set.xml +++ b/java/res/xml-et/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-fi/keyboard_set.xml b/java/res/xml-fi/keyboard_set.xml index cf95b5ec9..e8e4e7d9a 100644 --- a/java/res/xml-fi/keyboard_set.xml +++ b/java/res/xml-fi/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-fr-rCA/keyboard_set.xml b/java/res/xml-fr-rCA/keyboard_set.xml index 856363ea7..ea6ac8f26 100644 --- a/java/res/xml-fr-rCA/keyboard_set.xml +++ b/java/res/xml-fr-rCA/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-fr-rCH/keyboard_set.xml b/java/res/xml-fr-rCH/keyboard_set.xml index 778754c6f..751900b88 100644 --- a/java/res/xml-fr-rCH/keyboard_set.xml +++ b/java/res/xml-fr-rCH/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-fr/keyboard_set.xml b/java/res/xml-fr/keyboard_set.xml index ae911afa0..42a20e5ea 100644 --- a/java/res/xml-fr/keyboard_set.xml +++ b/java/res/xml-fr/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-hr/keyboard_set.xml b/java/res/xml-hr/keyboard_set.xml index 4bd81d0e8..e17aefdf6 100644 --- a/java/res/xml-hr/keyboard_set.xml +++ b/java/res/xml-hr/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-hu/keyboard_set.xml b/java/res/xml-hu/keyboard_set.xml index 9ed1d949a..0f6e5759e 100644 --- a/java/res/xml-hu/keyboard_set.xml +++ b/java/res/xml-hu/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-iw/keyboard_set.xml b/java/res/xml-iw/keyboard_set.xml index c16a6d79d..501ba96ee 100644 --- a/java/res/xml-iw/keyboard_set.xml +++ b/java/res/xml-iw/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-ky/keyboard_set.xml b/java/res/xml-ky/keyboard_set.xml index 1bb8926df..abd5f1631 100644 --- a/java/res/xml-ky/keyboard_set.xml +++ b/java/res/xml-ky/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-land/kbd_phone_shift.xml b/java/res/xml-land/kbd_phone_symbols.xml index f456a1775..41ba6cf3b 100644 --- a/java/res/xml-land/kbd_phone_shift.xml +++ b/java/res/xml-land/kbd_phone_symbols.xml @@ -24,5 +24,5 @@ latin:keyWidth="26.67%p" > <include - latin:keyboardLayout="@xml/rows_phone_shift" /> + latin:keyboardLayout="@xml/rows_phone_symbols" /> </Keyboard> diff --git a/java/res/xml-nb/keyboard_set.xml b/java/res/xml-nb/keyboard_set.xml index 1a36de435..d146beb71 100644 --- a/java/res/xml-nb/keyboard_set.xml +++ b/java/res/xml-nb/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-pl/keyboard_set.xml b/java/res/xml-pl/keyboard_set.xml index 39ee77771..6d2737929 100644 --- a/java/res/xml-pl/keyboard_set.xml +++ b/java/res/xml-pl/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-pt/keyboard_set.xml b/java/res/xml-pt/keyboard_set.xml index bd19761d3..65f9634ce 100644 --- a/java/res/xml-pt/keyboard_set.xml +++ b/java/res/xml-pt/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-ro/keyboard_set.xml b/java/res/xml-ro/keyboard_set.xml index 75ca68272..6c34966d0 100644 --- a/java/res/xml-ro/keyboard_set.xml +++ b/java/res/xml-ro/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-ru/keyboard_set.xml b/java/res/xml-ru/keyboard_set.xml index 8d4d277b2..b6a356891 100644 --- a/java/res/xml-ru/keyboard_set.xml +++ b/java/res/xml-ru/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-sk/keyboard_set.xml b/java/res/xml-sk/keyboard_set.xml index b73c446ef..b283d968a 100644 --- a/java/res/xml-sk/keyboard_set.xml +++ b/java/res/xml-sk/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-sl/keyboard_set.xml b/java/res/xml-sl/keyboard_set.xml index b2378e2c2..dbb2782f0 100644 --- a/java/res/xml-sl/keyboard_set.xml +++ b/java/res/xml-sl/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-sr/keyboard_set.xml b/java/res/xml-sr/keyboard_set.xml index 729136f3a..15471dbcd 100644 --- a/java/res/xml-sr/keyboard_set.xml +++ b/java/res/xml-sr/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-sv/keyboard_set.xml b/java/res/xml-sv/keyboard_set.xml index 3d366a443..e5184d33f 100644 --- a/java/res/xml-sv/keyboard_set.xml +++ b/java/res/xml-sv/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-sw600dp-land/kbd_phone_shift.xml b/java/res/xml-sw600dp-land/kbd_phone_symbols.xml index ba837922f..e3f56bce7 100644 --- a/java/res/xml-sw600dp-land/kbd_phone_shift.xml +++ b/java/res/xml-sw600dp-land/kbd_phone_symbols.xml @@ -23,6 +23,7 @@ latin:keyboardHorizontalEdgesPadding="10%p" latin:keyWidth="15.00%p" > + <!-- Tablet doesn't have phone symbols keyboard --> <include - latin:keyboardLayout="@xml/rows_phone_shift" /> + latin:keyboardLayout="@xml/rows_phone" /> </Keyboard> diff --git a/java/res/xml-sw600dp/kbd_phone_shift.xml b/java/res/xml-sw600dp/kbd_phone_symbols.xml index e72254576..9faeaf4e0 100644 --- a/java/res/xml-sw600dp/kbd_phone_shift.xml +++ b/java/res/xml-sw600dp/kbd_phone_symbols.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="15.00%p" > + <!-- Tablet doesn't have phone symbols keyboard --> <include - latin:keyboardLayout="@xml/rows_phone_shift" /> + latin:keyboardLayout="@xml/rows_phone" /> </Keyboard> diff --git a/java/res/xml-sw600dp/rows_azerty.xml b/java/res/xml-sw600dp/rows_azerty.xml index c29d291ea..aabe6b0e8 100644 --- a/java/res/xml-sw600dp/rows_azerty.xml +++ b/java/res/xml-sw600dp/rows_azerty.xml @@ -116,7 +116,10 @@ latin:keyLabel="n" latin:moreKeys="@string/more_keys_for_n" /> <Key - latin:keyLabel="\'" /> + latin:keyLabel="\'" + latin:keyHintLabel=":" + latin:moreKeys=":" + latin:keyStyle="hasShiftedLetterHintStyle" /> <include latin:keyboardLayout="@xml/keys_comma_period" /> <include diff --git a/java/res/xml-sw600dp/rows_phone.xml b/java/res/xml-sw600dp/rows_phone.xml index 1bad7ca72..fe8511988 100644 --- a/java/res/xml-sw600dp/rows_phone.xml +++ b/java/res/xml-sw600dp/rows_phone.xml @@ -28,7 +28,7 @@ <Row> <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> <Spacer - latin:keyWidth="17.375%p" /> + latin:keyWidth="12.75%p" /> <Key latin:keyLabel="-" latin:keyStyle="numKeyStyle" @@ -38,6 +38,9 @@ latin:keyStyle="numKeyStyle" latin:keyWidth="9.25%p" /> <Key + latin:keyStyle="numPauseKeyStyle" + latin:keyWidth="9.25%p" /> + <Key latin:keyStyle="num1KeyStyle" latin:keyXPos="42.25%p" /> <Key @@ -52,7 +55,7 @@ <Row> <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> <Spacer - latin:keyWidth="17.375%p" /> + latin:keyWidth="12.75%p" /> <Key latin:keyLabel="," latin:keyStyle="numKeyStyle" @@ -62,6 +65,9 @@ latin:keyStyle="numKeyStyle" latin:keyWidth="9.25%p" /> <Key + latin:keyStyle="numWaitKeyStyle" + latin:keyWidth="9.25%p" /> + <Key latin:keyStyle="num4KeyStyle" latin:keyXPos="42.25%p" /> <Key @@ -74,19 +80,23 @@ latin:keyWidth="fillRight" /> </Row> <Row> - <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="11.0%p" /> + <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> + <Spacer + latin:keyWidth="12.75%p" /> <Key latin:keyLabel="(" latin:keyStyle="numKeyStyle" - latin:keyXPos="17.375%p" - latin:keyWidth="9.25%p" /> + latin:keyWidth="9.25%p" + latin:keyXPos="12.75%p" /> <Key latin:keyLabel=")" latin:keyStyle="numKeyStyle" latin:keyWidth="9.25%p" /> <Key + latin:keyLabel="N" + latin:keyStyle="numKeyStyle" + latin:keyWidth="9.25%p" /> + <Key latin:keyStyle="num7KeyStyle" latin:keyXPos="42.25%p" /> <Key @@ -96,15 +106,15 @@ <!-- Note: This Spacer prevents the above key from being marked as a right edge key. --> <Spacer latin:keyWidth="0%p" /> - </Row> + </Row> <Row> <Key latin:keyStyle="numTabKeyStyle" latin:keyWidth="11.00%p" /> <Key latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle" - latin:keyWidth="18.50%p" - latin:keyXPos="17.375%p" /> + latin:keyWidth="27.75%p" + latin:keyXPos="12.75%p" /> <Key latin:keyStyle="numStarKeyStyle" latin:keyXPos="42.25%p" /> diff --git a/java/res/xml-sw600dp/rows_phone_shift.xml b/java/res/xml-sw600dp/rows_phone_shift.xml deleted file mode 100644 index c2f00fe8b..000000000 --- a/java/res/xml-sw600dp/rows_phone_shift.xml +++ /dev/null @@ -1,132 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 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. -*/ ---> - -<merge - xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_number" /> - <Row> - <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> - <Spacer - latin:keyWidth="12.75%p" /> - <Key - latin:keyLabel="-" - latin:keyStyle="numKeyStyle" - latin:keyWidth="9.25%p" /> - <Key - latin:keyLabel="+" - latin:keyStyle="numKeyStyle" - latin:keyWidth="9.25%p" /> - <Key - latin:keyStyle="numPauseKeyStyle" - latin:keyWidth="9.25%p" /> - <Key - latin:keyStyle="num1KeyStyle" - latin:keyXPos="42.25%p" /> - <Key - latin:keyStyle="num2KeyStyle" /> - <Key - latin:keyStyle="num3KeyStyle" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyXPos="-11.00%p" - latin:keyWidth="fillRight" /> - </Row> - <Row> - <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> - <Spacer - latin:keyWidth="12.75%p" /> - <Key - latin:keyLabel="," - latin:keyStyle="numKeyStyle" - latin:keyWidth="9.25%p" /> - <Key - latin:keyLabel="." - latin:keyStyle="numKeyStyle" - latin:keyWidth="9.25%p" /> - <Key - latin:keyStyle="numWaitKeyStyle" - latin:keyWidth="9.25%p" /> - <Key - latin:keyStyle="num4KeyStyle" - latin:keyXPos="42.25%p" /> - <Key - latin:keyStyle="num5KeyStyle" /> - <Key - latin:keyStyle="num6KeyStyle" /> - <Key - latin:keyStyle="returnKeyStyle" - latin:keyXPos="-11.00%p" - latin:keyWidth="fillRight" /> - </Row> - <Row> - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="11.00%p" /> - <Key - latin:keyLabel="(" - latin:keyStyle="numKeyStyle" - latin:keyWidth="9.25%p" - latin:keyXPos="12.75%p" /> - <Key - latin:keyLabel=")" - latin:keyStyle="numKeyStyle" - latin:keyWidth="9.25%p" /> - <Key - latin:keyLabel="N" - latin:keyStyle="numKeyStyle" - latin:keyWidth="9.25%p" /> - <Key - latin:keyStyle="num7KeyStyle" - latin:keyXPos="42.25%p" /> - <Key - latin:keyStyle="num8KeyStyle" /> - <Key - latin:keyStyle="num9KeyStyle" /> - <!-- Note: This Spacer prevents the above key from being marked as a right edge key. --> - <Spacer - latin:keyWidth="0%p" /> - </Row> - <Row> - <Key - latin:keyStyle="numTabKeyStyle" - latin:keyWidth="11.00%p" /> - <Key - latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle" - latin:keyWidth="27.75%p" - latin:keyXPos="12.75%p" /> - <Key - latin:keyStyle="numStarKeyStyle" - latin:keyXPos="42.25%p" /> - <Key - latin:keyStyle="num0KeyStyle" /> - <Key - latin:keyLabel="#" - latin:keyStyle="numKeyStyle" /> - <Spacer - latin:keyXPos="-11.00%p" - latin:keyWidth="0%p" /> - <include - latin:keyboardLayout="@xml/key_f2" /> - </Row> -</merge> diff --git a/java/res/xml-sw600dp/rows_symbols.xml b/java/res/xml-sw600dp/rows_symbols.xml index 701c35470..c2dfe2f82 100644 --- a/java/res/xml-sw600dp/rows_symbols.xml +++ b/java/res/xml-sw600dp/rows_symbols.xml @@ -95,12 +95,8 @@ <Key latin:keyLabel="+" latin:moreKeys="@string/more_keys_for_plus" /> - <Key - latin:keyLabel="(" - latin:moreKeys="[,{,<" /> - <Key - latin:keyLabel=")" - latin:moreKeys="],},>" /> + <include + latin:keyboardLayout="@xml/keys_parentheses" /> <Key latin:keyStyle="returnKeyStyle" latin:keyXPos="-14.6%p" @@ -112,12 +108,8 @@ <Key latin:keyStyle="toMoreSymbolKeyStyle" latin:keyWidth="10.0%p" /> - <Key - latin:keyLabel="<" - latin:moreKeys="≤,«,‹" /> - <Key - latin:keyLabel=">" - latin:moreKeys="≥,»,›" /> + <include + latin:keyboardLayout="@xml/keys_less_greater" /> <Key latin:keyLabel="=" latin:moreKeys="≠,≈" /> @@ -126,8 +118,7 @@ latin:mode="url" > <Key - latin:keyLabel="\'" - latin:moreKeys="‘,’,‚,‛" /> + latin:keyLabel="\'" /> </case> <default> <Key @@ -166,11 +157,10 @@ latin:keyStyle="spaceKeyStyle" latin:keyXPos="30.750%p" latin:keyWidth="39.750%p" /> - <!-- Note: DroidSans doesn't have double-high-reversed-quotation '\u201f' glyph. --> - <!-- latin:moreKeys="“,”,„,‟,«,»,‘,’,‚,‛" --> <Key latin:keyLabel=""" - latin:moreKeys="“,”,«,»,‘,’,‚,‛" /> + latin:moreKeys="@string/more_keys_for_tablet_double_quote" + latin:maxMoreKeysColumn="4" /> <Key latin:keyLabel="_" /> <Spacer diff --git a/java/res/xml-sw600dp/rows_symbols_shift.xml b/java/res/xml-sw600dp/rows_symbols_shift.xml index d3531dd39..6a640c06b 100644 --- a/java/res/xml-sw600dp/rows_symbols_shift.xml +++ b/java/res/xml-sw600dp/rows_symbols_shift.xml @@ -77,10 +77,8 @@ <Key latin:keyLabel="±" latin:moreKeys="∞" /> - <Key - latin:keyLabel="{" /> - <Key - latin:keyLabel="}" /> + <include + latin:keyboardLayout="@xml/keys_curly_brackets" /> <Key latin:keyStyle="returnKeyStyle" latin:keyXPos="-14.6%p" @@ -102,10 +100,8 @@ latin:keyLabel="™" /> <Key latin:keyLabel="℅" /> - <Key - latin:keyLabel="[" /> - <Key - latin:keyLabel="]" /> + <include + latin:keyboardLayout="@xml/keys_square_brackets" /> <Key latin:keyLabel="¡" /> <Key diff --git a/java/res/xml-sw768dp-land/kbd_phone_shift.xml b/java/res/xml-sw768dp-land/kbd_phone_symbols.xml index 4ef8e96a1..641464dbe 100644 --- a/java/res/xml-sw768dp-land/kbd_phone_shift.xml +++ b/java/res/xml-sw768dp-land/kbd_phone_symbols.xml @@ -23,6 +23,7 @@ latin:keyboardHorizontalEdgesPadding="10%p" latin:keyWidth="13.250%p" > + <!-- Tablet doesn't have phone symbols keyboard --> <include - latin:keyboardLayout="@xml/rows_phone_shift" /> + latin:keyboardLayout="@xml/rows_phone" /> </Keyboard> diff --git a/java/res/xml-sw768dp/kbd_phone_shift.xml b/java/res/xml-sw768dp/kbd_phone_symbols.xml index a56afcc0c..e1a359e84 100644 --- a/java/res/xml-sw768dp/kbd_phone_shift.xml +++ b/java/res/xml-sw768dp/kbd_phone_symbols.xml @@ -22,6 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" latin:keyWidth="13.250%p" > + <!-- Tablet doesn't have phone symbols keyboard --> <include - latin:keyboardLayout="@xml/rows_phone_shift" /> + latin:keyboardLayout="@xml/rows_phone" /> </Keyboard> diff --git a/java/res/xml-sw768dp/rows_azerty.xml b/java/res/xml-sw768dp/rows_azerty.xml index 886ebecaa..b9ef89822 100644 --- a/java/res/xml-sw768dp/rows_azerty.xml +++ b/java/res/xml-sw768dp/rows_azerty.xml @@ -124,9 +124,9 @@ latin:moreKeys="@string/more_keys_for_n" /> <Key latin:keyLabel="\'" - latin:keyLabelFlags="hasShiftedLetterHint" latin:keyHintLabel=":" - latin:moreKeys=":" /> + latin:moreKeys=":" + latin:keyStyle="hasShiftedLetterHintStyle" /> <include latin:keyboardLayout="@xml/keys_comma_period" /> <Key diff --git a/java/res/xml-sw768dp/rows_phone.xml b/java/res/xml-sw768dp/rows_phone.xml index da90895d0..789c02c42 100644 --- a/java/res/xml-sw768dp/rows_phone.xml +++ b/java/res/xml-sw768dp/rows_phone.xml @@ -33,13 +33,16 @@ <Key latin:keyLabel="-" latin:keyStyle="numKeyStyle" - latin:keyXPos="20.400%p" + latin:keyXPos="13.829%p" latin:keyWidth="8.047%p" /> <Key latin:keyLabel="+" latin:keyStyle="numKeyStyle" latin:keyWidth="8.047%p" /> <Key + latin:keyStyle="numPauseKeyStyle" + latin:keyWidth="8.047%p" /> + <Key latin:keyStyle="num1KeyStyle" latin:keyXPos="43.125%p" /> <Key @@ -52,19 +55,22 @@ latin:keyWidth="fillRight" /> </Row> <Row> - <Key - latin:keyStyle="toMoreSymbolKeyStyle" - latin:keyWidth="11.172%p" /> + <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> + <Spacer + latin:keyWidth="13.829%p" /> <Key latin:keyLabel="," latin:keyStyle="numKeyStyle" - latin:keyXPos="20.400%p" + latin:keyXPos="13.829%p" latin:keyWidth="8.047%p" /> <Key latin:keyLabel="." latin:keyStyle="numKeyStyle" latin:keyWidth="8.047%p" /> <Key + latin:keyStyle="numWaitKeyStyle" + latin:keyWidth="8.047%p" /> + <Key latin:keyStyle="num4KeyStyle" latin:keyXPos="43.125%p" /> <Key @@ -79,7 +85,7 @@ <Row> <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> <Spacer - latin:keyWidth="20.400%p" /> + latin:keyWidth="13.829%p" /> <Key latin:keyLabel="(" latin:keyStyle="numKeyStyle" @@ -89,6 +95,10 @@ latin:keyStyle="numKeyStyle" latin:keyWidth="8.047%p" /> <Key + latin:keyLabel="N" + latin:keyStyle="numKeyStyle" + latin:keyWidth="8.047%p" /> + <Key latin:keyStyle="num7KeyStyle" latin:keyXPos="43.125%p" /> <Key @@ -98,7 +108,7 @@ <!-- Note: This Spacer prevents the above key from being marked as a right edge key. --> <Spacer latin:keyWidth="0%p" /> - </Row> + </Row> <Row> <switch> <case latin:hasSettingsKey="true"> @@ -114,8 +124,8 @@ </switch> <Key latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle" - latin:keyXPos="20.400%p" - latin:keyWidth="16.084%p" /> + latin:keyXPos="13.829%p" + latin:keyWidth="24.140%p" /> <Key latin:keyStyle="numStarKeyStyle" latin:keyXPos="43.125%p" /> diff --git a/java/res/xml-sw768dp/rows_phone_shift.xml b/java/res/xml-sw768dp/rows_phone_shift.xml deleted file mode 100644 index 5861998ae..000000000 --- a/java/res/xml-sw768dp/rows_phone_shift.xml +++ /dev/null @@ -1,153 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -/* -** -** Copyright 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. -*/ ---> - -<merge - xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" -> - <include - latin:keyboardLayout="@xml/key_styles_common" /> - <include - latin:keyboardLayout="@xml/key_styles_number" /> - <Row> - <Key - latin:keyStyle="numTabKeyStyle" - latin:keyLabelFlags="alignLeft" - latin:keyWidth="11.172%p" /> - <Key - latin:keyLabel="-" - latin:keyStyle="numKeyStyle" - latin:keyXPos="13.829%p" - latin:keyWidth="8.047%p" /> - <Key - latin:keyLabel="+" - latin:keyStyle="numKeyStyle" - latin:keyWidth="8.047%p" /> - <Key - latin:keyStyle="numPauseKeyStyle" - latin:keyWidth="8.047%p" /> - <Key - latin:keyStyle="num1KeyStyle" - latin:keyXPos="43.125%p" /> - <Key - latin:keyStyle="num2KeyStyle" /> - <Key - latin:keyStyle="num3KeyStyle" /> - <Key - latin:keyStyle="deleteKeyStyle" - latin:keyXPos="-11.172%p" - latin:keyWidth="fillRight" /> - </Row> - <Row> - <Key - latin:keyStyle="backFromMoreSymbolKeyStyle" - latin:keyWidth="11.172%p" /> - <Key - latin:keyLabel="," - latin:keyStyle="numKeyStyle" - latin:keyXPos="13.829%p" - latin:keyWidth="8.047%p" /> - <Key - latin:keyLabel="." - latin:keyStyle="numKeyStyle" - latin:keyWidth="8.047%p" /> - <Key - latin:keyStyle="numWaitKeyStyle" - latin:keyWidth="8.047%p" /> - <Key - latin:keyStyle="num4KeyStyle" - latin:keyXPos="43.125%p" /> - <Key - latin:keyStyle="num5KeyStyle" /> - <Key - latin:keyStyle="num6KeyStyle" /> - <Key - latin:keyStyle="returnKeyStyle" - latin:keyXPos="-11.172%p" - latin:keyWidth="fillRight" /> - </Row> - <Row> - <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> - <Spacer - latin:keyWidth="13.829%p" /> - <Key - latin:keyLabel="(" - latin:keyStyle="numKeyStyle" - latin:keyWidth="8.047%p" /> - <Key - latin:keyLabel=")" - latin:keyStyle="numKeyStyle" - latin:keyWidth="8.047%p" /> - <Key - latin:keyLabel="N" - latin:keyStyle="numKeyStyle" - latin:keyWidth="8.047%p" /> - <Key - latin:keyStyle="num7KeyStyle" - latin:keyXPos="43.125%p" /> - <Key - latin:keyStyle="num8KeyStyle" /> - <Key - latin:keyStyle="num9KeyStyle" /> - <!-- Note: This Spacer prevents the above key from being marked as a right edge key. --> - <Spacer - latin:keyWidth="0%p" /> - </Row> - <Row> - <switch> - <case latin:hasSettingsKey="true"> - <Key - latin:keyStyle="settingsKeyStyle" - latin:keyWidth="8.047%p" /> - </case> - <default> - <!-- Note: This Spacer prevents the below key from being marked as a left edge key. --> - <Spacer - latin:keyWidth="8.047%p" /> - </default> - </switch> - <Key - latin:keyStyle="nonSpecialBackgroundSpaceKeyStyle" - latin:keyXPos="13.829%p" - latin:keyWidth="24.140%p" /> - <Key - latin:keyStyle="numStarKeyStyle" - latin:keyXPos="43.125%p" /> - <Key - latin:keyStyle="num0KeyStyle" /> - <Key - latin:keyLabel="#" - latin:keyStyle="numKeyStyle" /> - <switch> - <case - latin:shortcutKeyEnabled="true" - > - <Key - latin:keyStyle="shortcutKeyStyle" - latin:keyXPos="-8.047%p" - latin:keyWidth="fillRight" /> - </case> - <default> - <!-- Note: This Spacer prevents the above key from being marked as a right edge key. --> - <Spacer - latin:keyWidth="0%p" /> - </default> - </switch> - </Row> -</merge> diff --git a/java/res/xml-sw768dp/rows_symbols.xml b/java/res/xml-sw768dp/rows_symbols.xml index 7458b366a..2ba935724 100644 --- a/java/res/xml-sw768dp/rows_symbols.xml +++ b/java/res/xml-sw768dp/rows_symbols.xml @@ -102,12 +102,8 @@ <Key latin:keyLabel="+" latin:moreKeys="@string/more_keys_for_plus" /> - <Key - latin:keyLabel="(" - latin:moreKeys="[,{,<" /> - <Key - latin:keyLabel=")" - latin:moreKeys="],},>" /> + <include + latin:keyboardLayout="@xml/keys_parentheses" /> <Key latin:keyStyle="returnKeyStyle" latin:keyXPos="-15.704%p" @@ -119,12 +115,8 @@ <Key latin:keyStyle="toMoreSymbolKeyStyle" latin:keyWidth="13.829%p" /> - <Key - latin:keyLabel="<" - latin:moreKeys="≤,«,‹" /> - <Key - latin:keyLabel=">" - latin:moreKeys="≥,»,›" /> + <include + latin:keyboardLayout="@xml/keys_less_greater" /> <Key latin:keyLabel="=" latin:moreKeys="≠,≈" /> @@ -133,8 +125,7 @@ latin:mode="url" > <Key - latin:keyLabel="\'" - latin:moreKeys="‘,’,‚,‛" /> + latin:keyLabel="\'" /> </case> <default> <Key @@ -181,11 +172,10 @@ latin:keyStyle="spaceKeyStyle" latin:keyXPos="31.250%p" latin:keyWidth="37.500%p" /> - <!-- Note: DroidSans doesn't have double-high-reversed-quotation '\u201f' glyph. --> - <!-- latin:moreKeys="“,”,„,‟,«,»,‘,’,‚,‛" --> <Key latin:keyLabel=""" - latin:moreKeys="“,”,«,»,‘,’,‚,‛" /> + latin:moreKeys="@string/more_keys_for_tablet_double_quote" + latin:maxMoreKeysColumn="4" /> <Key latin:keyLabel="_" /> <switch> diff --git a/java/res/xml-sw768dp/rows_symbols_shift.xml b/java/res/xml-sw768dp/rows_symbols_shift.xml index 80735b697..aba9c236d 100644 --- a/java/res/xml-sw768dp/rows_symbols_shift.xml +++ b/java/res/xml-sw768dp/rows_symbols_shift.xml @@ -84,10 +84,8 @@ <Key latin:keyLabel="±" latin:moreKeys="∞" /> - <Key - latin:keyLabel="{" /> - <Key - latin:keyLabel="}" /> + <include + latin:keyboardLayout="@xml/keys_curly_brackets" /> <Key latin:keyStyle="returnKeyStyle" latin:keyXPos="-15.704%p" @@ -109,10 +107,8 @@ latin:keyLabel="™" /> <Key latin:keyLabel="℅" /> - <Key - latin:keyLabel="[" /> - <Key - latin:keyLabel="]" /> + <include + latin:keyboardLayout="@xml/keys_square_brackets" /> <Key latin:keyLabel="¡" /> <Key diff --git a/java/res/xml-tr/keyboard_set.xml b/java/res/xml-tr/keyboard_set.xml index 3c429585f..da79758ec 100644 --- a/java/res/xml-tr/keyboard_set.xml +++ b/java/res/xml-tr/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-uk/keyboard_set.xml b/java/res/xml-uk/keyboard_set.xml index 300eea226..8eb9eccb7 100644 --- a/java/res/xml-uk/keyboard_set.xml +++ b/java/res/xml-uk/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-vi/keyboard_set.xml b/java/res/xml-vi/keyboard_set.xml index 0b92c94c1..6d38eb1b4 100644 --- a/java/res/xml-vi/keyboard_set.xml +++ b/java/res/xml-vi/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml/kbd_arabic.xml b/java/res/xml/kbd_arabic.xml index d7f77cc3a..ce5f30b2f 100644 --- a/java/res/xml/kbd_arabic.xml +++ b/java/res/xml/kbd_arabic.xml @@ -20,7 +20,6 @@ <Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:isRtlKeyboard="true" > <include latin:keyboardLayout="@xml/rows_arabic" /> diff --git a/java/res/xml/kbd_hebrew.xml b/java/res/xml/kbd_hebrew.xml index 3d574db59..74836f342 100644 --- a/java/res/xml/kbd_hebrew.xml +++ b/java/res/xml/kbd_hebrew.xml @@ -20,7 +20,6 @@ <Keyboard xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:isRtlKeyboard="true" > <include latin:keyboardLayout="@xml/rows_hebrew" /> diff --git a/java/res/xml/kbd_phone_shift.xml b/java/res/xml/kbd_phone_symbols.xml index 104f33f5b..7f59a855a 100644 --- a/java/res/xml/kbd_phone_shift.xml +++ b/java/res/xml/kbd_phone_symbols.xml @@ -23,5 +23,5 @@ latin:keyWidth="26.67%p" > <include - latin:keyboardLayout="@xml/rows_phone_shift" /> + latin:keyboardLayout="@xml/rows_phone_symbols" /> </Keyboard> diff --git a/java/res/xml/key_styles_common.xml b/java/res/xml/key_styles_common.xml index 8d01e0fb5..14ee19ee9 100644 --- a/java/res/xml/key_styles_common.xml +++ b/java/res/xml/key_styles_common.xml @@ -180,7 +180,7 @@ <key-style latin:styleName="spaceKeyStyle" latin:code="@integer/key_space" - latin:keyActionFlags="noKeyPreview" + latin:keyActionFlags="noKeyPreview|enableLongPress" latin:backgroundType="functional" /> <key-style latin:styleName="shortcutKeyStyle" diff --git a/java/res/xml/key_styles_number.xml b/java/res/xml/key_styles_number.xml index 003165da8..7307a1a2b 100644 --- a/java/res/xml/key_styles_number.xml +++ b/java/res/xml/key_styles_number.xml @@ -45,6 +45,7 @@ latin:styleName="num0KeyStyle" latin:code="48" latin:keyLabel="0 +" + latin:keyActionFlags="enableLongPress" latin:parentStyle="numberKeyStyle" /> <key-style latin:styleName="num1KeyStyle" @@ -95,14 +96,15 @@ latin:code="42" latin:keyLabel="\uff0a" latin:parentStyle="numKeyStyle" /> + <!-- Only for non-tablet device --> <key-style - latin:styleName="numSwitchToAltKeyStyle" - latin:code="@integer/key_shift" + latin:styleName="numPhoneToSymbolKeyStyle" + latin:code="@integer/key_switch_alpha_symbol" latin:keyLabel="@string/label_to_phone_symbols_key" latin:parentStyle="numModeKeyStyle" /> <key-style - latin:styleName="numSwitchToNumericKeyStyle" - latin:code="@integer/key_shift" + latin:styleName="numPhoneToNumericKeyStyle" + latin:code="@integer/key_switch_alpha_symbol" latin:keyLabel="@string/label_to_phone_numeric_key" latin:parentStyle="numModeKeyStyle" /> <key-style @@ -125,5 +127,6 @@ latin:styleName="numSpaceKeyStyle" latin:code="@integer/key_space" latin:keyIcon="iconSpaceKeyForNumberLayout" + latin:keyActionFlags="enableLongPress" latin:parentStyle="numKeyBaseStyle" /> </merge> diff --git a/java/res/xml/keyboard_set.xml b/java/res/xml/keyboard_set.xml index ebdd9902e..1398b137c 100644 --- a/java/res/xml/keyboard_set.xml +++ b/java/res/xml/keyboard_set.xml @@ -34,8 +34,8 @@ latin:elementName="phone" latin:elementKeyboard="@xml/kbd_phone" /> <Element - latin:elementName="phoneShifted" - latin:elementKeyboard="@xml/kbd_phone_shift" /> + latin:elementName="phoneSymbols" + latin:elementKeyboard="@xml/kbd_phone_symbols" /> <Element latin:elementName="number" latin:elementKeyboard="@xml/kbd_number" /> diff --git a/java/res/xml-ar/kbd_symbols_shift.xml b/java/res/xml/keys_curly_brackets.xml index 820b425ea..b43fbb1fe 100644 --- a/java/res/xml-ar/kbd_symbols_shift.xml +++ b/java/res/xml/keys_curly_brackets.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2011, The Android Open Source Project +** 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. @@ -18,10 +18,13 @@ */ --> -<Keyboard +<merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:isRtlKeyboard="true" > - <include - latin:keyboardLayout="@xml/rows_symbols_shift" /> -</Keyboard> + <Key + latin:keyLabel="{" + latin:keyOutputText="@string/output_text_for_left_curly_bracket" /> + <Key + latin:keyLabel="}" + latin:keyOutputText="@string/output_text_for_right_curly_bracket" /> +</merge> diff --git a/java/res/xml-iw/kbd_symbols_shift.xml b/java/res/xml/keys_less_greater.xml index 820b425ea..8e90199fe 100644 --- a/java/res/xml-iw/kbd_symbols_shift.xml +++ b/java/res/xml/keys_less_greater.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2011, The Android Open Source Project +** 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. @@ -18,10 +18,15 @@ */ --> -<Keyboard +<merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:isRtlKeyboard="true" > - <include - latin:keyboardLayout="@xml/rows_symbols_shift" /> -</Keyboard> + <Key + latin:keyLabel="<" + latin:keyOutputText="@string/output_text_for_less_than" + latin:moreKeys="@string/more_keys_for_less_than" /> + <Key + latin:keyLabel=">" + latin:keyOutputText="@string/output_text_for_greater_than" + latin:moreKeys="@string/more_keys_for_greater_than" /> +</merge> diff --git a/java/res/xml/keys_parentheses.xml b/java/res/xml/keys_parentheses.xml new file mode 100644 index 000000000..bacb26d2f --- /dev/null +++ b/java/res/xml/keys_parentheses.xml @@ -0,0 +1,32 @@ +<?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" +> + <Key + latin:keyLabel="(" + latin:keyOutputText="@string/output_text_for_left_parenthesis" + latin:moreKeys="@string/more_keys_for_left_parenthesis" /> + <Key + latin:keyLabel=")" + latin:keyOutputText="@string/output_text_for_right_parenthesis" + latin:moreKeys="@string/more_keys_for_right_parenthesis" /> +</merge> diff --git a/java/res/xml-iw/kbd_symbols.xml b/java/res/xml/keys_square_brackets.xml index c1905b875..3525f4d5a 100644 --- a/java/res/xml-iw/kbd_symbols.xml +++ b/java/res/xml/keys_square_brackets.xml @@ -2,7 +2,7 @@ <!-- /* ** -** Copyright 2011, The Android Open Source Project +** 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. @@ -18,10 +18,13 @@ */ --> -<Keyboard +<merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" - latin:isRtlKeyboard="true" > - <include - latin:keyboardLayout="@xml/rows_symbols" /> -</Keyboard> + <Key + latin:keyLabel="[" + latin:keyOutputText="@string/output_text_for_left_square_bracket" /> + <Key + latin:keyLabel="]" + latin:keyOutputText="@string/output_text_for_right_square_bracket" /> +</merge> diff --git a/java/res/xml/rows_azerty.xml b/java/res/xml/rows_azerty.xml index 142ebc0a6..533c683d6 100644 --- a/java/res/xml/rows_azerty.xml +++ b/java/res/xml/rows_azerty.xml @@ -130,9 +130,13 @@ <Key latin:keyLabel="n" latin:moreKeys="@string/more_keys_for_n" /> + <!-- TODO: Introduce a flag, such as strinctMoreKeysOrder, to control moreKeys display + order more precisely. --> + <!-- This key is close enough to right edge, so that the 4-more keys will be displayed in + order of "4,3,1,2". See @string/more_keys_for_single_quote --> <Key latin:keyLabel="\'" - latin:moreKeys="‘,’,‚,‛" /> + latin:moreKeys="\u2018,\u2019,\u201b,\u201a" /> <Key latin:keyStyle="deleteKeyStyle" latin:keyWidth="fillRight" diff --git a/java/res/xml/rows_phone.xml b/java/res/xml/rows_phone.xml index 94d0f7273..18e4c9d3e 100644 --- a/java/res/xml/rows_phone.xml +++ b/java/res/xml/rows_phone.xml @@ -62,7 +62,7 @@ </Row> <Row> <Key - latin:keyStyle="numSwitchToAltKeyStyle" /> + latin:keyStyle="numPhoneToSymbolKeyStyle" /> <Key latin:keyStyle="num0KeyStyle" /> <Key diff --git a/java/res/xml/rows_phone_shift.xml b/java/res/xml/rows_phone_symbols.xml index 100520629..dfa134946 100644 --- a/java/res/xml/rows_phone_shift.xml +++ b/java/res/xml/rows_phone_symbols.xml @@ -71,7 +71,7 @@ </Row> <Row> <Key - latin:keyStyle="numSwitchToNumericKeyStyle" /> + latin:keyStyle="numPhoneToNumericKeyStyle" /> <Key latin:keyLabel="+" latin:keyStyle="numKeyStyle" /> diff --git a/java/res/xml/rows_symbols.xml b/java/res/xml/rows_symbols.xml index d0d0edbc8..81a9a4602 100644 --- a/java/res/xml/rows_symbols.xml +++ b/java/res/xml/rows_symbols.xml @@ -93,13 +93,8 @@ <Key latin:keyLabel="+" latin:moreKeys="@string/more_keys_for_plus" /> - <Key - latin:keyLabel="(" - latin:moreKeys="@string/more_keys_for_left_parenthesis" /> - <Key - latin:keyLabel=")" - latin:moreKeys="@string/more_keys_for_right_parenthesis" - latin:keyWidth="fillRight" /> + <include + latin:keyboardLayout="@xml/keys_parentheses" /> </Row> <Row latin:keyWidth="10%p" @@ -111,15 +106,13 @@ <Key latin:keyLabel="!" latin:moreKeys="¡" /> - <!-- Note: Neither DroidSans nor Roboto have a glyph for ‟ Double high-reversed-9 quotation mark U+201F. --> - <!-- latin:moreKeys="“,”,„,‟,«,»" --> <Key latin:keyLabel=""" - latin:moreKeys="“,”,«,»" - latin:maxMoreKeysColumn="6" /> + latin:moreKeys="@string/more_keys_for_double_quote" + latin:maxMoreKeysColumn="4" /> <Key latin:keyLabel="\'" - latin:moreKeys="‘,’,‚,‛" /> + latin:moreKeys="@string/more_keys_for_single_quote" /> <Key latin:keyLabel=":" /> <Key diff --git a/java/res/xml/rows_symbols_shift.xml b/java/res/xml/rows_symbols_shift.xml index 6d1838c7b..828bd0624 100644 --- a/java/res/xml/rows_symbols_shift.xml +++ b/java/res/xml/rows_symbols_shift.xml @@ -46,11 +46,8 @@ latin:keyLabel="÷" /> <Key latin:keyLabel="×" /> - <Key - latin:keyLabel="{" /> - <Key - latin:keyLabel="}" - latin:keyWidth="fillRight" /> + <include + latin:keyboardLayout="@xml/keys_curly_brackets" /> </Row> <Row latin:keyWidth="10%p" @@ -74,11 +71,8 @@ <Key latin:keyLabel="=" latin:moreKeys="≠,≈,∞" /> - <Key - latin:keyLabel="[" /> - <Key - latin:keyLabel="]" - latin:keyWidth="fillRight" /> + <include + latin:keyboardLayout="@xml/keys_square_brackets" /> </Row> <Row latin:keyWidth="10%p" @@ -98,12 +92,8 @@ latin:moreKeys="§" /> <Key latin:keyLabel="\\" /> - <Key - latin:keyLabel="<" - latin:moreKeys="≤,«,‹" /> - <Key - latin:keyLabel=">" - latin:moreKeys="≥,»,›" /> + <include + latin:keyboardLayout="@xml/keys_less_greater" /> <Key latin:keyStyle="deleteKeyStyle" latin:keyWidth="fillRight" diff --git a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java index 3b4149d7f..18a4bfbfc 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java +++ b/java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java @@ -38,12 +38,6 @@ public class KeyCodeDescriptionMapper { // Map of key codes to spoken description resource IDs private final HashMap<Integer, Integer> mKeyCodeMap; - // Map of shifted key codes to spoken description resource IDs - private final HashMap<Integer, Integer> mShiftedKeyCodeMap; - - // Map of shift-locked key codes to spoken description resource IDs - private final HashMap<Integer, Integer> mShiftLockedKeyCodeMap; - public static void init() { sInstance.initInternal(); } @@ -55,8 +49,6 @@ public class KeyCodeDescriptionMapper { private KeyCodeDescriptionMapper() { mKeyLabelMap = new HashMap<CharSequence, Integer>(); mKeyCodeMap = new HashMap<Integer, Integer>(); - mShiftedKeyCodeMap = new HashMap<Integer, Integer>(); - mShiftLockedKeyCodeMap = new HashMap<Integer, Integer>(); } private void initInternal() { @@ -64,31 +56,8 @@ public class KeyCodeDescriptionMapper { mKeyLabelMap.put(":-)", R.string.spoken_description_smiley); // Symbols that most TTS engines can't speak - mKeyCodeMap.put((int) '.', R.string.spoken_description_period); - mKeyCodeMap.put((int) ',', R.string.spoken_description_comma); - mKeyCodeMap.put((int) '(', R.string.spoken_description_left_parenthesis); - mKeyCodeMap.put((int) ')', R.string.spoken_description_right_parenthesis); - mKeyCodeMap.put((int) ':', R.string.spoken_description_colon); - mKeyCodeMap.put((int) ';', R.string.spoken_description_semicolon); - mKeyCodeMap.put((int) '!', R.string.spoken_description_exclamation_mark); - mKeyCodeMap.put((int) '?', R.string.spoken_description_question_mark); - mKeyCodeMap.put((int) '\"', R.string.spoken_description_double_quote); - mKeyCodeMap.put((int) '\'', R.string.spoken_description_single_quote); - mKeyCodeMap.put((int) '*', R.string.spoken_description_star); - mKeyCodeMap.put((int) '#', R.string.spoken_description_pound); mKeyCodeMap.put((int) ' ', R.string.spoken_description_space); - // Non-ASCII symbols (must use escape codes!) - mKeyCodeMap.put((int) '\u2022', R.string.spoken_description_dot); - mKeyCodeMap.put((int) '\u221A', R.string.spoken_description_square_root); - mKeyCodeMap.put((int) '\u03C0', R.string.spoken_description_pi); - mKeyCodeMap.put((int) '\u0394', R.string.spoken_description_delta); - mKeyCodeMap.put((int) '\u2122', R.string.spoken_description_trademark); - mKeyCodeMap.put((int) '\u2105', R.string.spoken_description_care_of); - mKeyCodeMap.put((int) '\u2026', R.string.spoken_description_ellipsis); - mKeyCodeMap.put((int) '\u201E', R.string.spoken_description_low_double_quote); - mKeyCodeMap.put((int) '\uFF0A', R.string.spoken_description_star); - // Special non-character codes defined in Keyboard mKeyCodeMap.put(Keyboard.CODE_DELETE, R.string.spoken_description_delete); mKeyCodeMap.put(Keyboard.CODE_ENTER, R.string.spoken_description_return); @@ -97,12 +66,6 @@ public class KeyCodeDescriptionMapper { mKeyCodeMap.put(Keyboard.CODE_SHORTCUT, R.string.spoken_description_mic); mKeyCodeMap.put(Keyboard.CODE_SWITCH_ALPHA_SYMBOL, R.string.spoken_description_to_symbol); mKeyCodeMap.put(Keyboard.CODE_TAB, R.string.spoken_description_tab); - - // Shifted versions of non-character codes defined in Keyboard - mShiftedKeyCodeMap.put(Keyboard.CODE_SHIFT, R.string.spoken_description_shift_shifted); - - // Shift-locked versions of non-character codes defined in Keyboard - mShiftLockedKeyCodeMap.put(Keyboard.CODE_SHIFT, R.string.spoken_description_caps_lock); } /** @@ -126,12 +89,18 @@ public class KeyCodeDescriptionMapper { */ public CharSequence getDescriptionForKey(Context context, Keyboard keyboard, Key key, boolean shouldObscure) { - if (key.mCode == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) { + final int code = key.mCode; + + if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) { final CharSequence description = getDescriptionForSwitchAlphaSymbol(context, keyboard); if (description != null) return description; } + if (code == Keyboard.CODE_SHIFT) { + return getDescriptionForShiftKey(context, keyboard); + } + if (!TextUtils.isEmpty(key.mLabel)) { final String label = key.mLabel.toString().trim(); @@ -176,6 +145,27 @@ public class KeyCodeDescriptionMapper { } /** + * Returns a context-sensitive description of the "Shift" key. + * + * @param context The package's context. + * @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) { + final int resId; + + if (keyboard.isShiftLocked()) { + resId = R.string.spoken_description_caps_lock; + } else if (keyboard.isShiftedOrShiftLocked()) { + resId = R.string.spoken_description_shift_shifted; + } else { + resId = R.string.spoken_description_shift; + } + + return context.getString(resId); + } + + /** * Returns a localized character sequence describing what will happen when * the specified key is pressed based on its key code. * <p> @@ -200,12 +190,6 @@ public class KeyCodeDescriptionMapper { boolean shouldObscure) { final int code = key.mCode; - if (keyboard.isShiftLocked() && mShiftLockedKeyCodeMap.containsKey(code)) { - return context.getString(mShiftLockedKeyCodeMap.get(code)); - } else if (keyboard.isShiftedOrShiftLocked() && mShiftedKeyCodeMap.containsKey(code)) { - return context.getString(mShiftedKeyCodeMap.get(code)); - } - // If the key description should be obscured, now is the time to do it. final boolean isDefinedNonCtrl = Character.isDefined(code) && !Character.isISOControl(code); if (shouldObscure && isDefinedNonCtrl) { diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index d4419aeaf..a6c9fd485 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -28,16 +28,15 @@ import android.util.Xml; import com.android.inputmethod.keyboard.internal.KeyStyles; import com.android.inputmethod.keyboard.internal.KeyStyles.KeyStyle; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; -import com.android.inputmethod.keyboard.internal.MoreKeySpecParser; +import com.android.inputmethod.keyboard.internal.KeySpecParser; import com.android.inputmethod.latin.R; +import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.XmlParseUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; /** * Class for describing the position and characteristics of a single key in the keyboard. @@ -120,6 +119,7 @@ public class Key { private static final int ACTION_FLAGS_IS_REPEATABLE = 0x01; private static final int ACTION_FLAGS_NO_KEY_PREVIEW = 0x02; private static final int ACTION_FLAGS_ALT_CODE_WHILE_TYPING = 0x04; + private static final int ACTION_FLAGS_ENABLE_LONG_PRESS = 0x08; private final int mHashCode; @@ -128,47 +128,8 @@ public class Key { /** Key is enabled and responds on press */ private boolean mEnabled = true; - // RTL parenthesis character swapping map. - private static final Map<Integer, Integer> sRtlParenthesisMap = new HashMap<Integer, Integer>(); - - static { - // The all letters need to be mirrored are found at - // http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedBinaryProperties.txt - addRtlParenthesisPair('(', ')'); - addRtlParenthesisPair('[', ']'); - addRtlParenthesisPair('{', '}'); - addRtlParenthesisPair('<', '>'); - // \u00ab: LEFT-POINTING DOUBLE ANGLE QUOTATION MARK - // \u00bb: RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK - addRtlParenthesisPair('\u00ab', '\u00bb'); - // \u2039: SINGLE LEFT-POINTING ANGLE QUOTATION MARK - // \u203a: SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - addRtlParenthesisPair('\u2039', '\u203a'); - // \u2264: LESS-THAN OR EQUAL TO - // \u2265: GREATER-THAN OR EQUAL TO - addRtlParenthesisPair('\u2264', '\u2265'); - } - - private static void addRtlParenthesisPair(int left, int right) { - sRtlParenthesisMap.put(left, right); - sRtlParenthesisMap.put(right, left); - } - - public static int getRtlParenthesisCode(int code, boolean isRtl) { - if (isRtl && sRtlParenthesisMap.containsKey(code)) { - return sRtlParenthesisMap.get(code); - } else { - return code; - } - } - - private static int getCode(Resources res, Keyboard.Params params, String moreKeySpec) { - return getRtlParenthesisCode( - MoreKeySpecParser.getCode(res, moreKeySpec), params.mIsRtlKeyboard); - } - private static Drawable getIcon(Keyboard.Params params, String moreKeySpec) { - final int iconAttrId = MoreKeySpecParser.getIconAttrId(moreKeySpec); + final int iconAttrId = KeySpecParser.getIconAttrId(moreKeySpec); if (iconAttrId == KeyboardIconsSet.ICON_UNDEFINED) { return null; } else { @@ -181,8 +142,9 @@ public class Key { */ public Key(Resources res, Keyboard.Params params, String moreKeySpec, int x, int y, int width, int height) { - this(params, MoreKeySpecParser.getLabel(moreKeySpec), null, getIcon(params, moreKeySpec), - getCode(res, params, moreKeySpec), MoreKeySpecParser.getOutputText(moreKeySpec), + this(params, KeySpecParser.getLabel(moreKeySpec), null, getIcon(params, moreKeySpec), + KeySpecParser.getCode(res, moreKeySpec), + KeySpecParser.getOutputText(moreKeySpec), x, y, width, height); } @@ -265,7 +227,6 @@ public class Key { mBackgroundType = style.getInt(keyAttr, R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL); - mActionFlags = style.getFlag(keyAttr, R.styleable.Keyboard_Key_keyActionFlags, 0); final KeyboardIconsSet iconsSet = params.mIconsSet; mVisualInsetsLeft = (int) Keyboard.Builder.getDimensionOrFraction(keyAttr, @@ -282,17 +243,19 @@ public class Key { mLabelFlags = style.getFlag(keyAttr, R.styleable.Keyboard_Key_keyLabelFlags, 0); final boolean preserveCase = (mLabelFlags & LABEL_FLAGS_PRESERVE_CASE) != 0; - + int actionFlags = style.getFlag(keyAttr, R.styleable.Keyboard_Key_keyActionFlags, 0); final String[] additionalMoreKeys = style.getStringArray( keyAttr, R.styleable.Keyboard_Key_additionalMoreKeys); - final String[] moreKeys = MoreKeySpecParser.insertAddtionalMoreKeys(style.getStringArray( + final String[] moreKeys = KeySpecParser.insertAddtionalMoreKeys(style.getStringArray( keyAttr, R.styleable.Keyboard_Key_moreKeys), additionalMoreKeys); if (moreKeys != null) { + actionFlags |= ACTION_FLAGS_ENABLE_LONG_PRESS; for (int i = 0; i < moreKeys.length; i++) { moreKeys[i] = adjustCaseOfStringForKeyboardId( moreKeys[i], preserveCase, params.mId); } } + mActionFlags = actionFlags; mMoreKeys = moreKeys; mMaxMoreKeysColumn = style.getInt(keyAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn, params.mMaxMiniKeyboardColumn); @@ -308,17 +271,15 @@ public class Key { // Choose the first letter of the label as primary code if not specified. if (code == Keyboard.CODE_UNSPECIFIED && TextUtils.isEmpty(outputText) && !TextUtils.isEmpty(mLabel)) { - if (mLabel.codePointCount(0, mLabel.length()) == 1) { - final int activatedCode; + if (Utils.codePointCount(mLabel) == 1) { // Use the first letter of the hint label if shiftedLetterActivated flag is // specified. if (hasShiftedLetterHint() && isShiftedLetterActivated() && !TextUtils.isEmpty(mHintLabel)) { - activatedCode = mHintLabel.codePointAt(0); + mCode = mHintLabel.codePointAt(0); } else { - activatedCode = mLabel.codePointAt(0); + mCode = mLabel.codePointAt(0); } - mCode = getRtlParenthesisCode(activatedCode, params.mIsRtlKeyboard); } else { // In some locale and case, the character might be represented by multiple code // points, such as upper case Eszett of German alphabet. @@ -348,7 +309,7 @@ public class Key { if (!Keyboard.isLetterCode(code) || preserveCase) return code; final String text = new String(new int[] { code } , 0, 1); final String casedText = adjustCaseOfStringForKeyboardId(text, preserveCase, id); - return casedText.codePointCount(0, casedText.length()) == 1 + return Utils.codePointCount(casedText) == 1 ? casedText.codePointAt(0) : Keyboard.CODE_UNSPECIFIED; } @@ -403,8 +364,8 @@ public class Key { && o.mCode == mCode && TextUtils.equals(o.mLabel, mLabel) && TextUtils.equals(o.mHintLabel, mHintLabel) - && o.mIconAttrId != mIconAttrId - && o.mBackgroundType != mBackgroundType; + && o.mIconAttrId == mIconAttrId + && o.mBackgroundType == mBackgroundType; } @Override @@ -419,11 +380,20 @@ public class Key { @Override public String toString() { - String top = Keyboard.printableCode(mCode); - if (mLabel != null && mLabel.length() != 1) { - top += "/\"" + mLabel + '"'; + return String.format("%s/%s %d,%d %dx%d %s/%s/%s", + Keyboard.printableCode(mCode), mLabel, mX, mY, mWidth, mHeight, mHintLabel, + KeyboardIconsSet.getIconName(mIconAttrId), backgroundName(mBackgroundType)); + } + + private static String backgroundName(int backgroundType) { + switch (backgroundType) { + case BACKGROUND_TYPE_NORMAL: return "normal"; + case BACKGROUND_TYPE_FUNCTIONAL: return "functional"; + case BACKGROUND_TYPE_ACTION: return "action"; + case BACKGROUND_TYPE_STICKY_OFF: return "stickyOff"; + case BACKGROUND_TYPE_STICKY_ON: return "stickyOn"; + default: return null; } - return String.format("%s %d,%d", top, mX, mY); } public void markAsLeftEdge(Keyboard.Params params) { @@ -466,6 +436,12 @@ public class Key { return (mActionFlags & ACTION_FLAGS_ALT_CODE_WHILE_TYPING) != 0; } + public boolean isLongPressEnabled() { + // We need not start long press timer on the key which has activated shifted letter. + return (mActionFlags & ACTION_FLAGS_ENABLE_LONG_PRESS) != 0 + && (mLabelFlags & LABEL_FLAGS_SHIFTED_LETTER_ACTIVATED) == 0; + } + public Typeface selectTypeface(Typeface defaultTypeface) { // TODO: Handle "bold" here too? if ((mLabelFlags & LABEL_FLAGS_FONT_NORMAL) != 0) { diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java index 0d271625b..bff491ffd 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java +++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java @@ -19,12 +19,14 @@ package com.android.inputmethod.keyboard; import android.util.Log; import java.util.Arrays; +import java.util.List; public class KeyDetector { private static final String TAG = KeyDetector.class.getSimpleName(); private static final boolean DEBUG = false; public static final int NOT_A_CODE = -1; + private static final int ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE = 2; private final int mKeyHysteresisDistanceSquared; @@ -154,8 +156,9 @@ public class KeyDetector { return distances.length; } - private void getNearbyKeyCodes(final int[] allCodes) { + private void getNearbyKeyCodes(final int primaryCode, final int[] allCodes) { final Key[] neighborKeys = mNeighborKeys; + final int maxCodesSize = allCodes.length; // allCodes[0] should always have the key code even if it is a non-letter key. if (neighborKeys[0] == null) { @@ -164,7 +167,7 @@ public class KeyDetector { } int numCodes = 0; - for (int j = 0; j < neighborKeys.length && numCodes < allCodes.length; j++) { + for (int j = 0; j < neighborKeys.length && numCodes < maxCodesSize; j++) { final Key key = neighborKeys[j]; if (key == null) break; @@ -174,6 +177,38 @@ public class KeyDetector { continue; allCodes[numCodes++] = code; } + if (maxCodesSize <= numCodes) { + return; + } + if (primaryCode != NOT_A_CODE) { + final List<Integer> additionalChars = + mKeyboard.getAdditionalProximityChars().get(primaryCode); + if (additionalChars == null || additionalChars.size() == 0) { + return; + } + int currentCodesSize = numCodes; + allCodes[numCodes++] = ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE; + if (maxCodesSize <= numCodes) { + return; + } + // TODO: This is O(N^2). Assuming additionalChars.size() is up to 4 or 5. + for (int i = 0; i < additionalChars.size(); ++i) { + final int additionalChar = additionalChars.get(i); + boolean contains = false; + for (int j = 0; j < currentCodesSize; ++j) { + if (additionalChar == allCodes[j]) { + contains = true; + break; + } + } + if (!contains) { + allCodes[numCodes++] = additionalChar; + if (maxCodesSize <= numCodes) { + return; + } + } + } + } } /** @@ -205,7 +240,7 @@ public class KeyDetector { } if (allCodes != null && allCodes.length > 0) { - getNearbyKeyCodes(allCodes); + getNearbyKeyCodes(primaryKey != null ? primaryKey.mCode : NOT_A_CODE, allCodes); if (DEBUG) { Log.d(TAG, "x=" + x + " y=" + y + " primary=" + printableCode(primaryKey) diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 8832d8fd1..10e0a5b01 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -20,6 +20,7 @@ import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; +import android.text.TextUtils; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; @@ -38,10 +39,12 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -92,7 +95,6 @@ public class Keyboard { */ public static final int CODE_SHIFT = -1; public static final int CODE_SWITCH_ALPHA_SYMBOL = -2; - public static final int CODE_CAPSLOCK = -3; public static final int CODE_OUTPUT_TEXT = -4; public static final int CODE_DELETE = -5; public static final int CODE_SETTINGS = -6; @@ -122,9 +124,6 @@ public class Keyboard { /** Maximum column for mini keyboard */ public final int mMaxMiniKeyboardColumn; - /** True if Right-To-Left keyboard */ - public final boolean mIsRtlKeyboard; - /** List of keys and icons in this keyboard */ public final Set<Key> mKeys; public final Set<Key> mShiftKeys; @@ -134,6 +133,8 @@ public class Keyboard { private final ProximityInfo mProximityInfo; + public final Map<Integer, List<Integer>> mAdditionalProximityChars; + public Keyboard(Params params) { mId = params.mId; mThemeId = params.mThemeId; @@ -141,7 +142,6 @@ public class Keyboard { mOccupiedWidth = params.mOccupiedWidth; mMostCommonKeyHeight = params.mMostCommonKeyHeight; mMostCommonKeyWidth = params.mMostCommonKeyWidth; - mIsRtlKeyboard = params.mIsRtlKeyboard; mMoreKeysTemplate = params.mMoreKeysTemplate; mMaxMiniKeyboardColumn = params.mMaxMiniKeyboardColumn; @@ -151,10 +151,12 @@ public class Keyboard { mKeys = Collections.unmodifiableSet(params.mKeys); mShiftKeys = Collections.unmodifiableSet(params.mShiftKeys); mIconsSet = params.mIconsSet; + mAdditionalProximityChars = params.mAdditionalProximityChars; mProximityInfo = new ProximityInfo( params.GRID_WIDTH, params.GRID_HEIGHT, mOccupiedWidth, mOccupiedHeight, - mMostCommonKeyWidth, mMostCommonKeyHeight, mKeys, params.mTouchPositionCorrection); + mMostCommonKeyWidth, mMostCommonKeyHeight, mKeys, params.mTouchPositionCorrection, + params.mAdditionalProximityChars); } public ProximityInfo getProximityInfo() { @@ -223,7 +225,6 @@ public class Keyboard { public int mHorizontalGap; public int mVerticalGap; - public boolean mIsRtlKeyboard; public int mMoreKeysTemplate; public int mMaxMiniKeyboardColumn; @@ -233,6 +234,9 @@ public class Keyboard { public final Set<Key> mKeys = new HashSet<Key>(); public final Set<Key> mShiftKeys = new HashSet<Key>(); public final KeyboardIconsSet mIconsSet = new KeyboardIconsSet(); + // TODO: Should be in Key instead of Keyboard.Params? + public final Map<Integer, List<Integer>> mAdditionalProximityChars = + new HashMap<Integer, List<Integer>>(); public KeyboardSet.KeysCache mKeysCache; @@ -364,13 +368,17 @@ public class Keyboard { return mProximityInfo.getNearestKeys(adjustedX, adjustedY); } + public Map<Integer, List<Integer>> getAdditionalProximityChars() { + return mAdditionalProximityChars; + } + public static String printableCode(int code) { switch (code) { case CODE_SHIFT: return "shift"; case CODE_SWITCH_ALPHA_SYMBOL: return "symbol"; - case CODE_CAPSLOCK: return "capslock"; case CODE_OUTPUT_TEXT: return "text"; case CODE_DELETE: return "delete"; + case CODE_SETTINGS: return "settings"; case CODE_SHORTCUT: return "shortcut"; case CODE_UNSPECIFIED: return "unspec"; case CODE_TAB: return "tab"; @@ -620,6 +628,7 @@ public class Keyboard { mParams = params; setTouchPositionCorrectionData(context, params); + setAdditionalProximityChars(context, params); params.GRID_WIDTH = res.getInteger(R.integer.config_keyboard_grid_width); params.GRID_HEIGHT = res.getInteger(R.integer.config_keyboard_grid_height); @@ -642,6 +651,25 @@ public class Keyboard { params.mTouchPositionCorrection.load(data); } + private static void setAdditionalProximityChars(Context context, Params params) { + final String[] additionalChars = + context.getResources().getStringArray(R.array.additional_proximitychars); + int currentPrimaryIndex = 0; + for (int i = 0; i < additionalChars.length; ++i) { + final String additionalChar = additionalChars[i]; + if (TextUtils.isEmpty(additionalChar)) { + currentPrimaryIndex = 0; + } else if (currentPrimaryIndex == 0) { + currentPrimaryIndex = additionalChar.charAt(0); + params.mAdditionalProximityChars.put( + currentPrimaryIndex, new ArrayList<Integer>()); + } else if (currentPrimaryIndex != 0) { + final int c = additionalChar.charAt(0); + params.mAdditionalProximityChars.get(currentPrimaryIndex).add(c); + } + } + } + public void setAutoGenerate(KeyboardSet.KeysCache keysCache) { mParams.mKeysCache = keysCache; } @@ -740,8 +768,6 @@ public class Keyboard { R.styleable.Keyboard_rowHeight, params.mBaseHeight, params.mBaseHeight / DEFAULT_KEYBOARD_ROWS); - params.mIsRtlKeyboard = keyboardAttr.getBoolean( - R.styleable.Keyboard_isRtlKeyboard, false); params.mMoreKeysTemplate = keyboardAttr.getResourceId( R.styleable.Keyboard_moreKeysTemplate, 0); params.mMaxMiniKeyboardColumn = keyAttr.getInt( diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 997b952de..0837e17da 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -46,7 +46,7 @@ public class KeyboardId { public static final int ELEMENT_SYMBOLS = 5; public static final int ELEMENT_SYMBOLS_SHIFTED = 6; public static final int ELEMENT_PHONE = 7; - public static final int ELEMENT_PHONE_SHIFTED = 8; + public static final int ELEMENT_PHONE_SYMBOLS = 8; public static final int ELEMENT_NUMBER = 9; private static final int F2KEY_MODE_NONE = 0; @@ -145,11 +145,11 @@ public class KeyboardId { } public boolean isPhoneKeyboard() { - return mElementId == ELEMENT_PHONE || mElementId == ELEMENT_PHONE_SHIFTED; + return mElementId == ELEMENT_PHONE || mElementId == ELEMENT_PHONE_SYMBOLS; } public boolean isPhoneShiftKeyboard() { - return mElementId == ELEMENT_PHONE_SHIFTED; + return mElementId == ELEMENT_PHONE_SYMBOLS; } public boolean navigateAction() { @@ -237,7 +237,7 @@ public class KeyboardId { case ELEMENT_SYMBOLS: return "symbols"; case ELEMENT_SYMBOLS_SHIFTED: return "symbolsShifted"; case ELEMENT_PHONE: return "phone"; - case ELEMENT_PHONE_SHIFTED: return "phoneShifted"; + case ELEMENT_PHONE_SYMBOLS: return "phoneSymbols"; case ELEMENT_NUMBER: return "number"; default: return null; } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java index d35948bad..82eaa1d17 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSet.java @@ -57,7 +57,10 @@ public class KeyboardSet { private final Context mContext; private final Params mParams; - private final KeysCache mKeysCache = new KeysCache(); + + private static final HashMap<KeyboardId, SoftReference<Keyboard>> sKeyboardCache = + new HashMap<KeyboardId, SoftReference<Keyboard>>(); + private static final KeysCache sKeysCache = new KeysCache(); public static class KeyboardSetException extends RuntimeException { public final KeyboardId mKeyboardId; @@ -74,6 +77,10 @@ public class KeyboardSet { mMap = new HashMap<Key, Key>(); } + public void clear() { + mMap.clear(); + } + public Key get(Key key) { final Key existingKey = mMap.get(key); if (existingKey != null) { @@ -103,11 +110,9 @@ public class KeyboardSet { Params() {} } - private static final HashMap<KeyboardId, SoftReference<Keyboard>> sKeyboardCache = - new HashMap<KeyboardId, SoftReference<Keyboard>>(); - public static void clearKeyboardCache() { sKeyboardCache.clear(); + sKeysCache.clear(); } private KeyboardSet(Context context, Params params) { @@ -119,9 +124,11 @@ public class KeyboardSet { final int keyboardSetElementId; switch (mParams.mMode) { case KeyboardId.MODE_PHONE: - keyboardSetElementId = - (baseKeyboardSetElementId == KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED) - ? KeyboardId.ELEMENT_PHONE_SHIFTED : KeyboardId.ELEMENT_PHONE; + if (baseKeyboardSetElementId == KeyboardId.ELEMENT_SYMBOLS) { + keyboardSetElementId = KeyboardId.ELEMENT_PHONE_SYMBOLS; + } else { + keyboardSetElementId = KeyboardId.ELEMENT_PHONE; + } break; case KeyboardId.MODE_NUMBER: keyboardSetElementId = KeyboardId.ELEMENT_NUMBER; @@ -154,7 +161,7 @@ public class KeyboardSet { final Keyboard.Builder<Keyboard.Params> builder = new Keyboard.Builder<Keyboard.Params>(context, new Keyboard.Params()); if (id.isAlphabetKeyboard()) { - builder.setAutoGenerate(mKeysCache); + builder.setAutoGenerate(sKeysCache); } builder.load(keyboardXmlId, id); builder.setTouchPositionCorrectionEnabled(mParams.mTouchPositionCorrectionEnabled); diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 951bcdbfd..5ba560d72 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -194,6 +194,9 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, } public void onPressKey(int code) { + if (isVibrateAndSoundFeedbackRequired()) { + mInputMethodService.hapticAndAudioFeedback(code); + } mState.onPressKey(code); } @@ -271,11 +274,31 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions, ? keyboardView.getTimerProxy().isInDoubleTapTimeout() : false; } + // Implements {@link KeyboardState.SwitchActions}. + @Override + public void startLongPressTimer(int code) { + final LatinKeyboardView keyboardView = getKeyboardView(); + if (keyboardView != null) { + final TimerProxy timer = keyboardView.getTimerProxy(); + timer.startLongPressTimer(code); + } + } + + // Implements {@link KeyboardState.SwitchActions}. + @Override + public void hapticAndAudioFeedback(int code) { + mInputMethodService.hapticAndAudioFeedback(code); + } + + public void onLongPressTimeout(int code) { + mState.onLongPressTimeout(code); + } + public boolean isInMomentarySwitchState() { return mState.isInMomentarySwitchState(); } - public boolean isVibrateAndSoundFeedbackRequired() { + private boolean isVibrateAndSoundFeedbackRequired() { return mKeyboardView != null && !mKeyboardView.isInSlidingKeyInput(); } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 2cbd132ca..c6fb75489 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -41,6 +41,7 @@ import com.android.inputmethod.compat.FrameLayoutCompatUtils; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; +import com.android.inputmethod.latin.Utils; import java.util.HashMap; @@ -851,7 +852,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy { if (key.mLabel != null) { // TODO Should take care of temporaryShiftLabel here. previewText.setCompoundDrawables(null, null, null, null); - if (key.mLabel.length() > 1) { + if (Utils.codePointCount(key.mLabel) > 1) { previewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, params.mKeyLetterSize); previewText.setTypeface(Typeface.DEFAULT_BOLD); } else { diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index 5aad67d49..f3583fefc 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -117,12 +117,12 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke private static final int MSG_DOUBLE_TAP = 3; private static final int MSG_KEY_TYPED = 4; - private final int mKeyRepeatInterval; + private final KeyTimerParams mParams; private boolean mInKeyRepeat; - public KeyTimerHandler(LatinKeyboardView outerInstance, int keyRepeatInterval) { + public KeyTimerHandler(LatinKeyboardView outerInstance, KeyTimerParams params) { super(outerInstance); - mKeyRepeatInterval = keyRepeatInterval; + mParams = params; } @Override @@ -132,18 +132,23 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke switch (msg.what) { case MSG_REPEAT_KEY: tracker.onRepeatKey(tracker.getKey()); - startKeyRepeatTimer(mKeyRepeatInterval, tracker); + startKeyRepeatTimer(tracker); break; case MSG_LONGPRESS_KEY: - keyboardView.openMiniKeyboardIfRequired(tracker.getKey(), tracker); + if (tracker != null) { + keyboardView.openMiniKeyboardIfRequired(tracker.getKey(), tracker); + } else { + KeyboardSwitcher.getInstance().onLongPressTimeout(msg.arg1); + } break; } } @Override - public void startKeyRepeatTimer(long delay, PointerTracker tracker) { + public void startKeyRepeatTimer(PointerTracker tracker) { mInKeyRepeat = true; - sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, tracker), delay); + sendMessageDelayed(obtainMessage(MSG_REPEAT_KEY, tracker), + mParams.mKeyRepeatStartTimeout); } public void cancelKeyRepeatTimer() { @@ -156,9 +161,49 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke } @Override - public void startLongPressTimer(long delay, PointerTracker tracker) { + public void startLongPressTimer(int code) { + cancelLongPressTimer(); + final int delay; + switch (code) { + case Keyboard.CODE_SHIFT: + delay = mParams.mLongPressShiftKeyTimeout; + break; + default: + delay = 0; + break; + } + if (delay > 0) { + sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, code, 0), delay); + } + } + + @Override + public void startLongPressTimer(PointerTracker tracker) { cancelLongPressTimer(); - sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, tracker), delay); + if (tracker != null) { + final Key key = tracker.getKey(); + final int delay; + switch (key.mCode) { + case Keyboard.CODE_SHIFT: + delay = mParams.mLongPressShiftKeyTimeout; + break; + case Keyboard.CODE_SPACE: + delay = mParams.mLongPressSpaceKeyTimeout; + break; + default: + if (KeyboardSwitcher.getInstance().isInMomentarySwitchState()) { + // We use longer timeout for sliding finger input started from the symbols + // mode key. + delay = mParams.mLongPressKeyTimeout * 3; + } else { + delay = mParams.mLongPressKeyTimeout; + } + break; + } + if (delay > 0) { + sendMessageDelayed(obtainMessage(MSG_LONGPRESS_KEY, tracker), delay); + } + } } @Override @@ -167,9 +212,9 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke } @Override - public void startKeyTypedTimer(long delay) { + public void startKeyTypedTimer() { removeMessages(MSG_KEY_TYPED); - sendMessageDelayed(obtainMessage(MSG_KEY_TYPED), delay); + sendMessageDelayed(obtainMessage(MSG_KEY_TYPED), mParams.mIgnoreSpecialKeyTimeout); } @Override @@ -201,11 +246,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke public static class PointerTrackerParams { public final boolean mSlidingKeyInputEnabled; - public final int mKeyRepeatStartTimeout; - public final int mLongPressKeyTimeout; - public final int mLongPressShiftKeyTimeout; - public final int mLongPressSpaceKeyTimeout; - public final int mIgnoreSpecialKeyTimeout; public final int mTouchNoiseThresholdTime; public final float mTouchNoiseThresholdDistance; @@ -213,11 +253,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke private PointerTrackerParams() { mSlidingKeyInputEnabled = false; - mKeyRepeatStartTimeout = 0; - mLongPressKeyTimeout = 0; - mLongPressShiftKeyTimeout = 0; - mLongPressSpaceKeyTimeout = 0; - mIgnoreSpecialKeyTimeout = 0; mTouchNoiseThresholdTime =0; mTouchNoiseThresholdDistance = 0; } @@ -225,8 +260,35 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke public PointerTrackerParams(TypedArray latinKeyboardViewAttr) { mSlidingKeyInputEnabled = latinKeyboardViewAttr.getBoolean( R.styleable.LatinKeyboardView_slidingKeyInputEnable, false); + mTouchNoiseThresholdTime = latinKeyboardViewAttr.getInt( + R.styleable.LatinKeyboardView_touchNoiseThresholdTime, 0); + mTouchNoiseThresholdDistance = latinKeyboardViewAttr.getDimension( + R.styleable.LatinKeyboardView_touchNoiseThresholdDistance, 0); + } + } + + static class KeyTimerParams { + public final int mKeyRepeatStartTimeout; + public final int mKeyRepeatInterval; + public final int mLongPressKeyTimeout; + public final int mLongPressShiftKeyTimeout; + public final int mLongPressSpaceKeyTimeout; + public final int mIgnoreSpecialKeyTimeout; + + KeyTimerParams() { + mKeyRepeatStartTimeout = 0; + mKeyRepeatInterval = 0; + mLongPressKeyTimeout = 0; + mLongPressShiftKeyTimeout = 0; + mLongPressSpaceKeyTimeout = 0; + mIgnoreSpecialKeyTimeout = 0; + } + + public KeyTimerParams(TypedArray latinKeyboardViewAttr) { mKeyRepeatStartTimeout = latinKeyboardViewAttr.getInt( R.styleable.LatinKeyboardView_keyRepeatStartTimeout, 0); + mKeyRepeatInterval = latinKeyboardViewAttr.getInt( + R.styleable.LatinKeyboardView_keyRepeatInterval, 0); mLongPressKeyTimeout = latinKeyboardViewAttr.getInt( R.styleable.LatinKeyboardView_longPressKeyTimeout, 0); mLongPressShiftKeyTimeout = latinKeyboardViewAttr.getInt( @@ -235,10 +297,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke R.styleable.LatinKeyboardView_longPressSpaceKeyTimeout, 0); mIgnoreSpecialKeyTimeout = latinKeyboardViewAttr.getInt( R.styleable.LatinKeyboardView_ignoreSpecialKeyTimeout, 0); - mTouchNoiseThresholdTime = latinKeyboardViewAttr.getInt( - R.styleable.LatinKeyboardView_touchNoiseThresholdTime, 0); - mTouchNoiseThresholdDistance = latinKeyboardViewAttr.getDimension( - R.styleable.LatinKeyboardView_touchNoiseThresholdDistance, 0); } } @@ -254,7 +312,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke mHasDistinctMultitouch = context.getPackageManager() .hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT); - PointerTracker.init(mHasDistinctMultitouch, getContext()); + PointerTracker.init(mHasDistinctMultitouch); final TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.LatinKeyboardView, defStyle, R.style.LatinKeyboardView); @@ -268,16 +326,14 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke mSpacebarTextShadowColor = a.getColor( R.styleable.LatinKeyboardView_spacebarTextShadowColor, 0); + final KeyTimerParams keyTimerParams = new KeyTimerParams(a); mPointerTrackerParams = new PointerTrackerParams(a); - mIsSpacebarTriggeringPopupByLongPress = ( - mPointerTrackerParams.mLongPressSpaceKeyTimeout > 0); + mIsSpacebarTriggeringPopupByLongPress = (keyTimerParams.mLongPressSpaceKeyTimeout > 0); final float keyHysteresisDistance = a.getDimension( R.styleable.LatinKeyboardView_keyHysteresisDistance, 0); mKeyDetector = new KeyDetector(keyHysteresisDistance); - final int keyRepeatInterval = a.getInt( - R.styleable.LatinKeyboardView_keyRepeatInterval, 0); - mKeyTimerHandler = new KeyTimerHandler(this, keyRepeatInterval); + mKeyTimerHandler = new KeyTimerHandler(this, keyTimerParams); mConfigShowMiniKeyboardAtTouchedPoint = a.getBoolean( R.styleable.LatinKeyboardView_showMiniKeyboardAtTouchedPoint, false); a.recycle(); @@ -425,12 +481,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke // Long pressing on 0 in phone number keypad gives you a '+'. invokeCodeInput(Keyboard.CODE_PLUS); invokeReleaseKey(primaryCode); - return true; - } - if (primaryCode == Keyboard.CODE_SHIFT && keyboard.mId.isAlphabetKeyboard()) { - tracker.onLongPressed(); - invokeCodeInput(Keyboard.CODE_CAPSLOCK); - invokeReleaseKey(primaryCode); + KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode); return true; } if (primaryCode == Keyboard.CODE_SPACE) { diff --git a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java index 974291373..4648da1c1 100644 --- a/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java +++ b/java/src/com/android/inputmethod/keyboard/MiniKeyboard.java @@ -18,7 +18,7 @@ package com.android.inputmethod.keyboard; import android.graphics.Paint; -import com.android.inputmethod.keyboard.internal.MoreKeySpecParser; +import com.android.inputmethod.keyboard.internal.KeySpecParser; import com.android.inputmethod.latin.R; public class MiniKeyboard extends Keyboard { @@ -210,7 +210,6 @@ public class MiniKeyboard extends Keyboard { // TODO: Mini keyboard's vertical gap is currently calculated heuristically. // Should revise the algorithm. mParams.mVerticalGap = parentKeyboard.mVerticalGap / 2; - mParams.mIsRtlKeyboard = parentKeyboard.mIsRtlKeyboard; mMoreKeys = parentKey.mMoreKeys; final int previewWidth = view.mKeyPreviewDrawParams.mPreviewBackgroundWidth; @@ -236,7 +235,7 @@ public class MiniKeyboard extends Keyboard { Paint paint = null; int maxWidth = minKeyWidth; for (String moreKeySpec : moreKeys) { - final String label = MoreKeySpecParser.getLabel(moreKeySpec); + final String label = KeySpecParser.getLabel(moreKeySpec); // If the label is single letter, minKeyWidth is enough to hold the label. if (label != null && label.length() > 1) { if (paint == null) { diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index fc92a24a6..110f7f6ae 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -16,7 +16,6 @@ package com.android.inputmethod.keyboard; -import android.content.Context; import android.os.SystemClock; import android.util.Log; import android.view.MotionEvent; @@ -71,10 +70,11 @@ public class PointerTracker { } public interface TimerProxy { - public void startKeyTypedTimer(long delay); + public void startKeyTypedTimer(); public boolean isTyping(); - public void startKeyRepeatTimer(long delay, PointerTracker tracker); - public void startLongPressTimer(long delay, PointerTracker tracker); + public void startKeyRepeatTimer(PointerTracker tracker); + public void startLongPressTimer(PointerTracker tracker); + public void startLongPressTimer(int code); public void cancelLongPressTimer(); public void startDoubleTapTimer(); public boolean isInDoubleTapTimeout(); @@ -82,13 +82,15 @@ public class PointerTracker { public static class Adapter implements TimerProxy { @Override - public void startKeyTypedTimer(long delay) {} + public void startKeyTypedTimer() {} @Override public boolean isTyping() { return false; } @Override - public void startKeyRepeatTimer(long delay, PointerTracker tracker) {} + public void startKeyRepeatTimer(PointerTracker tracker) {} @Override - public void startLongPressTimer(long delay, PointerTracker tracker) {} + public void startLongPressTimer(PointerTracker tracker) {} + @Override + public void startLongPressTimer(int code) {} @Override public void cancelLongPressTimer() {} @Override @@ -159,7 +161,7 @@ public class PointerTracker { private static final KeyboardActionListener EMPTY_LISTENER = new KeyboardActionListener.Adapter(); - public static void init(boolean hasDistinctMultitouch, Context context) { + public static void init(boolean hasDistinctMultitouch) { if (hasDistinctMultitouch) { sPointerTrackerQueue = new PointerTrackerQueue(); } else { @@ -269,7 +271,7 @@ public class PointerTracker { mListener.onCodeInput(code, keyCodes, x, y); } if (!key.altCodeWhileTyping() && !key.isModifier()) { - mTimerProxy.startKeyTypedTimer(sParams.mIgnoreSpecialKeyTimeout); + mTimerProxy.startKeyTypedTimer(); } } } @@ -674,7 +676,7 @@ public class PointerTracker { private void startRepeatKey(Key key) { if (key != null && key.isRepeatable()) { onRepeatKey(key); - mTimerProxy.startKeyRepeatTimer(sParams.mKeyRepeatStartTimeout, this); + mTimerProxy.startKeyRepeatTimer(this); mIsRepeatableKey = true; } else { mIsRepeatableKey = false; @@ -702,24 +704,8 @@ public class PointerTracker { } private void startLongPressTimer(Key key) { - if (key == null) return; - if (key.mCode == Keyboard.CODE_SHIFT) { - if (sParams.mLongPressShiftKeyTimeout > 0) { - mTimerProxy.startLongPressTimer(sParams.mLongPressShiftKeyTimeout, this); - } - } else if (key.mCode == Keyboard.CODE_SPACE) { - if (sParams.mLongPressSpaceKeyTimeout > 0) { - mTimerProxy.startLongPressTimer(sParams.mLongPressSpaceKeyTimeout, this); - } - } else if (key.hasShiftedLetterHint() && mKeyboard.isManualShifted()) { - // We need not start long press timer on the key which has manual temporary upper case - // code defined and the keyboard is in manual temporary upper case mode. - return; - } else if (sKeyboardSwitcher.isInMomentarySwitchState()) { - // We use longer timeout for sliding finger input started from the symbols mode key. - mTimerProxy.startLongPressTimer(sParams.mLongPressKeyTimeout * 3, this); - } else { - mTimerProxy.startLongPressTimer(sParams.mLongPressKeyTimeout, this); + if (key != null && key.isLongPressEnabled()) { + mTimerProxy.startLongPressTimer(this); } } diff --git a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java index c1dae0601..2d1a0083d 100644 --- a/java/src/com/android/inputmethod/keyboard/ProximityInfo.java +++ b/java/src/com/android/inputmethod/keyboard/ProximityInfo.java @@ -24,6 +24,9 @@ import com.android.inputmethod.latin.spellcheck.SpellCheckerProximityInfo; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Set; public class ProximityInfo { @@ -44,7 +47,8 @@ public class ProximityInfo { private final Key[][] mGridNeighbors; ProximityInfo(int gridWidth, int gridHeight, int minWidth, int height, int keyWidth, - int keyHeight, Set<Key> keys, TouchPositionCorrection touchPositionCorrection) { + int keyHeight, Set<Key> keys, TouchPositionCorrection touchPositionCorrection, + Map<Integer, List<Integer>> additionalProximityChars) { mGridWidth = gridWidth; mGridHeight = gridHeight; mGridSize = mGridWidth * mGridHeight; @@ -58,20 +62,20 @@ public class ProximityInfo { // No proximity required. Keyboard might be mini keyboard. return; } - computeNearestNeighbors(keyWidth, keys, touchPositionCorrection); + computeNearestNeighbors(keyWidth, keys, touchPositionCorrection, additionalProximityChars); } public static ProximityInfo createDummyProximityInfo() { - return new ProximityInfo(1, 1, 1, 1, 1, 1, Collections.<Key>emptySet(), null); + return new ProximityInfo(1, 1, 1, 1, 1, 1, Collections.<Key> emptySet(), + null, Collections.<Integer, List<Integer>> emptyMap()); } public static ProximityInfo createSpellCheckerProximityInfo(final int[] proximity) { final ProximityInfo spellCheckerProximityInfo = createDummyProximityInfo(); spellCheckerProximityInfo.mNativeProximityInfo = spellCheckerProximityInfo.setProximityInfoNative( - SpellCheckerProximityInfo.ROW_SIZE, - 480, 300, 11, 3, proximity, - 0, null, null, null, null, null, null, null, null); + SpellCheckerProximityInfo.ROW_SIZE, 480, 300, 11, 3, proximity, 0, + null, null, null, null, null, null, null, null); return spellCheckerProximityInfo; } @@ -79,11 +83,13 @@ public class ProximityInfo { static { Utils.loadNativeLibrary(); } + private native long setProximityInfoNative(int maxProximityCharsSize, int displayWidth, int displayHeight, int gridWidth, int gridHeight, int[] proximityCharsArray, int keyCount, int[] keyXCoordinates, int[] keyYCoordinates, int[] keyWidths, int[] keyHeights, int[] keyCharCodes, float[] sweetSpotCenterX, float[] sweetSpotCenterY, float[] sweetSpotRadii); + private native void releaseProximityInfoNative(long nativeProximityInfo); private final void setProximityInfo(Key[][] gridNeighborKeys, int keyboardWidth, @@ -138,7 +144,7 @@ public class ProximityInfo { final float radius = touchPositionCorrection.mRadii[row]; sweetSpotCenterXs[i] = hitBoxCenterX + x * hitBoxWidth; sweetSpotCenterYs[i] = hitBoxCenterY + y * hitBoxHeight; - sweetSpotRadii[i] = radius * (float)Math.sqrt( + sweetSpotRadii[i] = radius * (float) Math.sqrt( hitBoxWidth * hitBoxWidth + hitBoxHeight * hitBoxHeight); } } @@ -168,7 +174,12 @@ public class ProximityInfo { } private void computeNearestNeighbors(int defaultWidth, Set<Key> keys, - TouchPositionCorrection touchPositionCorrection) { + TouchPositionCorrection touchPositionCorrection, + Map<Integer, List<Integer>> additionalProximityChars) { + final Map<Integer, Key> keyCodeMap = new HashMap<Integer, Key>(); + for (final Key key : keys) { + keyCodeMap.put(key.mCode, key); + } final int thresholdBase = (int) (defaultWidth * SEARCH_DISTANCE); final int threshold = thresholdBase * thresholdBase; // Round-up so we don't have any pixels outside the grid @@ -186,6 +197,27 @@ public class ProximityInfo { neighborKeys[count++] = key; } } + int currentCodesSize = count; + for (int i = 0; i < currentCodesSize; ++i) { + final int c = neighborKeys[i].mCode; + final List<Integer> additionalChars = additionalProximityChars.get(c); + if (additionalChars == null || additionalChars.size() == 0) { + continue; + } + for (int j = 0; j < additionalChars.size(); ++j) { + final int additionalChar = additionalChars.get(j); + boolean contains = false; + for (int k = 0; k < count; ++k) { + if(additionalChar == neighborKeys[k].mCode) { + contains = true; + break; + } + } + if (!contains) { + neighborKeys[count++] = keyCodeMap.get(additionalChar); + } + } + } mGridNeighbors[(y / mCellHeight) * mGridWidth + (x / mCellWidth)] = Arrays.copyOfRange(neighborKeys, 0, count); } @@ -199,7 +231,7 @@ public class ProximityInfo { return EMPTY_KEY_ARRAY; } if (x >= 0 && x < mKeyboardMinWidth && y >= 0 && y < mKeyboardHeight) { - int index = (y / mCellHeight) * mGridWidth + (x / mCellWidth); + int index = (y / mCellHeight) * mGridWidth + (x / mCellWidth); if (index < mGridSize) { return mGridNeighbors[index]; } diff --git a/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java index abebfec01..a84b469ea 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java @@ -30,23 +30,31 @@ import java.util.Arrays; /** * String parser of moreKeys attribute of Key. * The string is comma separated texts each of which represents one "more key". + * - String resource can be embedded into specification @string/name. This is done before parsing + * comma. * Each "more key" specification is one of the following: * - A single letter (Letter) * - Label optionally followed by keyOutputText or code (keyLabel|keyOutputText). * - Icon followed by keyOutputText or code (@icon/icon_name|@integer/key_code) - * Special character, comma ',' backslash '\', and bar '|' can be escaped by '\' - * character. + * Special character, comma ',' backslash '\', and bar '|' can be escaped by '\' character. * Note that the character '@' and '\' are also parsed by XML parser and CSV parser as well. - * See {@link KeyboardIconsSet} about icon_number. + * See {@link KeyboardIconsSet} about icon_name. */ -public class MoreKeySpecParser { +public class KeySpecParser { private static final boolean DEBUG = LatinImeLogger.sDBG; + + // Constants for parsing. + private static int COMMA = ','; + private static final char ESCAPE_CHAR = '\\'; + private static final char PREFIX_AT = '@'; + private static final char SUFFIX_SLASH = '/'; + private static final String PREFIX_STRING = PREFIX_AT + "string" + SUFFIX_SLASH; private static final char LABEL_END = '|'; - private static final String PREFIX_ICON = Utils.PREFIX_AT + "icon" + Utils.SUFFIX_SLASH; - private static final String PREFIX_CODE = Utils.PREFIX_AT + "integer" + Utils.SUFFIX_SLASH; + private static final String PREFIX_ICON = PREFIX_AT + "icon" + SUFFIX_SLASH; + private static final String PREFIX_CODE = PREFIX_AT + "integer" + SUFFIX_SLASH; private static final String ADDITIONAL_MORE_KEY_MARKER = "%"; - private MoreKeySpecParser() { + private KeySpecParser() { // Intentional empty constructor for utility class. } @@ -56,7 +64,7 @@ public class MoreKeySpecParser { if (end > 0) { return true; } - throw new MoreKeySpecParserError("outputText or code not specified: " + moreKeySpec); + throw new KeySpecParserError("outputText or code not specified: " + moreKeySpec); } return false; } @@ -71,15 +79,17 @@ public class MoreKeySpecParser { } private static String parseEscape(String text) { - if (text.indexOf(Utils.ESCAPE_CHAR) < 0) { + if (text.indexOf(ESCAPE_CHAR) < 0) { return text; } final int length = text.length(); final StringBuilder sb = new StringBuilder(); for (int pos = 0; pos < length; pos++) { final char c = text.charAt(pos); - if (c == Utils.ESCAPE_CHAR && pos + 1 < length) { - sb.append(text.charAt(++pos)); + if (c == ESCAPE_CHAR && pos + 1 < length) { + // Skip escape char + pos++; + sb.append(text.charAt(pos)); } else { sb.append(c); } @@ -88,17 +98,18 @@ public class MoreKeySpecParser { } private static int indexOfLabelEnd(String moreKeySpec, int start) { - if (moreKeySpec.indexOf(Utils.ESCAPE_CHAR, start) < 0) { + if (moreKeySpec.indexOf(ESCAPE_CHAR, start) < 0) { final int end = moreKeySpec.indexOf(LABEL_END, start); if (end == 0) { - throw new MoreKeySpecParserError(LABEL_END + " at " + start + ": " + moreKeySpec); + throw new KeySpecParserError(LABEL_END + " at " + start + ": " + moreKeySpec); } return end; } final int length = moreKeySpec.length(); for (int pos = start; pos < length; pos++) { final char c = moreKeySpec.charAt(pos); - if (c == Utils.ESCAPE_CHAR && pos + 1 < length) { + if (c == ESCAPE_CHAR && pos + 1 < length) { + // Skip escape char pos++; } else if (c == LABEL_END) { return pos; @@ -115,7 +126,7 @@ public class MoreKeySpecParser { final String label = (end > 0) ? parseEscape(moreKeySpec.substring(0, end)) : parseEscape(moreKeySpec); if (TextUtils.isEmpty(label)) { - throw new MoreKeySpecParserError("Empty label: " + moreKeySpec); + throw new KeySpecParserError("Empty label: " + moreKeySpec); } return label; } @@ -127,7 +138,7 @@ public class MoreKeySpecParser { final int end = indexOfLabelEnd(moreKeySpec, 0); if (end > 0) { if (indexOfLabelEnd(moreKeySpec, end + 1) >= 0) { - throw new MoreKeySpecParserError("Multiple " + LABEL_END + ": " + throw new KeySpecParserError("Multiple " + LABEL_END + ": " + moreKeySpec); } final String outputText = parseEscape( @@ -135,23 +146,23 @@ public class MoreKeySpecParser { if (!TextUtils.isEmpty(outputText)) { return outputText; } - throw new MoreKeySpecParserError("Empty outputText: " + moreKeySpec); + throw new KeySpecParserError("Empty outputText: " + moreKeySpec); } final String label = getLabel(moreKeySpec); if (label == null) { - throw new MoreKeySpecParserError("Empty label: " + moreKeySpec); + throw new KeySpecParserError("Empty label: " + moreKeySpec); } // Code is automatically generated for one letter label. See {@link getCode()}. - return (label.length() == 1) ? null : label; + return (Utils.codePointCount(label) == 1) ? null : label; } public static int getCode(Resources res, String moreKeySpec) { if (hasCode(moreKeySpec)) { final int end = indexOfLabelEnd(moreKeySpec, 0); if (indexOfLabelEnd(moreKeySpec, end + 1) >= 0) { - throw new MoreKeySpecParserError("Multiple " + LABEL_END + ": " + moreKeySpec); + throw new KeySpecParserError("Multiple " + LABEL_END + ": " + moreKeySpec); } - final int resId = Utils.getResourceId(res, + final int resId = getResourceId(res, moreKeySpec.substring(end + /* LABEL_END */1 + /* PREFIX_AT */1), R.string.english_ime_name); final int code = res.getInteger(resId); @@ -162,8 +173,8 @@ public class MoreKeySpecParser { } final String label = getLabel(moreKeySpec); // Code is automatically generated for one letter label. - if (label != null && label.length() == 1) { - return label.charAt(0); + if (Utils.codePointCount(label) == 1) { + return label.codePointAt(0); } return Keyboard.CODE_OUTPUT_TEXT; } @@ -248,9 +259,96 @@ public class MoreKeySpecParser { } @SuppressWarnings("serial") - public static class MoreKeySpecParserError extends RuntimeException { - public MoreKeySpecParserError(String message) { + public static class KeySpecParserError extends RuntimeException { + public KeySpecParserError(String message) { super(message); } } + + private static int getResourceId(Resources res, String name, int packageNameResId) { + String packageName = res.getResourcePackageName(packageNameResId); + int resId = res.getIdentifier(name, null, packageName); + if (resId == 0) { + throw new RuntimeException("Unknown resource: " + name); + } + return resId; + } + + private static String resolveStringResource(String text, Resources res, int packageNameResId) { + final int size = text.length(); + if (size < PREFIX_STRING.length()) { + return text; + } + + StringBuilder sb = null; + for (int pos = 0; pos < size; pos++) { + final char c = text.charAt(pos); + if (c == PREFIX_AT && text.startsWith(PREFIX_STRING, pos)) { + if (sb == null) { + sb = new StringBuilder(text.substring(0, pos)); + } + final int end = searchResourceNameEnd(text, pos + PREFIX_STRING.length()); + final String resName = text.substring(pos + 1, end); + final int resId = getResourceId(res, resName, packageNameResId); + sb.append(res.getString(resId)); + pos = end - 1; + } else if (c == ESCAPE_CHAR) { + if (sb != null) { + // Append both escape character and escaped character. + sb.append(text.substring(pos, Math.min(pos + 2, size))); + } + pos++; + } else if (sb != null) { + sb.append(c); + } + } + return (sb == null) ? text : sb.toString(); + } + + private static int searchResourceNameEnd(String text, int start) { + final int size = text.length(); + for (int pos = start; pos < size; pos++) { + final char c = text.charAt(pos); + // String resource name should be consisted of [a-z_0-9]. + if ((c >= 'a' && c <= 'z') || c == '_' || (c >= '0' && c <= '9')) { + continue; + } + return pos; + } + return size; + } + + public static String[] parseCsvString(String rawText, Resources res, int packageNameResId) { + final String text = resolveStringResource(rawText, res, packageNameResId); + final int size = text.length(); + if (size == 0) { + return null; + } + if (Utils.codePointCount(text) == 1) { + return new String[] { text }; + } + + ArrayList<String> list = null; + int start = 0; + for (int pos = 0; pos < size; pos++) { + final char c = text.charAt(pos); + if (c == COMMA) { + if (list == null) { + list = new ArrayList<String>(); + } + list.add(text.substring(start, pos)); + // Skip comma + start = pos + 1; + } else if (c == ESCAPE_CHAR) { + // Skip escape character and escaped character. + pos++; + } + } + if (list == null) { + return new String[] { text.substring(start) }; + } else { + list.add(text.substring(start)); + return list.toArray(new String[list.size()]); + } + } } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java index 1450192b2..6ec56ca9f 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java @@ -16,19 +16,16 @@ package com.android.inputmethod.keyboard.internal; -import android.content.res.Resources; import android.content.res.TypedArray; import android.util.Log; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.latin.R; -import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.XmlParseUtils; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; -import java.util.ArrayList; import java.util.HashMap; public class KeyStyles { @@ -74,63 +71,8 @@ public class KeyStyles { protected static String[] parseStringArray(TypedArray a, int index) { if (!a.hasValue(index)) return null; - return parseCsvString(a.getString(index), a.getResources(), R.string.english_ime_name); - } - } - - /* package for test */ - static String[] parseCsvString(String rawText, Resources res, int packageNameResId) { - final String text = Utils.resolveStringResource(rawText, res, packageNameResId); - final int size = text.length(); - if (size == 0) { - return null; - } - if (size == 1) { - return new String[] { text }; - } - - final StringBuilder sb = new StringBuilder(); - ArrayList<String> list = null; - int start = 0; - for (int pos = 0; pos < size; pos++) { - final char c = text.charAt(pos); - if (c == ',') { - if (list == null) { - list = new ArrayList<String>(); - } - if (sb.length() == 0) { - list.add(text.substring(start, pos)); - } else { - list.add(sb.toString()); - sb.setLength(0); - } - start = pos + 1; - continue; - } else if (c == Utils.ESCAPE_CHAR) { - if (start == pos) { - // Skip escape character at the beginning of the value. - start++; - pos++; - } else { - if (start < pos && sb.length() == 0) { - sb.append(text.subSequence(start, pos)); - } - pos++; - if (pos < size) { - sb.append(text.charAt(pos)); - } - } - } else if (sb.length() > 0) { - sb.append(c); - } - } - if (list == null) { - return new String[] { - sb.length() > 0 ? sb.toString() : text.substring(start) - }; - } else { - list.add(sb.length() > 0 ? sb.toString() : text.substring(start)); - return list.toArray(new String[list.size()]); + return KeySpecParser.parseCsvString( + a.getString(index), a.getResources(), R.string.english_ime_name); } } diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java index bec6ae1cc..31a7e8b8e 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java @@ -36,8 +36,9 @@ public class KeyboardIconsSet { private final Map<Integer, Drawable> mIcons = new HashMap<Integer, Drawable>(); // The key value should be aligned with the enum value of Keyboard.icon*. - private static final Map<Integer, Integer> ICONS_TO_ATTRS_MAP = new HashMap<Integer, Integer>(); - private static final Map<String, Integer> NAME_TO_ATTRS_MAP = new HashMap<String, Integer>(); + private static final Map<Integer, Integer> ID_TO_ATTR_MAP = new HashMap<Integer, Integer>(); + private static final Map<String, Integer> NAME_TO_ATTR_MAP = new HashMap<String, Integer>(); + private static final Map<Integer, String> ATTR_TO_NAME_MAP = new HashMap<Integer, String>(); private static final Collection<Integer> VALID_ATTRS; static { @@ -55,12 +56,13 @@ public class KeyboardIconsSet { addIconIdMap(11, "shiftKeyShifted", R.styleable.Keyboard_iconShiftKeyShifted); addIconIdMap(12, "disabledShortcurKey", R.styleable.Keyboard_iconDisabledShortcutKey); addIconIdMap(13, "previewTabKey", R.styleable.Keyboard_iconPreviewTabKey); - VALID_ATTRS = ICONS_TO_ATTRS_MAP.values(); + VALID_ATTRS = ID_TO_ATTR_MAP.values(); } private static void addIconIdMap(int iconId, String name, Integer attrId) { - ICONS_TO_ATTRS_MAP.put(iconId, attrId); - NAME_TO_ATTRS_MAP.put(name, attrId); + ID_TO_ATTR_MAP.put(iconId, attrId); + NAME_TO_ATTR_MAP.put(name, attrId); + ATTR_TO_NAME_MAP.put(attrId, name); } public void loadIcons(final TypedArray keyboardAttrs) { @@ -82,7 +84,7 @@ public class KeyboardIconsSet { if (iconId == ICON_UNDEFINED) { return ATTR_UNDEFINED; } - final Integer attrId = ICONS_TO_ATTRS_MAP.get(iconId); + final Integer attrId = ID_TO_ATTR_MAP.get(iconId); if (attrId == null) { throw new IllegalArgumentException("icon id is out of range: " + iconId); } @@ -90,13 +92,23 @@ public class KeyboardIconsSet { } public static int getIconAttrId(final String iconName) { - final Integer attrId = NAME_TO_ATTRS_MAP.get(iconName); + final Integer attrId = NAME_TO_ATTR_MAP.get(iconName); if (attrId == null) { throw new IllegalArgumentException("unknown icon name: " + iconName); } return attrId; } + public static String getIconName(final int attrId) { + if (attrId == ATTR_UNDEFINED) { + return "null"; + } + if (ATTR_TO_NAME_MAP.containsKey(attrId)) { + return ATTR_TO_NAME_MAP.get(attrId); + } + return String.format("unknown<0x%08x>", attrId); + } + public Drawable getIconByAttrId(final Integer attrId) { if (attrId == ATTR_UNDEFINED) { return null; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java index 1de83866f..cb8b4f05c 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardState.java @@ -29,7 +29,7 @@ import com.android.inputmethod.keyboard.Keyboard; * The input events are {@link #onLoadKeyboard(String)}, {@link #onSaveKeyboardState()}, * {@link #onPressKey(int)}, {@link #onReleaseKey(int, boolean)}, * {@link #onCodeInput(int, boolean, boolean)}, {@link #onCancelInput(boolean)}, - * {@link #onUpdateShiftState(boolean)}. + * {@link #onUpdateShiftState(boolean)}, {@link #onLongPressTimeout(int)}. * * The actions are {@link SwitchActions}'s methods. */ @@ -54,6 +54,8 @@ public class KeyboardState { public void startDoubleTapTimer(); public boolean isInDoubleTapTimeout(); + public void startLongPressTimer(int code); + public void hapticAndAudioFeedback(int code); } private final SwitchActions mSwitchActions; @@ -335,6 +337,24 @@ public class KeyboardState { mSymbolKeyState.onRelease(); } + public void onLongPressTimeout(int code) { + if (DEBUG_EVENT) { + Log.d(TAG, "onLongPressTimeout: code=" + Keyboard.printableCode(code) + " " + this); + } + if (mIsAlphabetMode && code == Keyboard.CODE_SHIFT) { + if (mAlphabetShiftState.isShiftLocked()) { + setShiftLocked(false); + // Shift key is long pressed while shift locked state, we will toggle back to normal + // state. And mark as if shift key is released. + mShiftKeyState.onRelease(); + } else { + // Shift key is long pressed while shift unloked state. + setShiftLocked(true); + } + mSwitchActions.hapticAndAudioFeedback(code); + } + } + public void onUpdateShiftState(boolean autoCaps) { if (DEBUG_EVENT) { Log.d(TAG, "onUpdateShiftState: autoCaps=" + autoCaps + " " + this); @@ -370,23 +390,27 @@ public class KeyboardState { // Shift key has been double tapped while in normal state. This is the second // tap to disable shift locked state, so just ignore this. } - } else if (mAlphabetShiftState.isShiftLocked()) { - // Shift key is pressed while shift locked state, we will treat this state as - // shift lock shifted state and mark as if shift key pressed while normal state. - setShifted(SHIFT_LOCK_SHIFTED); - mShiftKeyState.onPress(); - } else if (mAlphabetShiftState.isAutomaticShifted()) { - // Shift key is pressed while automatic shifted, we have to move to manual shifted. - setShifted(MANUAL_SHIFT); - mShiftKeyState.onPress(); - } else if (mAlphabetShiftState.isShiftedOrShiftLocked()) { - // In manual shifted state, we just record shift key has been pressing while - // shifted state. - mShiftKeyState.onPressOnShifted(); } else { - // In base layout, chording or manual shifted mode is started. - setShifted(MANUAL_SHIFT); - mShiftKeyState.onPress(); + if (mAlphabetShiftState.isShiftLocked()) { + // Shift key is pressed while shift locked state, we will treat this state as + // shift lock shifted state and mark as if shift key pressed while normal state. + setShifted(SHIFT_LOCK_SHIFTED); + mShiftKeyState.onPress(); + } else if (mAlphabetShiftState.isAutomaticShifted()) { + // Shift key is pressed while automatic shifted, we have to move to manual + // shifted. + setShifted(MANUAL_SHIFT); + mShiftKeyState.onPress(); + } else if (mAlphabetShiftState.isShiftedOrShiftLocked()) { + // In manual shifted state, we just record shift key has been pressing while + // shifted state. + mShiftKeyState.onPressOnShifted(); + } else { + // In base layout, chording or manual shifted mode is started. + setShifted(MANUAL_SHIFT); + mShiftKeyState.onPress(); + } + mSwitchActions.startLongPressTimer(Keyboard.CODE_SHIFT); } } else { // In symbol mode, just toggle symbol and symbol more keyboard. @@ -480,18 +504,6 @@ public class KeyboardState { + " autoCaps=" + autoCaps + " " + this); } - if (mIsAlphabetMode && code == Keyboard.CODE_CAPSLOCK) { - if (mAlphabetShiftState.isShiftLocked()) { - setShiftLocked(false); - // Shift key is long pressed while shift locked state, we will toggle back to normal - // state. And mark as if shift key is released. - mShiftKeyState.onRelease(); - } else { - // Shift key is long pressed while shift unloked state. - setShiftLocked(true); - } - } - switch (mSwitchState) { case SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL: if (code == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) { diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 1e7171406..1bc55a583 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -59,7 +59,6 @@ import com.android.inputmethod.compat.SuggestionSpanUtils; import com.android.inputmethod.compat.VibratorCompatWrapper; import com.android.inputmethod.deprecated.LanguageSwitcherProxy; import com.android.inputmethod.deprecated.VoiceProxy; -import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardActionListener; import com.android.inputmethod.keyboard.KeyboardId; @@ -873,13 +872,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // turn this flag on in succession and both onUpdateSelection() calls arrive after // the second one - the first call successfully avoids this test, but the second one // enters. For the moment we rely on candidatesCleared to further reduce the impact. - if (SPACE_STATE_WEAK == mSpaceState) { - // Test for no WEAK_SPACE action because there is a race condition that may end up - // in coming here on a normal key press. We set this to NONE because after - // a cursor move, we don't want the suggestion strip to swap the space with the - // newly inserted punctuation. - mSpaceState = SPACE_STATE_NONE; - } + + // We set this to NONE because after a cursor move, we don't want the space + // state-related special processing to kick in. + mSpaceState = SPACE_STATE_NONE; + if (((mWordComposer.isComposingWord()) || mVoiceProxy.isVoiceInputHighlighted()) && (selectionChanged || candidatesCleared)) { @@ -1296,10 +1293,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar case Keyboard.CODE_SETTINGS: onSettingsKeyPressed(); break; - case Keyboard.CODE_CAPSLOCK: - // Caps lock code is handled in KeyboardSwitcher.onCodeInput() below. - hapticAndAudioFeedback(primaryCode); - break; case Keyboard.CODE_SHORTCUT: mSubtypeSwitcher.switchToShortcutIME(); break; @@ -1901,16 +1894,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // So, LatinImeLogger logs "" as a user's input. LatinImeLogger.logOnManualSuggestion( "", suggestion.toString(), index, suggestions.mWords); + final CharSequence outputText = mSettingsValues.mSuggestPuncOutputTextList + .getWord(index); + final int primaryCode = outputText.charAt(0); // Find out whether the previous character is a space. If it is, as a special case // for punctuation entered through the suggestion strip, it should be swapped // if it was a magic or a weak space. This is meant to help in case the user // pressed space on purpose of displaying the suggestion strip punctuation. - final int rawPrimaryCode = suggestion.charAt(0); - // Maybe apply the "bidi mirrored" conversions for parentheses - final Keyboard keyboard = mKeyboardSwitcher.getKeyboard(); - final boolean isRtl = keyboard != null && keyboard.mIsRtlKeyboard; - final int primaryCode = Key.getRtlParenthesisCode(rawPrimaryCode, isRtl); - insertPunctuationFromSuggestionStrip(ic, primaryCode); // TODO: the following endBatchEdit seems useless, check if (ic != null) { @@ -2229,9 +2219,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // be needed, but it's there just in case something went wrong. final CharSequence textBeforeCursor = ic.getTextBeforeCursor(2, 0); if (!". ".equals(textBeforeCursor)) { - // We should not have come here if we aren't just after a ". ". - throw new RuntimeException("Tried to revert double-space combo but we didn't find " + // Theoretically we should not be coming here if there isn't ". " before the + // cursor, but the application may be changing the text while we are typing, so + // anything goes. We should not crash. + Log.d(TAG, "Tried to revert double-space combo but we didn't find " + "\". \" just before the cursor."); + return false; } ic.beginBatchEdit(); ic.deleteSurroundingText(2, 0); @@ -2294,18 +2287,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar loadSettings(); } - private void hapticAndAudioFeedback(int primaryCode) { + public void hapticAndAudioFeedback(int primaryCode) { vibrate(); playKeyClick(primaryCode); } @Override public void onPressKey(int primaryCode) { - final KeyboardSwitcher switcher = mKeyboardSwitcher; - if (switcher.isVibrateAndSoundFeedbackRequired()) { - hapticAndAudioFeedback(primaryCode); - } - switcher.onPressKey(primaryCode); + mKeyboardSwitcher.onPressKey(primaryCode); } @Override @@ -2313,7 +2302,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mKeyboardSwitcher.onReleaseKey(primaryCode, withSliding); } - // receive ringer mode change and network state change. private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java index e6ef3962e..8e2f605c4 100644 --- a/java/src/com/android/inputmethod/latin/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/SettingsValues.java @@ -25,6 +25,7 @@ import android.view.inputmethod.EditorInfo; import com.android.inputmethod.compat.InputTypeCompatUtils; import com.android.inputmethod.compat.VibratorCompatWrapper; +import com.android.inputmethod.keyboard.internal.KeySpecParser; import java.util.Arrays; import java.util.Locale; @@ -36,8 +37,9 @@ public class SettingsValues { public final int mDelayUpdateOldSuggestions; public final String mMagicSpaceStrippers; public final String mMagicSpaceSwappers; - public final String mSuggestPuncs; + private final String mSuggestPuncs; public final SuggestedWords mSuggestPuncList; + public final SuggestedWords mSuggestPuncOutputTextList; private final String mSymbolsExcludedFromWordSeparators; public final String mWordSeparators; public final CharSequence mHintToSaveText; @@ -98,9 +100,11 @@ public class SettingsValues { } } } - mSuggestPuncs = res.getString(R.string.suggested_punctuations); - // TODO: it would be nice not to recreate this each time we change the configuration - mSuggestPuncList = createSuggestPuncList(mSuggestPuncs); + final String[] suggestPuncsSpec = KeySpecParser.parseCsvString( + res.getString(R.string.suggested_punctuations), res, R.string.english_ime_name); + mSuggestPuncs = createSuggestPuncs(suggestPuncsSpec); + mSuggestPuncList = createSuggestPuncList(suggestPuncsSpec); + mSuggestPuncOutputTextList = createSuggestPuncOutputTextList(suggestPuncsSpec); mSymbolsExcludedFromWordSeparators = res.getString(R.string.symbols_excluded_from_word_separators); mWordSeparators = createWordSeparators(mMagicSpaceStrippers, mMagicSpaceSwappers, @@ -150,11 +154,36 @@ public class SettingsValues { } // Helper functions to create member values. - private static SuggestedWords createSuggestPuncList(final String puncs) { - SuggestedWords.Builder builder = new SuggestedWords.Builder(); + private static String createSuggestPuncs(final String[] puncs) { + final StringBuilder sb = new StringBuilder(); if (puncs != null) { - for (int i = 0; i < puncs.length(); i++) { - builder.addWord(puncs.subSequence(i, i + 1)); + for (final String puncSpec : puncs) { + sb.append(KeySpecParser.getLabel(puncSpec)); + } + } + return sb.toString(); + } + + private static SuggestedWords createSuggestPuncList(final String[] puncs) { + final SuggestedWords.Builder builder = new SuggestedWords.Builder(); + if (puncs != null) { + for (final String puncSpec : puncs) { + builder.addWord(KeySpecParser.getLabel(puncSpec)); + } + } + return builder.setIsPunctuationSuggestions().build(); + } + + private static SuggestedWords createSuggestPuncOutputTextList(final String[] puncs) { + final SuggestedWords.Builder builder = new SuggestedWords.Builder(); + if (puncs != null) { + for (final String puncSpec : puncs) { + final String outputText = KeySpecParser.getOutputText(puncSpec); + if (outputText != null) { + builder.addWord(outputText); + } else { + builder.addWord(KeySpecParser.getLabel(puncSpec)); + } } } return builder.setIsPunctuationSuggestions().build(); diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index a70808741..3975dddeb 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -62,12 +62,6 @@ public class Utils { private static boolean DBG = LatinImeLogger.sDBG; private static boolean DBG_EDIT_DISTANCE = false; - // Constants for resource name parsing. - public static final char ESCAPE_CHAR = '\\'; - public static final char PREFIX_AT = '@'; - public static final char SUFFIX_SLASH = '/'; - private static final String PREFIX_STRING = PREFIX_AT + "string"; - private Utils() { // Intentional empty constructor for utility class. } @@ -800,61 +794,8 @@ public class Utils { } } - public static int getResourceId(Resources res, String name, int packageNameResId) { - String packageName = res.getResourcePackageName(packageNameResId); - int resId = res.getIdentifier(name, null, packageName); - if (resId == 0) { - throw new RuntimeException("Unknown resource: " + name); - } - return resId; - } - - public static String resolveStringResource(String text, Resources res, int packageNameResId) { - final int size = text.length(); - if (size < PREFIX_STRING.length()) { - return text; - } - - StringBuilder sb = null; - for (int pos = 0; pos < size; pos++) { - final char c = text.charAt(pos); - if (c == PREFIX_AT && text.startsWith(PREFIX_STRING, pos)) { - if (sb == null) { - sb = new StringBuilder(text.substring(0, pos)); - } - final int end = Utils.searchResourceNameEnd(text, pos + PREFIX_STRING.length()); - final String resName = text.substring(pos + 1, end); - final int resId = getResourceId(res, resName, packageNameResId); - sb.append(res.getString(resId)); - pos = end - 1; - } else if (c == ESCAPE_CHAR) { - pos++; - if (sb != null) { - sb.append(c); - if (pos < size) { - sb.append(text.charAt(pos)); - } - } - } else if (sb != null) { - sb.append(c); - } - } - return (sb == null) ? text : sb.toString(); - } - - private static int searchResourceNameEnd(String text, int start) { - final int size = text.length(); - if (start >= size || text.charAt(start) != SUFFIX_SLASH) { - throw new RuntimeException("Resource name not specified"); - } - for (int pos = start + 1; pos < size; pos++) { - final char c = text.charAt(pos); - // String resource name should be consisted of [a-z_0-9]. - if ((c >= 'a' && c <= 'z') || c == '_' || (c >= '0' && c <= '9')) { - continue; - } - return pos; - } - return size; + public static int codePointCount(String text) { + if (TextUtils.isEmpty(text)) return 0; + return text.codePointCount(0, text.length()); } } diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 230c2916b..bd244b913 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -16,8 +16,6 @@ package com.android.inputmethod.latin; -import android.text.TextUtils; - import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.KeyDetector; import com.android.inputmethod.keyboard.Keyboard; @@ -33,7 +31,7 @@ public class WordComposer { public static final int NOT_A_CODE = KeyDetector.NOT_A_CODE; public static final int NOT_A_COORDINATE = -1; - final int N = BinaryDictionary.MAX_WORD_LENGTH; + final static int N = BinaryDictionary.MAX_WORD_LENGTH; private ArrayList<int[]> mCodes; private int[] mXCoordinates; diff --git a/native/src/correction.cpp b/native/src/correction.cpp index 7323747d7..8275c5d7e 100644 --- a/native/src/correction.cpp +++ b/native/src/correction.cpp @@ -383,7 +383,10 @@ Correction::CorrectionType Correction::processCharAndCalcState( incrementInputIndex(); } else { --mTransposedCount; - if (DEBUG_CORRECTION) { + if (DEBUG_CORRECTION + && (INPUTLENGTH_FOR_DEBUG <= 0 || INPUTLENGTH_FOR_DEBUG == mInputLength) + && (MIN_OUTPUT_INDEX_FOR_DEBUG <= 0 + || MIN_OUTPUT_INDEX_FOR_DEBUG < mOutputIndex)) { DUMP_WORD(mWord, mOutputIndex); AKLOGI("UNRELATED(0): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, mTransposedCount, mExcessiveCount, c); @@ -404,13 +407,17 @@ Correction::CorrectionType Correction::processCharAndCalcState( : mProximityInfo->getMatchedProximityId( mInputIndex, c, checkProximityChars, &proximityIndex); - if (ProximityInfo::UNRELATED_CHAR == matchedProximityCharId) { + if (ProximityInfo::UNRELATED_CHAR == matchedProximityCharId + || ProximityInfo::ADDITIONAL_PROXIMITY_CHAR == matchedProximityCharId) { if (canTryCorrection && mOutputIndex > 0 && mCorrectionStates[mOutputIndex].mProximityMatching && mCorrectionStates[mOutputIndex].mExceeding && isEquivalentChar(mProximityInfo->getMatchedProximityId( mInputIndex, mWord[mOutputIndex - 1], false))) { - if (DEBUG_CORRECTION) { + if (DEBUG_CORRECTION + && (INPUTLENGTH_FOR_DEBUG <= 0 || INPUTLENGTH_FOR_DEBUG == mInputLength) + && (MIN_OUTPUT_INDEX_FOR_DEBUG <= 0 + || MIN_OUTPUT_INDEX_FOR_DEBUG < mOutputIndex)) { AKLOGI("CONVERSION p->e %c", mWord[mOutputIndex - 1]); } // Conversion p->e @@ -429,7 +436,8 @@ Correction::CorrectionType Correction::processCharAndCalcState( } } - if (ProximityInfo::UNRELATED_CHAR == matchedProximityCharId) { + if (ProximityInfo::UNRELATED_CHAR == matchedProximityCharId + || ProximityInfo::ADDITIONAL_PROXIMITY_CHAR == matchedProximityCharId) { // TODO: Optimize // As the current char turned out to be an unrelated char, // we will try other correction-types. Please note that mCorrectionStates[mOutputIndex] @@ -481,12 +489,47 @@ Correction::CorrectionType Correction::processCharAndCalcState( ++mExcessiveCount; incrementInputIndex(); } + if (DEBUG_CORRECTION + && (INPUTLENGTH_FOR_DEBUG <= 0 || INPUTLENGTH_FOR_DEBUG == mInputLength) + && (MIN_OUTPUT_INDEX_FOR_DEBUG <= 0 + || MIN_OUTPUT_INDEX_FOR_DEBUG < mOutputIndex)) { + DUMP_WORD(mWord, mOutputIndex); + if (mTransposing) { + AKLOGI("TRANSPOSE: %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, + mTransposedCount, mExcessiveCount, c); + } else { + AKLOGI("EXCEED: %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, + mTransposedCount, mExcessiveCount, c); + } + } } else if (mSkipping) { // 3. Skip correction ++mSkippedCount; + if (DEBUG_CORRECTION + && (INPUTLENGTH_FOR_DEBUG <= 0 || INPUTLENGTH_FOR_DEBUG == mInputLength) + && (MIN_OUTPUT_INDEX_FOR_DEBUG <= 0 + || MIN_OUTPUT_INDEX_FOR_DEBUG < mOutputIndex)) { + AKLOGI("SKIP: %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, + mTransposedCount, mExcessiveCount, c); + } return processSkipChar(c, isTerminal, false); + } else if (ProximityInfo::ADDITIONAL_PROXIMITY_CHAR == matchedProximityCharId) { + // As a last resort, use additional proximity characters + mProximityMatching = true; + ++mProximityCount; + mDistances[mOutputIndex] = ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO; + if (DEBUG_CORRECTION + && (INPUTLENGTH_FOR_DEBUG <= 0 || INPUTLENGTH_FOR_DEBUG == mInputLength) + && (MIN_OUTPUT_INDEX_FOR_DEBUG <= 0 + || MIN_OUTPUT_INDEX_FOR_DEBUG < mOutputIndex)) { + AKLOGI("ADDITIONALPROX: %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, + mTransposedCount, mExcessiveCount, c); + } } else { - if (DEBUG_CORRECTION) { + if (DEBUG_CORRECTION + && (INPUTLENGTH_FOR_DEBUG <= 0 || INPUTLENGTH_FOR_DEBUG == mInputLength) + && (MIN_OUTPUT_INDEX_FOR_DEBUG <= 0 + || MIN_OUTPUT_INDEX_FOR_DEBUG < mOutputIndex)) { DUMP_WORD(mWord, mOutputIndex); AKLOGI("UNRELATED(1): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, mTransposedCount, mExcessiveCount, c); @@ -506,6 +549,13 @@ Correction::CorrectionType Correction::processCharAndCalcState( ++mProximityCount; mDistances[mOutputIndex] = mProximityInfo->getNormalizedSquaredDistance(mInputIndex, proximityIndex); + if (DEBUG_CORRECTION + && (INPUTLENGTH_FOR_DEBUG <= 0 || INPUTLENGTH_FOR_DEBUG == mInputLength) + && (MIN_OUTPUT_INDEX_FOR_DEBUG <= 0 + || MIN_OUTPUT_INDEX_FOR_DEBUG < mOutputIndex)) { + AKLOGI("PROX: %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, + mTransposedCount, mExcessiveCount, c); + } } addCharToCurrentWord(c); @@ -539,7 +589,9 @@ Correction::CorrectionType Correction::processCharAndCalcState( || isSameAsUserTypedLength) && isTerminal) { mTerminalInputIndex = mInputIndex - 1; mTerminalOutputIndex = mOutputIndex - 1; - if (DEBUG_CORRECTION) { + if (DEBUG_CORRECTION + && (INPUTLENGTH_FOR_DEBUG <= 0 || INPUTLENGTH_FOR_DEBUG == mInputLength) + && (MIN_OUTPUT_INDEX_FOR_DEBUG <= 0 || MIN_OUTPUT_INDEX_FOR_DEBUG < mOutputIndex)) { DUMP_WORD(mWord, mOutputIndex); AKLOGI("ONTERMINAL(1): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, mTransposedCount, mExcessiveCount, c); @@ -678,7 +730,7 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const if (excessiveCount > 0) { multiplyRate(WORDS_WITH_EXCESSIVE_CHARACTER_DEMOTION_RATE, &finalFreq); if (!lastCharExceeded && !proximityInfo->existsAdjacentProximityChars(excessivePos)) { - if (DEBUG_CORRECTION_FREQ) { + if (DEBUG_DICT_FULL) { AKLOGI("Double excessive demotion"); } // If an excessive character is not adjacent to the left char or the right char, @@ -687,11 +739,13 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const } } + const bool performTouchPositionCorrection = + CALIBRATE_SCORE_BY_TOUCH_COORDINATES && proximityInfo->touchPositionCorrectionEnabled() + && skippedCount == 0 && excessiveCount == 0 && transposedCount == 0; // Score calibration by touch coordinates is being done only for pure-fat finger typing error // cases. // TODO: Remove this constraint. - if (CALIBRATE_SCORE_BY_TOUCH_COORDINATES && proximityInfo->touchPositionCorrectionEnabled() - && skippedCount == 0 && excessiveCount == 0 && transposedCount == 0) { + if (performTouchPositionCorrection) { for (int i = 0; i < outputLength; ++i) { const int squaredDistance = correction->mDistances[i]; if (i < adjustedProximityMatchedCount) { @@ -702,29 +756,38 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const static const float A = ZERO_DISTANCE_PROMOTION_RATE / 100.0f; static const float B = 1.0f; static const float C = 0.5f; + static const float MIN = 0.3f; static const float R1 = NEUTRAL_SCORE_SQUARED_RADIUS; static const float R2 = HALF_SCORE_SQUARED_RADIUS; const float x = (float)squaredDistance / ProximityInfo::NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR; - const float factor = (x < R1) + const float factor = max((x < R1) ? (A * (R1 - x) + B * x) / R1 - : (B * (R2 - x) + C * (x - R1)) / (R2 - R1); + : (B * (R2 - x) + C * (x - R1)) / (R2 - R1), MIN); // factor is piecewise linear function like: // A -_ . // ^-_ . // B \ . - // \ . - // C \ . - // 0 R1 R2 - if (factor <= 0) { - return -1; - } + // \_ . + // C ------------. + // . + // 0 R1 R2 . multiplyRate((int)(factor * 100), &finalFreq); } else if (squaredDistance == PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO) { multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); + } else if (squaredDistance == ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO) { + multiplyRate(WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); } } } else { + // Demote additional proximity characters + int additionalProximityCount = 0; + for (int i = 0; i < outputLength; ++i) { + const int squaredDistance = correction->mDistances[i]; + if (squaredDistance == ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO) { + ++additionalProximityCount; + } + } // Promotion for a word with proximity characters for (int i = 0; i < adjustedProximityMatchedCount; ++i) { // A word with proximity corrections @@ -732,7 +795,11 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const AKLOGI("Found a proximity correction."); } multiplyIntCapped(typedLetterMultiplier, &finalFreq); - multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); + if (i < additionalProximityCount) { + multiplyRate(WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); + } else { + multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); + } } } @@ -794,7 +861,8 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const AKLOGI("calc: %d, %d", outputLength, sameLength); } - if (DEBUG_CORRECTION_FREQ) { + if (DEBUG_CORRECTION_FREQ + && (INPUTLENGTH_FOR_DEBUG <= 0 || INPUTLENGTH_FOR_DEBUG == inputLength)) { DUMP_WORD(correction->mWord, outputLength); AKLOGI("FinalFreq: [P%d, S%d, T%d, E%d] %d, %d, %d, %d, %d, %d", proximityMatchedCount, skippedCount, transposedCount, excessiveCount, outputLength, lastCharExceeded, diff --git a/native/src/correction.h b/native/src/correction.h index b246070fe..a711c994d 100644 --- a/native/src/correction.h +++ b/native/src/correction.h @@ -85,7 +85,7 @@ class Correction { } } - Correction(const int typedLetterMultiplier, const int fullWordMultiplier); + Correction(const int typedLetterMultiplier, const int fullWordMultiplier); void initCorrection( const ProximityInfo *pi, const int inputLength, const int maxWordLength); void initCorrectionState(const int rootPos, const int childCount, const bool traverseAll); diff --git a/native/src/defines.h b/native/src/defines.h index 3f3f5ba5c..02c1fe0a2 100644 --- a/native/src/defines.h +++ b/native/src/defines.h @@ -172,6 +172,7 @@ static void prof_out(void) { #define NOT_A_COORDINATE -1 #define EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO -2 #define PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO -3 +#define ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO -4 #define NOT_A_INDEX -1 #define NOT_A_FREQUENCY -1 @@ -194,6 +195,7 @@ static void prof_out(void) { #define WORDS_WITH_TRANSPOSED_CHARACTERS_DEMOTION_RATE 70 #define FULL_MATCHED_WORDS_PROMOTION_RATE 120 #define WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE 90 +#define WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE 30 #define WORDS_WITH_MATCH_SKIP_PROMOTION_RATE 105 #define WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_RATE 160 #define CORRECTION_COUNT_RATE_DEMOTION_RATE_BASE 45 @@ -210,6 +212,9 @@ static void prof_out(void) { // This is only used for the size of array. Not to be used in c functions. #define MAX_WORD_LENGTH_INTERNAL 48 +// This must be equal to ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE in KeyDetector.java +#define ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE 2 + // Word limit for sub queues used in WordsPriorityQueuePool. Sub queues are temporary queues used // for better performance. // Holds up to 1 candidate for each word @@ -241,4 +246,8 @@ static void prof_out(void) { // The ratio of neutral area radius to sweet spot radius. #define NEUTRAL_AREA_RADIUS_RATIO 1.3f +// DEBUG +#define INPUTLENGTH_FOR_DEBUG -1 +#define MIN_OUTPUT_INDEX_FOR_DEBUG -1 + #endif // LATINIME_DEFINES_H diff --git a/native/src/proximity_info.cpp b/native/src/proximity_info.cpp index e0e938099..b6bab2274 100644 --- a/native/src/proximity_info.cpp +++ b/native/src/proximity_info.cpp @@ -261,7 +261,8 @@ ProximityInfo::ProximityType ProximityInfo::getMatchedProximityId(const int inde // Not an exact nor an accent-alike match: search the list of close keys int j = 1; - while (j < MAX_PROXIMITY_CHARS_SIZE && currentChars[j] > 0) { + while (j < MAX_PROXIMITY_CHARS_SIZE + && currentChars[j] > ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) { const bool matched = (currentChars[j] == baseLowerC || currentChars[j] == c); if (matched) { if (proximityIndex) { @@ -271,6 +272,21 @@ ProximityInfo::ProximityType ProximityInfo::getMatchedProximityId(const int inde } ++j; } + if (j < MAX_PROXIMITY_CHARS_SIZE + && currentChars[j] == ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) { + ++j; + while (j < MAX_PROXIMITY_CHARS_SIZE + && currentChars[j] > ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) { + const bool matched = (currentChars[j] == baseLowerC || currentChars[j] == c); + if (matched) { + if (proximityIndex) { + *proximityIndex = j; + } + return ADDITIONAL_PROXIMITY_CHAR; + } + ++j; + } + } // Was not included, signal this as an unrelated character. return UNRELATED_CHAR; diff --git a/native/src/proximity_info.h b/native/src/proximity_info.h index 9ca5505a7..b77c1bb0a 100644 --- a/native/src/proximity_info.h +++ b/native/src/proximity_info.h @@ -38,7 +38,9 @@ class ProximityInfo { // It is a char located nearby on the keyboard NEAR_PROXIMITY_CHAR, // It is an unrelated char - UNRELATED_CHAR + UNRELATED_CHAR, + // Additional proximity char which can differ by language. + ADDITIONAL_PROXIMITY_CHAR } ProximityType; ProximityInfo(const int maxProximityCharsSize, const int keyboardWidth, diff --git a/tests/res/values/donottranslate.xml b/tests/res/values/donottranslate.xml index bfd1c1716..d0cde71a5 100644 --- a/tests/res/values/donottranslate.xml +++ b/tests/res/values/donottranslate.xml @@ -30,11 +30,14 @@ <string name="label_surrounded_by_spaces">" abc "</string> <string name="escaped_char">"\\a"</string> <string name="escaped_comma">"\\,"</string> + <string name="escaped_comma_escape">"a\\,\\"</string> <string name="escaped_escape">"\\\\"</string> <string name="escaped_label">"a\\bc"</string> <string name="escaped_label_at_beginning">"\\abc"</string> + <string name="escaped_label_at_end">"abc\\"</string> <string name="escaped_label_with_comma">"a\\,c"</string> <string name="escaped_label_with_comma_at_beginning">"\\,bc"</string> + <string name="escaped_label_with_comma_at_end">"ab\\,"</string> <string name="escaped_label_with_successive">"\\,\\\\bc"</string> <string name="escaped_label_with_escape">"a\\\\c"</string> <string name="multiple_chars">"a,b,c"</string> diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyStylesTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserCsvTests.java index 2ae8027af..721c801e1 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyStylesTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserCsvTests.java @@ -24,7 +24,7 @@ import com.android.inputmethod.latin.tests.R; import java.util.Arrays; -public class KeyStylesTests extends AndroidTestCase { +public class KeySpecParserCsvTests extends AndroidTestCase { private Resources mTestResources; @Override @@ -39,7 +39,7 @@ public class KeyStylesTests extends AndroidTestCase { } private void assertTextArray(String message, String value, String ... expected) { - final String actual[] = KeyStyles.parseCsvString(value, mTestResources, + final String actual[] = KeySpecParser.parseCsvString(value, mTestResources, R.string.empty_string); if (expected.length == 0) { assertNull(message, actual); @@ -63,65 +63,114 @@ public class KeyStylesTests extends AndroidTestCase { } } + // \U001d11e: MUSICAL SYMBOL G CLEF + private static final String PAIR1 = "\ud834\udd1e"; + // \U001d122: MUSICAL SYMBOL F CLEF + private static final String PAIR2 = "\ud834\udd22"; + // \U002f8a6: CJK COMPATIBILITY IDEOGRAPH-2F8A6; variant character of \u6148. + private static final String PAIR3 = "\ud87e\udca6"; + private static final String SURROGATE1 = PAIR1 + PAIR2; + private static final String SURROGATE2 = PAIR1 + PAIR2 + PAIR3; + public void testParseCsvTextZero() { assertTextArray("Empty string", ""); } public void testParseCsvTextSingle() { assertTextArray("Single char", "a", "a"); + assertTextArray("Surrogate pair", PAIR1, PAIR1); + assertTextArray("Single escape", "\\", "\\"); assertTextArray("Space", " ", " "); assertTextArray("Single label", "abc", "abc"); + assertTextArray("Single srrogate pairs label", SURROGATE2, SURROGATE2); assertTextArray("Spaces", " ", " "); assertTextArray("Spaces in label", "a b c", "a b c"); assertTextArray("Spaces at beginning of label", " abc", " abc"); assertTextArray("Spaces at end of label", "abc ", "abc "); assertTextArray("Label surrounded by spaces", " abc ", " abc "); + assertTextArray("Surrogate pair surrounded by space", + " " + PAIR1 + " ", + " " + PAIR1 + " "); + assertTextArray("Surrogate pair within characters", + "ab" + PAIR2 + "cd", + "ab" + PAIR2 + "cd"); + assertTextArray("Surrogate pairs within characters", + "ab" + SURROGATE1 + "cd", + "ab" + SURROGATE1 + "cd"); assertTextArray("Incomplete resource reference 1", "string", "string"); - assertTextArray("Incomplete resource reference 2", "@strin", "@strin"); + assertTextArray("Incomplete resource reference 2", "@string", "@string"); + assertTextArray("Incomplete resource reference 3", "string/", "string/"); + assertTextArray("Incomplete resource reference 4", "@" + SURROGATE2, "@" + SURROGATE2); } public void testParseCsvTextSingleEscaped() { - assertTextArray("Escaped char", "\\a", "a"); - assertTextArray("Escaped comma", "\\,", ","); - assertTextArray("Escaped escape", "\\\\", "\\"); - assertTextArray("Escaped label", "a\\bc", "abc"); - assertTextArray("Escaped label at beginning", "\\abc", "abc"); - assertTextArray("Escaped label with comma", "a\\,c", "a,c"); - assertTextArray("Escaped label with comma at beginning", "\\,bc", ",bc"); - assertTextArray("Escaped label with successive", "\\,\\\\bc", ",\\bc"); - assertTextArray("Escaped label with escape", "a\\\\c", "a\\c"); + assertTextArray("Escaped char", "\\a", "\\a"); + assertTextArray("Escaped surrogate pair", "\\" + PAIR1, "\\" + PAIR1); + assertTextArray("Escaped comma", "\\,", "\\,"); + assertTextArray("Escaped comma escape", "a\\,\\", "a\\,\\"); + assertTextArray("Escaped escape", "\\\\", "\\\\"); + assertTextArray("Escaped label", "a\\bc", "a\\bc"); + assertTextArray("Escaped surrogate", "a\\" + PAIR1 + "c", "a\\" + PAIR1 + "c"); + assertTextArray("Escaped label at beginning", "\\abc", "\\abc"); + assertTextArray("Escaped surrogate at beginning", "\\" + SURROGATE2, "\\" + SURROGATE2); + assertTextArray("Escaped label at end", "abc\\", "abc\\"); + assertTextArray("Escaped surrogate at end", SURROGATE2 + "\\", SURROGATE2 + "\\"); + assertTextArray("Escaped label with comma", "a\\,c", "a\\,c"); + assertTextArray("Escaped surrogate with comma", + PAIR1 + "\\," + PAIR2, PAIR1 + "\\," + PAIR2); + assertTextArray("Escaped label with comma at beginning", "\\,bc", "\\,bc"); + assertTextArray("Escaped surrogate with comma at beginning", + "\\," + SURROGATE1, "\\," + SURROGATE1); + assertTextArray("Escaped label with comma at end", "ab\\,", "ab\\,"); + assertTextArray("Escaped surrogate with comma at end", + SURROGATE2 + "\\,", SURROGATE2 + "\\,"); + assertTextArray("Escaped label with successive", "\\,\\\\bc", "\\,\\\\bc"); + assertTextArray("Escaped surrogate with successive", + "\\,\\\\" + SURROGATE1, "\\,\\\\" + SURROGATE1); + assertTextArray("Escaped label with escape", "a\\\\c", "a\\\\c"); + assertTextArray("Escaped surrogate with escape", + PAIR1 + "\\\\" + PAIR2, PAIR1 + "\\\\" + PAIR2); - assertTextArray("Escaped @string", "\\@string/empty_string", "@string/empty_string"); + assertTextArray("Escaped @string", "\\@string", "\\@string"); + assertTextArray("Escaped @string/", "\\@string/", "\\@string/"); + assertTextArray("Escaped @string/", "\\@string/empty_string", "\\@string/empty_string"); } public void testParseCsvTextMulti() { assertTextArray("Multiple chars", "a,b,c", "a", "b", "c"); + assertTextArray("Multiple chars", "a,b,\\c", "a", "b", "\\c"); + assertTextArray("Multiple chars and escape at beginning and end", + "\\a,b,\\c\\", "\\a", "b", "\\c\\"); + assertTextArray("Multiple surrogates", PAIR1 + "," + PAIR2 + "," + PAIR3, + PAIR1, PAIR2, PAIR3); assertTextArray("Multiple chars surrounded by spaces", " a , b , c ", " a ", " b ", " c "); assertTextArray("Multiple labels", "abc,def,ghi", "abc", "def", "ghi"); + assertTextArray("Multiple surrogated", SURROGATE1 + "," + SURROGATE2, + SURROGATE1, SURROGATE2); assertTextArray("Multiple labels surrounded by spaces", " abc , def , ghi ", " abc ", " def ", " ghi "); } public void testParseCsvTextMultiEscaped() { - assertTextArray("Multiple chars with comma", "a,\\,,c", "a", ",", "c"); + assertTextArray("Multiple chars with comma", "a,\\,,c", "a", "\\,", "c"); assertTextArray("Multiple chars with comma surrounded by spaces", " a , \\, , c ", - " a ", " , ", " c "); - assertTextArray("Multiple labels with escape", "\\abc,d\\ef,gh\\i", "abc", "def", "ghi"); + " a ", " \\, ", " c "); + assertTextArray("Multiple labels with escape", + "\\abc,d\\ef,gh\\i", "\\abc", "d\\ef", "gh\\i"); assertTextArray("Multiple labels with escape surrounded by spaces", - " \\abc , d\\ef , gh\\i ", " abc ", " def ", " ghi "); + " \\abc , d\\ef , gh\\i ", " \\abc ", " d\\ef ", " gh\\i "); assertTextArray("Multiple labels with comma and escape", - "ab\\\\,d\\\\\\,,g\\,i", "ab\\", "d\\,", "g,i"); + "ab\\\\,d\\\\\\,,g\\,i", "ab\\\\", "d\\\\\\,", "g\\,i"); assertTextArray("Multiple labels with comma and escape surrounded by spaces", - " ab\\\\ , d\\\\\\, , g\\,i ", " ab\\ ", " d\\, ", " g,i "); + " ab\\\\ , d\\\\\\, , g\\,i ", " ab\\\\ ", " d\\\\\\, ", " g\\,i "); assertTextArray("Multiple escaped @string", "\\@,\\@string/empty_string", - "@", "@string/empty_string"); + "\\@", "\\@string/empty_string"); } public void testParseCsvResourceError() { - assertError("Incomplete resource name 1", "@string", "@string"); - assertError("Incomplete resource name 2", "@string/", "@string/"); + assertError("Incomplete resource name", "@string/", "@string/"); assertError("Non existing resource", "@string/non_existing"); } @@ -147,27 +196,36 @@ public class KeyStylesTests extends AndroidTestCase { "@string/spaces_at_end_of_label", "abc "); assertTextArray("label surrounded by spaces", "@string/label_surrounded_by_spaces", " abc "); + + assertTextArray("Escape and single char", + "\\\\@string/single_char", "\\\\a"); } public void testParseCsvResourceSingleEscaped() { assertTextArray("Escaped char", - "@string/escaped_char", "a"); + "@string/escaped_char", "\\a"); assertTextArray("Escaped comma", - "@string/escaped_comma", ","); + "@string/escaped_comma", "\\,"); + assertTextArray("Escaped comma escape", + "@string/escaped_comma_escape", "a\\,\\"); assertTextArray("Escaped escape", - "@string/escaped_escape", "\\"); + "@string/escaped_escape", "\\\\"); assertTextArray("Escaped label", - "@string/escaped_label", "abc"); + "@string/escaped_label", "a\\bc"); assertTextArray("Escaped label at beginning", - "@string/escaped_label_at_beginning", "abc"); + "@string/escaped_label_at_beginning", "\\abc"); + assertTextArray("Escaped label at end", + "@string/escaped_label_at_end", "abc\\"); assertTextArray("Escaped label with comma", - "@string/escaped_label_with_comma", "a,c"); + "@string/escaped_label_with_comma", "a\\,c"); assertTextArray("Escaped label with comma at beginning", - "@string/escaped_label_with_comma_at_beginning", ",bc"); + "@string/escaped_label_with_comma_at_beginning", "\\,bc"); + assertTextArray("Escaped label with comma at end", + "@string/escaped_label_with_comma_at_end", "ab\\,"); assertTextArray("Escaped label with successive", - "@string/escaped_label_with_successive", ",\\bc"); + "@string/escaped_label_with_successive", "\\,\\\\bc"); assertTextArray("Escaped label with escape", - "@string/escaped_label_with_escape", "a\\c"); + "@string/escaped_label_with_escape", "a\\\\c"); } public void testParseCsvResourceMulti() { @@ -185,36 +243,41 @@ public class KeyStylesTests extends AndroidTestCase { public void testParseCsvResourcetMultiEscaped() { assertTextArray("Multiple chars with comma", "@string/multiple_chars_with_comma", - "a", ",", "c"); + "a", "\\,", "c"); assertTextArray("Multiple chars with comma surrounded by spaces", "@string/multiple_chars_with_comma_surrounded_by_spaces", - " a ", " , ", " c "); + " a ", " \\, ", " c "); assertTextArray("Multiple labels with escape", "@string/multiple_labels_with_escape", - "abc", "def", "ghi"); + "\\abc", "d\\ef", "gh\\i"); assertTextArray("Multiple labels with escape surrounded by spaces", "@string/multiple_labels_with_escape_surrounded_by_spaces", - " abc ", " def ", " ghi "); + " \\abc ", " d\\ef ", " gh\\i "); assertTextArray("Multiple labels with comma and escape", "@string/multiple_labels_with_comma_and_escape", - "ab\\", "d\\,", "g,i"); + "ab\\\\", "d\\\\\\,", "g\\,i"); assertTextArray("Multiple labels with comma and escape surrounded by spaces", "@string/multiple_labels_with_comma_and_escape_surrounded_by_spaces", - " ab\\ ", " d\\, ", " g,i "); + " ab\\\\ ", " d\\\\\\, ", " g\\,i "); } public void testParseMultipleResources() { assertTextArray("Literals and resources", "1,@string/multiple_chars,z", "1", "a", "b", "c", "z"); + assertTextArray("Literals and resources and escape at end", + "\\1,@string/multiple_chars,z\\", "\\1", "a", "b", "c", "z\\"); assertTextArray("Multiple single resource chars and labels", "@string/single_char,@string/single_label,@string/escaped_comma", - "a", "abc", ","); + "a", "abc", "\\,"); + assertTextArray("Multiple single resource chars and labels 2", + "@string/single_char,@string/single_label,@string/escaped_comma_escape", + "a", "abc", "a\\,\\"); assertTextArray("Multiple multiple resource chars and labels", "@string/multiple_chars,@string/multiple_labels,@string/multiple_chars_with_comma", - "a", "b", "c", "abc", "def", "ghi", "a", ",", "c"); + "a", "b", "c", "abc", "def", "ghi", "a", "\\,", "c"); assertTextArray("Concatenated resources", "@string/multiple_chars@string/multiple_labels@string/multiple_chars_with_comma", - "a", "b", "cabc", "def", "ghia", ",", "c"); + "a", "b", "cabc", "def", "ghia", "\\,", "c"); assertTextArray("Concatenated resource and literal", "abc@string/multiple_labels", "abcabc", "def", "ghi"); diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParserTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java index bc38cc16c..d27c55cdd 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecParserTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java @@ -24,7 +24,7 @@ import com.android.inputmethod.latin.R; import java.util.Arrays; -public class MoreKeySpecParserTests extends AndroidTestCase { +public class KeySpecParserTests extends AndroidTestCase { private Resources mRes; private static final int ICON_SETTINGS_KEY = R.styleable.Keyboard_iconSettingsKey; @@ -49,16 +49,16 @@ public class MoreKeySpecParserTests extends AndroidTestCase { private void assertParser(String message, String moreKeySpec, String expectedLabel, String expectedOutputText, int expectedIcon, int expectedCode) { - String actualLabel = MoreKeySpecParser.getLabel(moreKeySpec); + String actualLabel = KeySpecParser.getLabel(moreKeySpec); assertEquals(message + ": label:", expectedLabel, actualLabel); - String actualOutputText = MoreKeySpecParser.getOutputText(moreKeySpec); + String actualOutputText = KeySpecParser.getOutputText(moreKeySpec); assertEquals(message + ": ouptputText:", expectedOutputText, actualOutputText); - int actualIcon = MoreKeySpecParser.getIconAttrId(moreKeySpec); + int actualIcon = KeySpecParser.getIconAttrId(moreKeySpec); assertEquals(message + ": icon:", expectedIcon, actualIcon); - int actualCode = MoreKeySpecParser.getCode(mRes, moreKeySpec); + int actualCode = KeySpecParser.getCode(mRes, moreKeySpec); assertEquals(message + ": codes value:", expectedCode, actualCode); } @@ -73,9 +73,22 @@ public class MoreKeySpecParserTests extends AndroidTestCase { } } + // \U001d11e: MUSICAL SYMBOL G CLEF + private static final String PAIR1 = "\ud834\udd1e"; + private static final int CODE1 = PAIR1.codePointAt(0); + // \U001d122: MUSICAL SYMBOL F CLEF + private static final String PAIR2 = "\ud834\udd22"; + private static final int CODE2 = PAIR2.codePointAt(0); + // \U002f8a6: CJK COMPATIBILITY IDEOGRAPH-2F8A6; variant character of \u6148. + private static final String PAIR3 = "\ud87e\udca6"; + private static final String SURROGATE1 = PAIR1 + PAIR2; + private static final String SURROGATE2 = PAIR1 + PAIR2 + PAIR3; + public void testSingleLetter() { assertParser("Single letter", "a", "a", null, ICON_UNDEFINED, 'a'); + assertParser("Single surrogate", PAIR1, + PAIR1, null, ICON_UNDEFINED, CODE1); assertParser("Single escaped bar", "\\|", "|", null, ICON_UNDEFINED, '|'); assertParser("Single escaped escape", "\\\\", @@ -86,20 +99,31 @@ public class MoreKeySpecParserTests extends AndroidTestCase { ",", null, ICON_UNDEFINED, ','); assertParser("Single escaped letter", "\\a", "a", null, ICON_UNDEFINED, 'a'); + assertParser("Single escaped surrogate", "\\" + PAIR2, + PAIR2, null, ICON_UNDEFINED, CODE2); assertParser("Single at", "@", "@", null, ICON_UNDEFINED, '@'); assertParser("Single escaped at", "\\@", "@", null, ICON_UNDEFINED, '@'); assertParser("Single letter with outputText", "a|abc", "a", "abc", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); + assertParser("Single letter with surrogate outputText", "a|" + SURROGATE1, + "a", SURROGATE1, ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); + assertParser("Single surrogate with outputText", PAIR3 + "|abc", + PAIR3, "abc", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Single letter with escaped outputText", "a|a\\|c", "a", "a|c", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); + assertParser("Single letter with escaped surrogate outputText", + "a|" + PAIR1 + "\\|" + PAIR2, + "a", PAIR1 + "|" + PAIR2, ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Single letter with comma outputText", "a|a,b", "a", "a,b", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Single letter with escaped comma outputText", "a|a\\,b", "a", "a,b", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Single letter with outputText starts with at", "a|@bc", "a", "@bc", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); + assertParser("Single letter with surrogate outputText starts with at", "a|@" + SURROGATE2, + "a", "@" + SURROGATE2, ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Single letter with outputText contains at", "a|a@c", "a", "a@c", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Single letter with escaped at outputText", "a|\\@bc", @@ -115,8 +139,13 @@ public class MoreKeySpecParserTests extends AndroidTestCase { public void testLabel() { assertParser("Simple label", "abc", "abc", "abc", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); + assertParser("Simple surrogate label", SURROGATE1, + SURROGATE1, SURROGATE1, ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Label with escaped bar", "a\\|c", "a|c", "a|c", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); + assertParser("Surrogate label with escaped bar", PAIR1 + "\\|" + PAIR2, + PAIR1 + "|" + PAIR2, PAIR1 + "|" + PAIR2, + ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Label with escaped escape", "a\\\\c", "a\\c", "a\\c", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Label with comma", "a,c", @@ -125,6 +154,8 @@ public class MoreKeySpecParserTests extends AndroidTestCase { "a,c", "a,c", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Label starts with at", "@bc", "@bc", "@bc", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); + assertParser("Surrogate label starts with at", "@" + SURROGATE1, + "@" + SURROGATE1, "@" + SURROGATE1, ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Label contains at", "a@c", "a@c", "a@c", ICON_UNDEFINED, Keyboard.CODE_OUTPUT_TEXT); assertParser("Label with escaped at", "\\@bc", @@ -220,9 +251,9 @@ public class MoreKeySpecParserTests extends AndroidTestCase { null, null, ICON_SETTINGS_KEY, mCodeSettings); } - private void assertMoreKeys(String message, String[] moreKeys, String[] additionalMoreKeys, - String[] expected) { - final String[] actual = MoreKeySpecParser.insertAddtionalMoreKeys( + private static void assertMoreKeys(String message, String[] moreKeys, + String[] additionalMoreKeys, String[] expected) { + final String[] actual = KeySpecParser.insertAddtionalMoreKeys( moreKeys, additionalMoreKeys); if (expected == null && actual == null) { return; diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java index c6893847f..e9f37afee 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java @@ -37,7 +37,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { // Chording input in shift locked. public void testChordingShiftLocked() { // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press shift key and hold, enter into choring shift state. pressKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED); @@ -95,7 +95,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { // Load keyboard loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Press "ABC" key, enter into chording alphabet shift locked. @@ -112,7 +112,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { // Load keyboard loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Press "=\<" key, enter into symbols shifted chording state. @@ -170,7 +170,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { // Load keyboard loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Press/release "=\<" key, enter symbols shifted. @@ -189,7 +189,7 @@ public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { // Load keyboard loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Press/release "=\<" key, enter symbols shifted. diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java index 55147f613..8c53fb5c8 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java @@ -88,7 +88,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Switching between alphabet shift locked and symbols. public void testAlphabetShiftLockedAndSymbols() { // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); @@ -127,7 +127,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Automatic switch back to alphabet shift locked test by space key. public void testSwitchBackBySpaceShiftLocked() { // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); @@ -179,7 +179,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { setLayoutSwitchBackSymbols(switchBackSymbols); loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); @@ -235,24 +235,45 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { } // Long press shift key. - // TODO: Move long press recognizing timer/logic into KeyboardState. public void testLongPressShift() { + // Set auto caps mode off. + setAutoCapsMode(NO_AUTO_CAPS); + // Load keyboard, should be in alphabet. + loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + // Press/release shift key, back to alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release letter key, remain in shift locked. pressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); // Press/release word separator, remain in shift locked. pressAndReleaseKey(CODE_SPACE, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); - // Press/release shift key, back to alphabet. pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); - + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Long press shift key, back to alphabet. - longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + // Press/release shift key, back to alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + + // Set auto caps mode on. + setAutoCapsMode(AUTO_CAPS); + // Load keyboard, should be in automatic shifted. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + // Press/release shift key, back to alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); } // Double tap shift key. @@ -311,11 +332,11 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { updateShiftState(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Update shift state, remained in alphabet shift locked. updateShiftState(ALPHABET_SHIFT_LOCKED); // Long press shift key, back to alphabet. - longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); @@ -342,11 +363,11 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { updateShiftState(ALPHABET_AUTOMATIC_SHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Update shift state, remained in alphabet shift locked (not automatic shifted). updateShiftState(ALPHABET_SHIFT_LOCKED); // Long press shift key, back to alphabet. - longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); // Load keyboard, should be in automatic shifted. loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); @@ -393,7 +414,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Alphabet shift locked -> shift key + letter -> alphabet shift locked. // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press and slide from "123?" key, enter symbols. pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Enter/release into symbol letter key, switch back to alphabet shift locked. @@ -444,7 +465,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Load keyboard loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Press and slide from "ABC" key, enter alphabet shift locked. @@ -459,7 +480,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Load keyboard loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Press and slide from "=\<" key, enter symbols shifted. @@ -512,7 +533,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Load keyboard loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Press/release "=\<" key, enter into symbols shifted. @@ -529,7 +550,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Load keyboard loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Press/release "?123" key, enter into symbols. pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); // Press/release "=\<" key, enter into symbols shifted. @@ -550,7 +571,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { loadKeyboard(ALPHABET_UNSHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Change focus to new text field. loadKeyboard(ALPHABET_UNSHIFTED); @@ -583,7 +604,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Change focus to new text field. loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); @@ -615,7 +636,7 @@ public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { // Alphabet shift locked -> rotate -> alphabet shift locked. // Long press shift key, enter alphabet shift locked. - longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); + longPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_SHIFT_LOCKED); // Rotate device, remain in alphabet shift locked. rotateDevice(ALPHABET_SHIFT_LOCKED); diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTestsBase.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTestsBase.java index 76b84364c..96a54668c 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTestsBase.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardStateTestsBase.java @@ -106,15 +106,11 @@ public class KeyboardStateTestsBase extends AndroidTestCase assertLayout(afterSlide, mSwitcher.getLayoutId()); } - public void longPressShiftKey(int afterPress, int afterLongPress) { - // Long press shift key - mSwitcher.onPressKey(CODE_SHIFT); - assertLayout(afterPress, mSwitcher.getLayoutId()); - // Long press recognized in LatinKeyboardView.KeyTimerHandler. - mSwitcher.onCodeInput(CODE_CAPSLOCK, SINGLE); - assertLayout(afterLongPress, mSwitcher.getLayoutId()); - mSwitcher.onReleaseKey(CODE_SHIFT, NOT_SLIDING); + public void longPressAndReleaseKey(int code, int afterPress, int afterLongPress) { + pressKey(code, afterPress); + mSwitcher.onLongPressTimeout(code); assertLayout(afterLongPress, mSwitcher.getLayoutId()); + releaseKey(code, afterLongPress); } public void secondPressAndReleaseKey(int code, int afterPress, int afterRelease) { diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java index 2f39340c9..a01b69cc1 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java @@ -31,7 +31,6 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { public static final int CODE_SHIFT = Keyboard.CODE_SHIFT; public static final int CODE_SYMBOL = Keyboard.CODE_SWITCH_ALPHA_SYMBOL; - public static final int CODE_CAPSLOCK = Keyboard.CODE_CAPSLOCK; public static final int CODE_SPACE = Keyboard.CODE_SPACE; public static final int CODE_AUTO_CAPS_TRIGGER = Keyboard.CODE_SPACE; @@ -51,6 +50,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { private boolean mAutoCapsState = true; private boolean mIsInDoubleTapTimeout; + private int mLongPressTimeoutCode; private final KeyboardState mState = new KeyboardState(this); @@ -129,6 +129,24 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { return mIsInDoubleTapTimeout; } + @Override + public void startLongPressTimer(int code) { + mLongPressTimeoutCode = code; + } + + @Override + public void hapticAndAudioFeedback(int code) { + // Nothing to do. + } + + public void onLongPressTimeout(int code) { + // TODO: Handle simultaneous long presses. + if (mLongPressTimeoutCode == code) { + mLongPressTimeoutCode = 0; + mState.onLongPressTimeout(code); + } + } + public void updateShiftState() { mState.onUpdateShiftState(mAutoCapsMode && mAutoCapsState); } @@ -147,6 +165,9 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { public void onReleaseKey(int code, boolean withSliding) { mState.onReleaseKey(code, withSliding); + if (mLongPressTimeoutCode == code) { + mLongPressTimeoutCode = 0; + } } public void onCodeInput(int code, boolean isSinglePointer) { diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index 6dfa80904..8c0ccd40b 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -218,4 +218,77 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> { assertEquals("auto correct then move curor then backspace", EXPECTED_RESULT, mTextView.getText().toString()); } + + public void testNoSpaceAfterManualPick() { + final String WORD_TO_TYPE = "this"; + final String EXPECTED_RESULT = WORD_TO_TYPE; + type(WORD_TO_TYPE); + mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE); + assertEquals("no space after manual pick", EXPECTED_RESULT, + mTextView.getText().toString()); + } + + public void testManualPickThenType() { + final String WORD1_TO_TYPE = "this"; + final String WORD2_TO_TYPE = "is"; + final String EXPECTED_RESULT = "this is"; + type(WORD1_TO_TYPE); + mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); + type(WORD2_TO_TYPE); + assertEquals("manual pick then type", EXPECTED_RESULT, mTextView.getText().toString()); + } + + public void testManualPickThenSeparator() { + final String WORD1_TO_TYPE = "this"; + final String WORD2_TO_TYPE = "!"; + final String EXPECTED_RESULT = "this!"; + type(WORD1_TO_TYPE); + mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); + type(WORD2_TO_TYPE); + assertEquals("manual pick then separator", EXPECTED_RESULT, mTextView.getText().toString()); + } + + public void testWordThenSpaceThenPunctuationFromStripTwice() { + final String WORD_TO_TYPE = "this "; + final String PUNCTUATION_FROM_STRIP = "!"; + final String EXPECTED_RESULT = "this!! "; + type(WORD_TO_TYPE); + mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); + mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); + assertEquals("type word then type space then punctuation from strip twice", EXPECTED_RESULT, + mTextView.getText().toString()); + } + + public void testWordThenSpaceThenPunctuationFromKeyboardTwice() { + final String WORD_TO_TYPE = "this !!"; + final String EXPECTED_RESULT = "this !!"; + type(WORD_TO_TYPE); + assertEquals("manual pick then space then punctuation from keyboard twice", EXPECTED_RESULT, + mTextView.getText().toString()); + } + + public void testManualPickThenPunctuationFromStripTwiceThenType() { + final String WORD1_TO_TYPE = "this"; + final String WORD2_TO_TYPE = "is"; + final String PUNCTUATION_FROM_STRIP = "!"; + final String EXPECTED_RESULT = "this!! is"; + type(WORD1_TO_TYPE); + mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); + mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); + mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); + type(WORD2_TO_TYPE); + assertEquals("pick word then pick punctuation twice then type", EXPECTED_RESULT, + mTextView.getText().toString()); + } + + public void testManualPickThenSpaceThenType() { + final String WORD1_TO_TYPE = "this"; + final String WORD2_TO_TYPE = " is"; + final String EXPECTED_RESULT = "this is"; + type(WORD1_TO_TYPE); + mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE); + type(WORD2_TO_TYPE); + assertEquals("manual pick then space then type", WORD1_TO_TYPE + WORD2_TO_TYPE, + mTextView.getText().toString()); + } } |