From a83a1feb62c4b4ff1a7cf5b6f58ad115491de76f Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 6 Feb 2014 11:34:12 +0900 Subject: [PATCH] Consolidate keyIcon and code with keyLabel attribute Change-Id: I75fbd348fab5022606ca14552eb03b15af6684c8 --- java/res/values/attrs.xml | 8 --- java/res/xml-sw600dp/key_styles_common.xml | 57 +++++---------- java/res/xml-sw600dp/key_styles_enter.xml | 50 +++++++------ java/res/xml/key_devanagari_sign_anusvara.xml | 3 +- .../xml/key_devanagari_sign_candrabindu.xml | 3 +- java/res/xml/key_devanagari_sign_nukta.xml | 3 +- .../key_devanagari_vowel_sign_candra_o.xml | 3 +- .../key_devanagari_vowel_sign_vocalic_r.xml | 3 +- java/res/xml/key_styles_common.xml | 72 +++++-------------- java/res/xml/key_styles_enter.xml | 54 ++++++++------ java/res/xml/key_styles_number.xml | 26 +++---- java/res/xml/keys_curly_brackets.xml | 6 +- java/res/xml/keys_less_greater.xml | 13 ++-- java/res/xml/keys_parentheses.xml | 6 +- java/res/xml/keys_square_brackets.xml | 6 +- .../xml/keystyle_devanagari_sign_virama.xml | 3 +- .../xml/keystyle_devanagari_sign_visarga.xml | 3 +- .../xml/keystyle_devanagari_vowel_sign_aa.xml | 3 +- .../xml/keystyle_devanagari_vowel_sign_ai.xml | 3 +- .../xml/keystyle_devanagari_vowel_sign_au.xml | 3 +- .../xml/keystyle_devanagari_vowel_sign_e.xml | 3 +- .../xml/keystyle_devanagari_vowel_sign_i.xml | 3 +- .../xml/keystyle_devanagari_vowel_sign_ii.xml | 3 +- .../xml/keystyle_devanagari_vowel_sign_o.xml | 3 +- .../xml/keystyle_devanagari_vowel_sign_u.xml | 3 +- .../xml/keystyle_devanagari_vowel_sign_uu.xml | 3 +- java/res/xml/rowkeys_symbols3.xml | 7 +- java/res/xml/rowkeys_thai1.xml | 9 +-- java/res/xml/rowkeys_thai2.xml | 12 ++-- java/res/xml/rowkeys_thai3.xml | 12 ++-- java/res/xml/rowkeys_thai4.xml | 12 ++-- java/res/xml/rows_number_normal.xml | 4 +- java/res/xml/rows_phone.xml | 3 +- .../com/android/inputmethod/keyboard/Key.java | 19 +++-- .../keyboard/internal/KeyStylesSet.java | 2 - .../res/values/donottranslate-more-keys.xml | 4 +- 36 files changed, 156 insertions(+), 274 deletions(-) diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 5bedd4ac2..0eacdb1bf 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -240,11 +240,6 @@ - - - @@ -318,9 +313,6 @@ - - - diff --git a/java/res/xml-sw600dp/key_styles_common.xml b/java/res/xml-sw600dp/key_styles_common.xml index 4e4579b4f..4dbc23ed0 100644 --- a/java/res/xml-sw600dp/key_styles_common.xml +++ b/java/res/xml-sw600dp/key_styles_common.xml @@ -39,7 +39,6 @@ @@ -49,7 +48,7 @@ > @@ -58,71 +57,56 @@ > - - @@ -132,8 +116,7 @@ > @@ -143,16 +126,14 @@ > @@ -164,23 +145,19 @@ latin:backgroundType="functional" /> - - + latin:keyLabel="!text/label_go_key|!code/key_shift_enter" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!text/label_go_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!text/label_next_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!text/label_previous_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!text/label_done_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!text/label_send_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!icon/search_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> diff --git a/java/res/xml/key_devanagari_sign_anusvara.xml b/java/res/xml/key_devanagari_sign_anusvara.xml index 0acd3bcd4..ed9cfbba1 100644 --- a/java/res/xml/key_devanagari_sign_anusvara.xml +++ b/java/res/xml/key_devanagari_sign_anusvara.xml @@ -28,7 +28,6 @@ diff --git a/java/res/xml/key_devanagari_sign_candrabindu.xml b/java/res/xml/key_devanagari_sign_candrabindu.xml index df0c4e054..225d2a6e6 100644 --- a/java/res/xml/key_devanagari_sign_candrabindu.xml +++ b/java/res/xml/key_devanagari_sign_candrabindu.xml @@ -44,7 +44,6 @@ U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU --> diff --git a/java/res/xml/key_devanagari_sign_nukta.xml b/java/res/xml/key_devanagari_sign_nukta.xml index f7a03ee90..8f8da2709 100644 --- a/java/res/xml/key_devanagari_sign_nukta.xml +++ b/java/res/xml/key_devanagari_sign_nukta.xml @@ -46,7 +46,6 @@ U+093C: "़" DEVANAGARI SIGN NUKTA --> diff --git a/java/res/xml/key_devanagari_vowel_sign_candra_o.xml b/java/res/xml/key_devanagari_vowel_sign_candra_o.xml index 370fc5405..8d5368c46 100644 --- a/java/res/xml/key_devanagari_vowel_sign_candra_o.xml +++ b/java/res/xml/key_devanagari_vowel_sign_candra_o.xml @@ -28,7 +28,6 @@ diff --git a/java/res/xml/key_devanagari_vowel_sign_vocalic_r.xml b/java/res/xml/key_devanagari_vowel_sign_vocalic_r.xml index f150d7ed9..fb912253d 100644 --- a/java/res/xml/key_devanagari_vowel_sign_vocalic_r.xml +++ b/java/res/xml/key_devanagari_vowel_sign_vocalic_r.xml @@ -52,7 +52,6 @@ U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R --> diff --git a/java/res/xml/key_styles_common.xml b/java/res/xml/key_styles_common.xml index 9c40d627a..2e59cedbd 100644 --- a/java/res/xml/key_styles_common.xml +++ b/java/res/xml/key_styles_common.xml @@ -42,7 +42,6 @@ @@ -52,7 +51,7 @@ > @@ -61,99 +60,70 @@ > - - - - - - - - - - - - + latin:keyLabel="!text/label_to_symbol_key|!code/key_shift" + latin:parentStyle="baseForLayoutSwitchKeyStyle" /> - @@ -281,66 +273,84 @@ latin:styleName="enterKeyStyle" latin:parentStyle="shiftEnterKeyStyle" /> + + + + + latin:keyLabel="!text/label_go_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!text/label_next_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!text/label_previous_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!text/label_done_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!text/label_send_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:keyLabel="!icon/search_key|!code/key_enter" + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> + latin:backgroundType="action" + latin:parentStyle="defaultEnterKeyStyle" /> diff --git a/java/res/xml/key_styles_number.xml b/java/res/xml/key_styles_number.xml index 2e5a601b0..3c0cf720e 100644 --- a/java/res/xml/key_styles_number.xml +++ b/java/res/xml/key_styles_number.xml @@ -89,36 +89,28 @@ latin:keyLabel="9" latin:keyHintLabel="WXYZ" latin:parentStyle="numberKeyStyle" /> - + - - + latin:keyLabel="{|!code/key_left_curly_bracket" /> + latin:keyLabel="}|!code/key_right_curly_bracket" /> diff --git a/java/res/xml/keys_less_greater.xml b/java/res/xml/keys_less_greater.xml index 56d0727dd..98dcef6b5 100644 --- a/java/res/xml/keys_less_greater.xml +++ b/java/res/xml/keys_less_greater.xml @@ -25,28 +25,25 @@ + diff --git a/java/res/xml/keys_parentheses.xml b/java/res/xml/keys_parentheses.xml index 25e89c930..fe4e5de84 100644 --- a/java/res/xml/keys_parentheses.xml +++ b/java/res/xml/keys_parentheses.xml @@ -22,11 +22,9 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > diff --git a/java/res/xml/keys_square_brackets.xml b/java/res/xml/keys_square_brackets.xml index 5c128fd0c..a9cf6a6db 100644 --- a/java/res/xml/keys_square_brackets.xml +++ b/java/res/xml/keys_square_brackets.xml @@ -22,9 +22,7 @@ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > + latin:keyLabel="[|!code/key_left_square_bracket" /> + latin:keyLabel="]|!code/key_right_square_bracket" /> diff --git a/java/res/xml/keystyle_devanagari_sign_virama.xml b/java/res/xml/keystyle_devanagari_sign_virama.xml index b22fbe842..9d007919d 100644 --- a/java/res/xml/keystyle_devanagari_sign_virama.xml +++ b/java/res/xml/keystyle_devanagari_sign_virama.xml @@ -29,7 +29,6 @@ U+094D: "्" DEVANAGARI SIGN VIRAMA --> diff --git a/java/res/xml/keystyle_devanagari_sign_visarga.xml b/java/res/xml/keystyle_devanagari_sign_visarga.xml index cb294951f..42facd7fa 100644 --- a/java/res/xml/keystyle_devanagari_sign_visarga.xml +++ b/java/res/xml/keystyle_devanagari_sign_visarga.xml @@ -29,7 +29,6 @@ U+0903: "ः" DEVANAGARI SIGN VISARGA --> diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml b/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml index 2e78c53ec..8013b0d72 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_aa.xml @@ -46,7 +46,6 @@ diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml b/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml index 0554c0e15..fd74ab52b 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_ai.xml @@ -53,7 +53,6 @@ diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_au.xml b/java/res/xml/keystyle_devanagari_vowel_sign_au.xml index 29a11a82e..15d4f901b 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_au.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_au.xml @@ -44,7 +44,6 @@ diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_e.xml b/java/res/xml/keystyle_devanagari_vowel_sign_e.xml index edd29c791..89d8fc7c8 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_e.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_e.xml @@ -53,7 +53,6 @@ diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_i.xml b/java/res/xml/keystyle_devanagari_vowel_sign_i.xml index 200fed29f..9e3c6ed76 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_i.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_i.xml @@ -45,7 +45,6 @@ diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml b/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml index 6dc9951df..3d064b595 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_ii.xml @@ -45,7 +45,6 @@ diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_o.xml b/java/res/xml/keystyle_devanagari_vowel_sign_o.xml index 233ac8609..3eddbe5e0 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_o.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_o.xml @@ -47,7 +47,6 @@ diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_u.xml b/java/res/xml/keystyle_devanagari_vowel_sign_u.xml index 7291b7099..9a00adebc 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_u.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_u.xml @@ -46,7 +46,6 @@ diff --git a/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml b/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml index a95ab822d..06b51eb72 100644 --- a/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml +++ b/java/res/xml/keystyle_devanagari_vowel_sign_uu.xml @@ -46,7 +46,6 @@ diff --git a/java/res/xml/rowkeys_symbols3.xml b/java/res/xml/rowkeys_symbols3.xml index e525dc480..43fe1082c 100644 --- a/java/res/xml/rowkeys_symbols3.xml +++ b/java/res/xml/rowkeys_symbols3.xml @@ -28,15 +28,14 @@ + diff --git a/java/res/xml/rowkeys_thai1.xml b/java/res/xml/rowkeys_thai1.xml index cd536656f..805822f06 100644 --- a/java/res/xml/rowkeys_thai1.xml +++ b/java/res/xml/rowkeys_thai1.xml @@ -48,8 +48,7 @@ diff --git a/java/res/xml/rowkeys_thai2.xml b/java/res/xml/rowkeys_thai2.xml index 4bcbbbf8d..bc9d70c9e 100644 --- a/java/res/xml/rowkeys_thai2.xml +++ b/java/res/xml/rowkeys_thai2.xml @@ -48,16 +48,14 @@ @@ -90,16 +88,14 @@ - diff --git a/java/res/xml/rows_phone.xml b/java/res/xml/rows_phone.xml index d8dcfbd62..6f05e51be 100644 --- a/java/res/xml/rows_phone.xml +++ b/java/res/xml/rows_phone.xml @@ -68,8 +68,7 @@ diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 1b9007da2..ed691f874 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -316,20 +316,17 @@ public class Key implements Comparable { mActionFlags = actionFlags; final String keySpec = style.getString(keyAttr, R.styleable.Keyboard_Key_keyLabel); + if (TextUtils.isEmpty(keySpec)) { + throw new RuntimeException("Empty keySpec"); + } - final int iconIdInAttr = KeySpecParser.getIconId(style.getString(keyAttr, - R.styleable.Keyboard_Key_keyIcon)); - mIconId = (iconIdInAttr != ICON_UNDEFINED) ? iconIdInAttr - : KeySpecParser.getIconId(keySpec); + mIconId = KeySpecParser.getIconId(keySpec); final int disabledIconId = KeySpecParser.getIconId(style.getString(keyAttr, R.styleable.Keyboard_Key_keyIconDisabled)); final int previewIconId = KeySpecParser.getIconId(style.getString(keyAttr, R.styleable.Keyboard_Key_keyIconPreview)); - final int codeInAttr = KeySpecParser.parseCode(style.getString(keyAttr, - R.styleable.Keyboard_Key_code), params.mCodesSet, CODE_UNSPECIFIED); - final int code = (codeInAttr != CODE_UNSPECIFIED) ? codeInAttr - : KeySpecParser.getCode(keySpec, params.mCodesSet); + final int code = KeySpecParser.getCode(keySpec, params.mCodesSet); if ((mLabelFlags & LABEL_FLAGS_FROM_CUSTOM_ACTION_LABEL) != 0) { mLabel = params.mId.mCustomActionLabel; } else if (code >= Character.MIN_SUPPLEMENTARY_CODE_POINT) { @@ -376,10 +373,10 @@ public class Key implements Comparable { } else { mCode = StringUtils.toUpperCaseOfCodeForLocale(code, needsToUpperCase, locale); } + final int altCodeInAttr = KeySpecParser.parseCode(style.getString(keyAttr, + R.styleable.Keyboard_Key_altCode), params.mCodesSet, CODE_UNSPECIFIED); final int altCode = StringUtils.toUpperCaseOfCodeForLocale( - KeySpecParser.parseCode(style.getString(keyAttr, - R.styleable.Keyboard_Key_altCode), params.mCodesSet, CODE_UNSPECIFIED), - needsToUpperCase, locale); + altCodeInAttr, needsToUpperCase, locale); mOptionalAttributes = OptionalAttributes.newInstance(outputText, altCode, disabledIconId, previewIconId, visualInsetsLeft, visualInsetsRight); mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr); diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java index a64f23501..f6180e32a 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStylesSet.java @@ -135,14 +135,12 @@ public final class KeyStylesSet { public void readKeyAttributes(final TypedArray keyAttr) { // TODO: Currently not all Key attributes can be declared as style. - readString(keyAttr, R.styleable.Keyboard_Key_code); readString(keyAttr, R.styleable.Keyboard_Key_altCode); readString(keyAttr, R.styleable.Keyboard_Key_keyLabel); readString(keyAttr, R.styleable.Keyboard_Key_keyHintLabel); readStringArray(keyAttr, R.styleable.Keyboard_Key_moreKeys); readStringArray(keyAttr, R.styleable.Keyboard_Key_additionalMoreKeys); readFlags(keyAttr, R.styleable.Keyboard_Key_keyLabelFlags); - readString(keyAttr, R.styleable.Keyboard_Key_keyIcon); readString(keyAttr, R.styleable.Keyboard_Key_keyIconDisabled); readString(keyAttr, R.styleable.Keyboard_Key_keyIconPreview); readInt(keyAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn); diff --git a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml index ceb46dcd2..6b64652f2 100644 --- a/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml +++ b/tools/make-keyboard-text/res/values/donottranslate-more-keys.xml @@ -196,8 +196,8 @@ !icon/shortcut_key|!code/key_shortcut !hasLabels!,\@string/label_next_key|!code/key_action_next !hasLabels!,\@string/label_previous_key|!code/key_action_previous - - = \\ < + + = \\\\ < ~ [ <