From 8108a3e1cdceb1874804f74ec24d824a7df1b669 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 26 Sep 2014 02:28:21 +0900 Subject: [PATCH] Add Serbian Latin keyboard Bug: 9687668 Change-Id: I0631ab04cf33e3d454c965e98a756c31666537bf --- java/res/values/donottranslate.xml | 2 + java/res/values/strings.xml | 14 +- java/res/xml-sw600dp/rows_serbian_qwertz.xml | 43 +++++ java/res/xml/kbd_serbian_qwertz.xml | 23 +++ .../keyboard_layout_set_serbian_qwertz.xml | 42 +++++ java/res/xml/method.xml | 20 +-- java/res/xml/rowkeys_serbian_qwertz1.xml | 25 +++ java/res/xml/rowkeys_serbian_qwertz2.xml | 27 +++ java/res/xml/rowkeys_serbian_qwertz3.xml | 27 +++ java/res/xml/rows_serbian_qwertz.xml | 39 +++++ .../keyboard/internal/KeyboardTextsTable.java | 163 ++++++++++++------ .../keyboard/internal/MoreKeySpec.java | 9 +- .../KeyboardLayoutSetSubtypesCountTests.java | 4 +- .../keyboard/action/KlpActionLabelTests.java | 13 ++ .../keyboard/layout/LayoutBase.java | 2 +- .../keyboard/layout/SerbianQwertz.java | 57 ++++++ .../layout/tests/SerbianLatinCustomizer.java | 82 +++++++++ .../layout/tests/TestsSerbianLatin.java | 36 ++++ .../layout/tests/TestsSerbianLatinQwerty.java | 88 ++++++++++ .../donottranslate-more-keys.xml | 42 +++++ 20 files changed, 675 insertions(+), 83 deletions(-) create mode 100644 java/res/xml-sw600dp/rows_serbian_qwertz.xml create mode 100644 java/res/xml/kbd_serbian_qwertz.xml create mode 100644 java/res/xml/keyboard_layout_set_serbian_qwertz.xml create mode 100644 java/res/xml/rowkeys_serbian_qwertz1.xml create mode 100644 java/res/xml/rowkeys_serbian_qwertz2.xml create mode 100644 java/res/xml/rowkeys_serbian_qwertz3.xml create mode 100644 java/res/xml/rows_serbian_qwertz.xml create mode 100644 tests/src/com/android/inputmethod/keyboard/layout/SerbianQwertz.java create mode 100644 tests/src/com/android/inputmethod/keyboard/layout/tests/SerbianLatinCustomizer.java create mode 100644 tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbianLatin.java create mode 100644 tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbianLatinQwerty.java create mode 100644 tools/make-keyboard-text/res/values-sr-rZZ/donottranslate-more-keys.xml diff --git a/java/res/values/donottranslate.xml b/java/res/values/donottranslate.xml index 74988f90f..959fe833b 100644 --- a/java/res/values/donottranslate.xml +++ b/java/res/values/donottranslate.xml @@ -31,11 +31,13 @@ en_GB es_US hi_ZZ + sr_ZZ hi_ZZ + sr_ZZ diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index d64444e01..76da5ce3d 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -207,6 +207,10 @@ Spanish (US) Hinglish + + Serbian (Latin) @@ -222,6 +226,10 @@ Hinglish (%s) + + Serbian (%s) %s (Traditional) @@ -229,12 +237,6 @@ (Compact) can be an abbreviation to fit in the CHAR LIMIT. TODO: Remove translatable=false once we are settled down with the naming. --> %s (Compact) - - %s (Cyrillic) - - %s (Latin) + + + + + + + + + + + + + + + + + + diff --git a/java/res/xml/kbd_serbian_qwertz.xml b/java/res/xml/kbd_serbian_qwertz.xml new file mode 100644 index 000000000..4f763b861 --- /dev/null +++ b/java/res/xml/kbd_serbian_qwertz.xml @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/java/res/xml/keyboard_layout_set_serbian_qwertz.xml b/java/res/xml/keyboard_layout_set_serbian_qwertz.xml new file mode 100644 index 000000000..2c7e28b50 --- /dev/null +++ b/java/res/xml/keyboard_layout_set_serbian_qwertz.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index 74ac79f59..270f90cb8 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -89,7 +89,7 @@ sk: Slovak/qwerty sl: Slovenian/qwerty sr: Serbian/south_slavic - (sr-Latn: Serbian/qwerty) # not yet implemented. + (sr_ZZ: Serbian (Latin)/serbian_qwertz) # This is a preliminary keyboard layout. sv: Swedish/nordic sw: Swahili/qwerty ta_IN: Tamil (India)/tamil @@ -661,24 +661,14 @@ android:imeSubtypeExtraValue="SupportTouchPositionCorrection,EmojiCapable" android:isAsciiCapable="false" /> - + + + + + + + \ No newline at end of file diff --git a/java/res/xml/rowkeys_serbian_qwertz2.xml b/java/res/xml/rowkeys_serbian_qwertz2.xml new file mode 100644 index 000000000..83ec92d29 --- /dev/null +++ b/java/res/xml/rowkeys_serbian_qwertz2.xml @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/java/res/xml/rowkeys_serbian_qwertz3.xml b/java/res/xml/rowkeys_serbian_qwertz3.xml new file mode 100644 index 000000000..30ba7afa2 --- /dev/null +++ b/java/res/xml/rowkeys_serbian_qwertz3.xml @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/java/res/xml/rows_serbian_qwertz.xml b/java/res/xml/rows_serbian_qwertz.xml new file mode 100644 index 000000000..4be2abf1a --- /dev/null +++ b/java/res/xml/rows_serbian_qwertz.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.java index 192011384..846e4968a 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsTable.java @@ -85,19 +85,19 @@ public final class KeyboardTextsTable { // /* index:histogram */ "name", /* 0:32 */ "morekeys_a", /* 1:32 */ "morekeys_o", - /* 2:30 */ "morekeys_e", + /* 2:31 */ "morekeys_e", /* 3:30 */ "morekeys_u", /* 4:30 */ "keylabel_to_alpha", - /* 5:28 */ "morekeys_i", + /* 5:29 */ "morekeys_i", /* 6:24 */ "morekeys_n", - /* 7:23 */ "morekeys_c", + /* 7:24 */ "morekeys_c", /* 8:23 */ "double_quotes", /* 9:22 */ "single_quotes", - /* 10:20 */ "morekeys_s", + /* 10:21 */ "morekeys_s", /* 11:18 */ "keyspec_currency", /* 12:16 */ "morekeys_y", - /* 13:14 */ "morekeys_z", - /* 14:13 */ "morekeys_d", + /* 13:15 */ "morekeys_z", + /* 14:14 */ "morekeys_d", /* 15:10 */ "morekeys_t", /* 16:10 */ "morekeys_l", /* 17: 9 */ "morekeys_g", @@ -193,30 +193,30 @@ public final class KeyboardTextsTable { /* 107: 2 */ "keyspec_symbols_percent", /* 108: 2 */ "morekeys_symbols_semicolon", /* 109: 2 */ "morekeys_symbols_percent", - /* 110: 1 */ "morekeys_v", - /* 111: 1 */ "morekeys_j", - /* 112: 1 */ "morekeys_q", - /* 113: 1 */ "morekeys_x", - /* 114: 1 */ "keyspec_q", - /* 115: 1 */ "keyspec_w", - /* 116: 1 */ "keyspec_y", - /* 117: 1 */ "keyspec_x", - /* 118: 1 */ "morekeys_east_slavic_row2_11", - /* 119: 1 */ "morekeys_cyrillic_ka", - /* 120: 1 */ "morekeys_cyrillic_a", - /* 121: 1 */ "morekeys_currency_dollar", - /* 122: 1 */ "morekeys_plus", - /* 123: 1 */ "morekeys_less_than", - /* 124: 1 */ "morekeys_greater_than", - /* 125: 1 */ "morekeys_exclamation", - /* 126: 1 */ "label_go_key", - /* 127: 1 */ "label_send_key", - /* 128: 1 */ "label_next_key", - /* 129: 1 */ "label_done_key", - /* 130: 1 */ "label_search_key", - /* 131: 1 */ "label_previous_key", - /* 132: 1 */ "label_pause_key", - /* 133: 1 */ "label_wait_key", + /* 110: 2 */ "label_go_key", + /* 111: 2 */ "label_send_key", + /* 112: 2 */ "label_next_key", + /* 113: 2 */ "label_done_key", + /* 114: 2 */ "label_search_key", + /* 115: 2 */ "label_previous_key", + /* 116: 2 */ "label_pause_key", + /* 117: 2 */ "label_wait_key", + /* 118: 1 */ "morekeys_v", + /* 119: 1 */ "morekeys_j", + /* 120: 1 */ "morekeys_q", + /* 121: 1 */ "morekeys_x", + /* 122: 1 */ "keyspec_q", + /* 123: 1 */ "keyspec_w", + /* 124: 1 */ "keyspec_y", + /* 125: 1 */ "keyspec_x", + /* 126: 1 */ "morekeys_east_slavic_row2_11", + /* 127: 1 */ "morekeys_cyrillic_ka", + /* 128: 1 */ "morekeys_cyrillic_a", + /* 129: 1 */ "morekeys_currency_dollar", + /* 130: 1 */ "morekeys_plus", + /* 131: 1 */ "morekeys_less_than", + /* 132: 1 */ "morekeys_greater_than", + /* 133: 1 */ "morekeys_exclamation", /* 134: 0 */ "morekeys_currency_generic", /* 135: 0 */ "morekeys_symbols_1", /* 136: 0 */ "morekeys_symbols_2", @@ -365,6 +365,14 @@ public final class KeyboardTextsTable { /* morekeys_symbols_semicolon */ EMPTY, // U+2030: "‰" PER MILLE SIGN /* morekeys_symbols_percent */ "\u2030", + /* label_go_key */ "!string/label_go_key", + /* label_send_key */ "!string/label_send_key", + /* label_next_key */ "!string/label_next_key", + /* label_done_key */ "!string/label_done_key", + /* label_search_key */ "!string/label_search_key", + /* label_previous_key */ "!string/label_previous_key", + /* label_pause_key */ "!string/label_pause_key", + /* label_wait_key */ "!string/label_wait_key", /* morekeys_v ~ */ EMPTY, EMPTY, EMPTY, EMPTY, /* ~ morekeys_x */ @@ -387,14 +395,6 @@ public final class KeyboardTextsTable { /* morekeys_greater_than */ "!fixedColumnOrder!3,!text/keyspec_right_single_angle_quote,!text/keyspec_greater_than_equal,!text/keyspec_right_double_angle_quote", // U+00A1: "¡" INVERTED EXCLAMATION MARK /* morekeys_exclamation */ "\u00A1", - /* label_go_key */ "!string/label_go_key", - /* label_send_key */ "!string/label_send_key", - /* label_next_key */ "!string/label_next_key", - /* label_done_key */ "!string/label_done_key", - /* label_search_key */ "!string/label_search_key", - /* label_previous_key */ "!string/label_previous_key", - /* label_pause_key */ "!string/label_pause_key", - /* label_wait_key */ "!string/label_wait_key", /* morekeys_currency_generic */ "$,\u00A2,\u20AC,\u00A3,\u00A5,\u20B1", // U+00B9: "¹" SUPERSCRIPT ONE // U+00BD: "½" VULGAR FRACTION ONE HALF @@ -1281,8 +1281,9 @@ public final class KeyboardTextsTable { // U+0135: "ĵ" LATIN SMALL LETTER J WITH CIRCUMFLEX /* keyspec_spanish_row2_10 */ "\u0135", /* morekeys_bullet ~ */ - null, null, null, null, null, null, null, null, null, null, null, null, null, null, - /* ~ morekeys_symbols_percent */ + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, + /* ~ label_wait_key */ // U+0175: "ŵ" LATIN SMALL LETTER W WITH CIRCUMFLEX /* morekeys_v */ "w,\u0175", /* morekeys_j */ null, @@ -1649,8 +1650,9 @@ public final class KeyboardTextsTable { /* morekeys_symbols_semicolon */ ";", // U+2030: "‰" PER MILLE SIGN /* morekeys_symbols_percent */ "\\%,\u2030", - /* morekeys_v ~ */ - null, null, null, null, null, null, null, null, null, null, null, null, null, + /* label_go_key ~ */ + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, /* ~ morekeys_plus */ // U+2264: "≤" LESS-THAN OR EQUAL TO // U+2265: "≥" GREATER-THAN EQUAL TO @@ -1908,9 +1910,8 @@ public final class KeyboardTextsTable { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, - /* ~ morekeys_exclamation */ + null, null, null, null, null, null, null, null, + /* ~ morekeys_symbols_percent */ /* label_go_key */ "Go", /* label_send_key */ "Send", /* label_next_key */ "Next", @@ -2063,7 +2064,7 @@ public final class KeyboardTextsTable { /* keyspec_tablet_period */ "\u0589", /* keyhintlabel_tablet_period ~ */ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, /* ~ morekeys_greater_than */ // U+055C: "՜" ARMENIAN EXCLAMATION MARK // U+00A1: "¡" INVERTED EXCLAMATION MARK @@ -2244,6 +2245,7 @@ public final class KeyboardTextsTable { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, /* ~ morekeys_currency_dollar */ // U+00B1: "±" PLUS-MINUS SIGN // U+FB29: "﬩" HEBREW LETTER ALTERNATIVE PLUS SIGN @@ -2315,7 +2317,8 @@ public final class KeyboardTextsTable { /* morekeys_cyrillic_o */ "\u04E9", /* morekeys_cyrillic_i ~ */ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, /* ~ keyspec_x */ // U+04BB: "һ" CYRILLIC SMALL LETTER SHHA /* morekeys_east_slavic_row2_11 */ "\u04BB", @@ -2343,7 +2346,8 @@ public final class KeyboardTextsTable { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, /* ~ morekeys_cyrillic_a */ // U+17DB: "៛" KHMER CURRENCY SYMBOL RIEL /* morekeys_currency_dollar */ "\u17DB,\u00A2,\u00A3,\u20AC,\u00A5,\u20B1", @@ -3332,6 +3336,49 @@ public final class KeyboardTextsTable { /* keyspec_south_slavic_row3_8 */ "\u0452", }; + /* Locale sr_ZZ: Serbian (ZZ) */ + private static final String[] TEXTS_sr_ZZ = { + /* morekeys_a */ null, + /* morekeys_o */ null, + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + /* morekeys_e */ "\u00E8", + /* morekeys_u */ null, + /* keylabel_to_alpha */ null, + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + /* morekeys_i */ "\u00EC", + /* morekeys_n */ null, + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + /* morekeys_c */ "\u010D,\u0107,%", + /* double_quotes */ null, + /* single_quotes */ null, + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + /* morekeys_s */ "\u0161,%", + /* keyspec_currency */ null, + /* morekeys_y */ null, + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + /* morekeys_z */ "\u017E,%", + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + /* morekeys_d */ "\u0111,%", + /* morekeys_t ~ */ + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, + /* ~ morekeys_symbols_percent */ + /* label_go_key */ "Idi", + /* label_send_key */ "\u0160alji", + /* label_next_key */ "Sled", + /* label_done_key */ "Gotov", + /* label_search_key */ "Tra\u017Ei", + /* label_previous_key */ "Preth", + /* label_pause_key */ "Pauza", + /* label_wait_key */ "\u010Cekaj", + }; + /* Locale sv: Swedish */ private static final String[] TEXTS_sv = { // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE @@ -3978,7 +4025,8 @@ public final class KeyboardTextsTable { /* morekeys_w */ "\u0175", /* morekeys_east_slavic_row2_2 ~ */ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, /* ~ morekeys_v */ // U+0135: "ĵ" LATIN SMALL LETTER J WITH CIRCUMFLEX /* morekeys_j */ "\u0135", @@ -3999,25 +4047,25 @@ public final class KeyboardTextsTable { "de" , TEXTS_de, /* 16/ 62 German */ "el" , TEXTS_el, /* 1/ 5 Greek */ "en" , TEXTS_en, /* 8/ 11 English */ - "eo" , TEXTS_eo, /* 26/118 Esperanto */ + "eo" , TEXTS_eo, /* 26/126 Esperanto */ "es" , TEXTS_es, /* 8/ 55 Spanish */ "et_EE" , TEXTS_et_EE, /* 22/ 27 Estonian (Estonia) */ "eu_ES" , TEXTS_eu_ES, /* 7/ 8 Basque (Spain) */ - "fa" , TEXTS_fa, /* 58/125 Persian */ + "fa" , TEXTS_fa, /* 58/133 Persian */ "fi" , TEXTS_fi, /* 10/ 54 Finnish */ "fr" , TEXTS_fr, /* 13/ 62 French */ "gl_ES" , TEXTS_gl_ES, /* 7/ 8 Gallegan (Spain) */ "hi" , TEXTS_hi, /* 23/ 53 Hindi */ - "hi_ZZ" , TEXTS_hi_ZZ, /* 9/134 Hindi (ZZ) */ + "hi_ZZ" , TEXTS_hi_ZZ, /* 9/118 Hindi (ZZ) */ "hr" , TEXTS_hr, /* 9/ 20 Croatian */ "hu" , TEXTS_hu, /* 9/ 20 Hungarian */ - "hy_AM" , TEXTS_hy_AM, /* 9/126 Armenian (Armenia) */ + "hy_AM" , TEXTS_hy_AM, /* 9/134 Armenian (Armenia) */ "is" , TEXTS_is, /* 10/ 16 Icelandic */ "it" , TEXTS_it, /* 11/ 62 Italian */ - "iw" , TEXTS_iw, /* 20/123 Hebrew */ + "iw" , TEXTS_iw, /* 20/131 Hebrew */ "ka_GE" , TEXTS_ka_GE, /* 3/ 10 Georgian (Georgia) */ - "kk" , TEXTS_kk, /* 15/121 Kazakh */ - "km_KH" , TEXTS_km_KH, /* 2/122 Khmer (Cambodia) */ + "kk" , TEXTS_kk, /* 15/129 Kazakh */ + "km_KH" , TEXTS_km_KH, /* 2/130 Khmer (Cambodia) */ "kn_IN" , TEXTS_kn_IN, /* 2/ 12 Kannada (India) */ "ky" , TEXTS_ky, /* 10/ 89 Kirghiz */ "lo_LA" , TEXTS_lo_LA, /* 2/ 12 Lao (Laos) */ @@ -4040,6 +4088,7 @@ public final class KeyboardTextsTable { "sk" , TEXTS_sk, /* 20/ 22 Slovak */ "sl" , TEXTS_sl, /* 8/ 20 Slovenian */ "sr" , TEXTS_sr, /* 11/ 94 Serbian */ + "sr_ZZ" , TEXTS_sr_ZZ, /* 14/118 Serbian (ZZ) */ "sv" , TEXTS_sv, /* 21/ 54 Swedish */ "sw" , TEXTS_sw, /* 9/ 18 Swahili */ "ta_IN" , TEXTS_ta_IN, /* 2/ 12 Tamil (India) */ @@ -4052,7 +4101,7 @@ public final class KeyboardTextsTable { "uk" , TEXTS_uk, /* 11/ 88 Ukrainian */ "vi" , TEXTS_vi, /* 8/ 15 Vietnamese */ "zu" , TEXTS_zu, /* 8/ 11 Zulu */ - "zz" , TEXTS_zz, /* 19/112 Alphabet */ + "zz" , TEXTS_zz, /* 19/120 Alphabet */ }; static { diff --git a/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java b/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java index 764159c3d..0cd031e5f 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java +++ b/java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java @@ -149,8 +149,13 @@ public final class MoreKeySpec { } } final int size = filteredMoreKeys.size(); - return (moreKeys.length == size) ? moreKeys - : filteredMoreKeys.toArray(new MoreKeySpec[size]); + if (size == moreKeys.length) { + return moreKeys; + } + if (size == 0) { + return null; + } + return filteredMoreKeys.toArray(new MoreKeySpec[size]); } private static final boolean DEBUG = DebugFlags.DEBUG_ENABLED; diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java index 89c06a747..25bac9dd4 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java @@ -25,8 +25,8 @@ import java.util.ArrayList; @SmallTest public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase { - private static final int NUMBER_OF_SUBTYPES = 80; - private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 48; + private static final int NUMBER_OF_SUBTYPES = 81; + private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 49; private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2; @Override diff --git a/tests/src/com/android/inputmethod/keyboard/action/KlpActionLabelTests.java b/tests/src/com/android/inputmethod/keyboard/action/KlpActionLabelTests.java index 3fd3a36fc..74343cb6a 100644 --- a/tests/src/com/android/inputmethod/keyboard/action/KlpActionLabelTests.java +++ b/tests/src/com/android/inputmethod/keyboard/action/KlpActionLabelTests.java @@ -156,4 +156,17 @@ public class KlpActionLabelTests extends KlpActionTestsBase { doTestActionKeysInLocaleWithKeyboardTextsSet(hinglish, hi_ZZ, Locale.ITALIAN); doTestActionKeysInLocaleWithKeyboardTextsSet(hinglish, hi_ZZ, Locale.JAPANESE); } + + public void testSerbianLatinActionLabel() { + final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); + final Locale sr_ZZ = new Locale("sr", "ZZ"); + final InputMethodSubtype hinglish = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( + sr_ZZ.toString(), "serbian_qwertz"); + // An action label should be displayed in subtype's locale regardless of the system locale. + doTestActionKeysInLocaleWithKeyboardTextsSet(hinglish, sr_ZZ, sr_ZZ); + doTestActionKeysInLocaleWithKeyboardTextsSet(hinglish, sr_ZZ, Locale.US); + doTestActionKeysInLocaleWithKeyboardTextsSet(hinglish, sr_ZZ, Locale.FRENCH); + doTestActionKeysInLocaleWithKeyboardTextsSet(hinglish, sr_ZZ, Locale.ITALIAN); + doTestActionKeysInLocaleWithKeyboardTextsSet(hinglish, sr_ZZ, Locale.JAPANESE); + } } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java index b05789b73..eb11278d6 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java @@ -310,7 +310,7 @@ public abstract class LayoutBase extends AbstractLayoutBase { // U+00A1: "¡" INVERTED EXCLAMATION MARK // U+00BF: "¿" INVERTED QUESTION MARK - static final ExpectedKey[] EXCLAMATION_AND_QUESTION_MARKS = joinKeys( + public static final ExpectedKey[] EXCLAMATION_AND_QUESTION_MARKS = joinKeys( key("!", moreKey("\u00A1")), key("?", moreKey("\u00BF"))); // U+200C: ZERO WIDTH NON-JOINER // U+200D: ZERO WIDTH JOINER diff --git a/tests/src/com/android/inputmethod/keyboard/layout/SerbianQwertz.java b/tests/src/com/android/inputmethod/keyboard/layout/SerbianQwertz.java new file mode 100644 index 000000000..b23fe768e --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/SerbianQwertz.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout; + +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +public final class SerbianQwertz extends LayoutBase { + private static final String LAYOUT_NAME = "serbian_qwertz"; + + public SerbianQwertz(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + public static final String ROW1_11 = "ROW1_11"; + public static final String ROW2_10 = "ROW2_10"; + public static final String ROW2_11 = "ROW2_11"; + public static final String ROW3_8 = "ROW3_8"; + public static final String ROW3_9 = "ROW3_9"; + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + key("q", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("z", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0")), + ROW1_11) + .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10, ROW2_11) + .setKeysOfRow(3, "y", "x", "c", "v", "b", "n", "m", ROW3_8, ROW3_9) + .build(); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/SerbianLatinCustomizer.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/SerbianLatinCustomizer.java new file mode 100644 index 000000000..3660ce4b7 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/SerbianLatinCustomizer.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout.tests; + +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.SerbianQwertz; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +class SerbianLatinCustomizer extends LayoutCustomizer { + public SerbianLatinCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : LayoutBase.EXCLAMATION_AND_QUESTION_MARKS; + } + + protected void setSerbianKeys(final ExpectedKeyboardBuilder builder) { + builder + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .replaceKeyOfLabel(SerbianQwertz.ROW1_11, "\u0161") + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .replaceKeyOfLabel(SerbianQwertz.ROW2_10, "\u010D") + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .replaceKeyOfLabel(SerbianQwertz.ROW2_11, "\u0107") + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + .replaceKeyOfLabel(SerbianQwertz.ROW3_8, "\u0111") + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + .replaceKeyOfLabel(SerbianQwertz.ROW3_9, "\u017E"); + } + + @SuppressWarnings("unused") + protected void setMoreKeysOfS(final ExpectedKeyboardBuilder builder) { + // Serbian QWERTZ has a dedicated "š" key. + } + + @SuppressWarnings("unused") + protected void setMoreKeysOfC(final ExpectedKeyboardBuilder builder) { + // Serbian QWERTZ has a dedicated "č" and "ć" keys. + } + + @SuppressWarnings("unused") + protected void setMoreKeysOfD(final ExpectedKeyboardBuilder builder) { + // Serbian QWERTZ has a dedicated "đ" key. + } + + @SuppressWarnings("unused") + protected void setMoreKeysOfZ(final ExpectedKeyboardBuilder builder) { + // Serbian QWERTZ has a dedicated "ž" key. + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + setSerbianKeys(builder); + setMoreKeysOfS(builder); + setMoreKeysOfC(builder); + setMoreKeysOfD(builder); + setMoreKeysOfZ(builder); + return builder + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + .setMoreKeysOf("e", "\u00E8") + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + .setMoreKeysOf("i", "\u00EC"); + } +} \ No newline at end of file diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbianLatin.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbianLatin.java new file mode 100644 index 000000000..70f4bcefd --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbianLatin.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout.tests; + +import android.test.suitebuilder.annotation.SmallTest; + +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.SerbianQwertz; + +import java.util.Locale; + +/** + * sr_ZZ: Serbian (Latin)/serbian_qwertz + */ +@SmallTest +public final class TestsSerbianLatin extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sr", "ZZ"); + private static final LayoutBase LAYOUT = new SerbianQwertz(new SerbianLatinCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbianLatinQwerty.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbianLatinQwerty.java new file mode 100644 index 000000000..d8ef51b45 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbianLatinQwerty.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout.tests; + +import android.test.suitebuilder.annotation.SmallTest; + +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * sr_ZZ: Serbian (Latin)/qwerty + */ +@SmallTest +public final class TestsSerbianLatinQwerty extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sr", "ZZ"); + private static final LayoutBase LAYOUT = new Qwerty(new SerbianLatinQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class SerbianLatinQwertyCustomizer extends SerbianLatinCustomizer { + public SerbianLatinQwertyCustomizer(final Locale locale) { + super(locale); + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS + : joinKeys(LayoutBase.EXCLAMATION_AND_QUESTION_MARKS, LayoutBase.SHIFT_KEY); + } + + @Override + protected void setSerbianKeys(final ExpectedKeyboardBuilder builder) { + // QWERTY layout doesn't have Serbian Latin Keys. + } + + @Override + protected void setMoreKeysOfS(final ExpectedKeyboardBuilder builder) { + builder + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u0161") + .setAdditionalMoreKeysPositionOf("s", 2); + } + + @Override + protected void setMoreKeysOfC(final ExpectedKeyboardBuilder builder) { + builder + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .setMoreKeysOf("c", "\u010D", "\u0107") + .setAdditionalMoreKeysPositionOf("c", 3); + } + + @Override + protected void setMoreKeysOfD(final ExpectedKeyboardBuilder builder) { + builder + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + .setMoreKeysOf("d", "\u0111") + .setAdditionalMoreKeysPositionOf("d", 2); + } + + @Override + protected void setMoreKeysOfZ(final ExpectedKeyboardBuilder builder) { + builder + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + .setMoreKeysOf("z", "\u017E") + .setAdditionalMoreKeysPositionOf("z", 2); + } + } +} diff --git a/tools/make-keyboard-text/res/values-sr-rZZ/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values-sr-rZZ/donottranslate-more-keys.xml new file mode 100644 index 000000000..1168126ff --- /dev/null +++ b/tools/make-keyboard-text/res/values-sr-rZZ/donottranslate-more-keys.xml @@ -0,0 +1,42 @@ + + + + + è + + ì + + š,% + + č,ć,% + + đ,% + + ž,% + "Idi" + "Šalji" + "Sled" + "Gotov" + "Traži" + "Preth" + "Pauza" + "Čekaj" +