Parse keyLabel for icon, code, and outputText as well
Change-Id: I023915b68b4aabd056c2c1eb745876471556e15emain
parent
a9e1930a6a
commit
6193217f5c
|
@ -240,6 +240,7 @@
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="Keyboard_Key">
|
<declare-styleable name="Keyboard_Key">
|
||||||
|
<!-- TODO: Remove code attribute and consolidate with keySpec. -->
|
||||||
<!-- The unicode value that this key outputs.
|
<!-- The unicode value that this key outputs.
|
||||||
Code value represented in hexadecimal prefixed with "0x" or code value reference using
|
Code value represented in hexadecimal prefixed with "0x" or code value reference using
|
||||||
"!code/<code_name>" notation. -->
|
"!code/<code_name>" notation. -->
|
||||||
|
@ -275,8 +276,10 @@
|
||||||
<flag name="altCodeWhileTyping" value="0x04" />
|
<flag name="altCodeWhileTyping" value="0x04" />
|
||||||
<flag name="enableLongPress" value="0x08" />
|
<flag name="enableLongPress" value="0x08" />
|
||||||
</attr>
|
</attr>
|
||||||
|
<!-- TODO: Remove keyOutputText attribute and consolidate with keySpec. -->
|
||||||
<!-- The string of characters to output when this key is pressed. -->
|
<!-- The string of characters to output when this key is pressed. -->
|
||||||
<attr name="keyOutputText" format="string" />
|
<attr name="keyOutputText" format="string" />
|
||||||
|
<!-- TODO: Rename keyLabel to keySpec. -->
|
||||||
<!-- The label to display on the key. -->
|
<!-- The label to display on the key. -->
|
||||||
<attr name="keyLabel" format="string" />
|
<attr name="keyLabel" format="string" />
|
||||||
<!-- The hint label to display on the key in conjunction with the label. -->
|
<!-- The hint label to display on the key in conjunction with the label. -->
|
||||||
|
@ -318,6 +321,7 @@
|
||||||
<!-- If true, disable additionalMoreKeys. -->
|
<!-- If true, disable additionalMoreKeys. -->
|
||||||
<flag name="disableAdditionalMoreKeys" value="0x80000000" />
|
<flag name="disableAdditionalMoreKeys" value="0x80000000" />
|
||||||
</attr>
|
</attr>
|
||||||
|
<!-- TODO: Remove keyIcon attribute and consolidate with keySpec. -->
|
||||||
<!-- The icon to display on the key instead of the label. -->
|
<!-- The icon to display on the key instead of the label. -->
|
||||||
<attr name="keyIcon" format="string" />
|
<attr name="keyIcon" format="string" />
|
||||||
<!-- The icon for disabled key -->
|
<!-- The icon for disabled key -->
|
||||||
|
|
|
@ -267,12 +267,6 @@ public class Key implements Comparable<Key> {
|
||||||
R.styleable.Keyboard_Key_visualInsetsLeft, baseWidth, baseWidth, 0));
|
R.styleable.Keyboard_Key_visualInsetsLeft, baseWidth, baseWidth, 0));
|
||||||
final int visualInsetsRight = Math.round(keyAttr.getFraction(
|
final int visualInsetsRight = Math.round(keyAttr.getFraction(
|
||||||
R.styleable.Keyboard_Key_visualInsetsRight, baseWidth, baseWidth, 0));
|
R.styleable.Keyboard_Key_visualInsetsRight, baseWidth, baseWidth, 0));
|
||||||
mIconId = KeySpecParser.getIconId(style.getString(keyAttr,
|
|
||||||
R.styleable.Keyboard_Key_keyIcon));
|
|
||||||
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));
|
|
||||||
|
|
||||||
mLabelFlags = style.getFlags(keyAttr, R.styleable.Keyboard_Key_keyLabelFlags)
|
mLabelFlags = style.getFlags(keyAttr, R.styleable.Keyboard_Key_keyLabelFlags)
|
||||||
| row.getDefaultKeyLabelFlags();
|
| row.getDefaultKeyLabelFlags();
|
||||||
|
@ -321,8 +315,21 @@ public class Key implements Comparable<Key> {
|
||||||
}
|
}
|
||||||
mActionFlags = actionFlags;
|
mActionFlags = actionFlags;
|
||||||
|
|
||||||
final int code = KeySpecParser.parseCode(style.getString(keyAttr,
|
final String keySpec = style.getString(keyAttr, R.styleable.Keyboard_Key_keyLabel);
|
||||||
|
|
||||||
|
final int iconIdInAttr = KeySpecParser.getIconId(style.getString(keyAttr,
|
||||||
|
R.styleable.Keyboard_Key_keyIcon));
|
||||||
|
mIconId = (iconIdInAttr != ICON_UNDEFINED) ? iconIdInAttr
|
||||||
|
: 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);
|
R.styleable.Keyboard_Key_code), params.mCodesSet, CODE_UNSPECIFIED);
|
||||||
|
final int code = (codeInAttr != CODE_UNSPECIFIED) ? codeInAttr
|
||||||
|
: KeySpecParser.getCode(keySpec, params.mCodesSet);
|
||||||
if ((mLabelFlags & LABEL_FLAGS_FROM_CUSTOM_ACTION_LABEL) != 0) {
|
if ((mLabelFlags & LABEL_FLAGS_FROM_CUSTOM_ACTION_LABEL) != 0) {
|
||||||
mLabel = params.mId.mCustomActionLabel;
|
mLabel = params.mId.mCustomActionLabel;
|
||||||
} else if (code >= Character.MIN_SUPPLEMENTARY_CODE_POINT) {
|
} else if (code >= Character.MIN_SUPPLEMENTARY_CODE_POINT) {
|
||||||
|
@ -331,8 +338,8 @@ public class Key implements Comparable<Key> {
|
||||||
// code point nor as a surrogate pair.
|
// code point nor as a surrogate pair.
|
||||||
mLabel = new StringBuilder().appendCodePoint(code).toString();
|
mLabel = new StringBuilder().appendCodePoint(code).toString();
|
||||||
} else {
|
} else {
|
||||||
mLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr,
|
mLabel = StringUtils.toUpperCaseOfStringForLocale(
|
||||||
R.styleable.Keyboard_Key_keyLabel), needsToUpperCase, locale);
|
KeySpecParser.getLabel(keySpec), needsToUpperCase, locale);
|
||||||
}
|
}
|
||||||
if ((mLabelFlags & LABEL_FLAGS_DISABLE_HINT_LABEL) != 0) {
|
if ((mLabelFlags & LABEL_FLAGS_DISABLE_HINT_LABEL) != 0) {
|
||||||
mHintLabel = null;
|
mHintLabel = null;
|
||||||
|
@ -340,8 +347,12 @@ public class Key implements Comparable<Key> {
|
||||||
mHintLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr,
|
mHintLabel = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr,
|
||||||
R.styleable.Keyboard_Key_keyHintLabel), needsToUpperCase, locale);
|
R.styleable.Keyboard_Key_keyHintLabel), needsToUpperCase, locale);
|
||||||
}
|
}
|
||||||
String outputText = StringUtils.toUpperCaseOfStringForLocale(style.getString(keyAttr,
|
final String outputTextInAttr = style.getString(
|
||||||
R.styleable.Keyboard_Key_keyOutputText), needsToUpperCase, locale);
|
keyAttr, R.styleable.Keyboard_Key_keyOutputText);
|
||||||
|
final String rawOutputText = (outputTextInAttr != null) ? outputTextInAttr
|
||||||
|
: KeySpecParser.getOutputText(keySpec);
|
||||||
|
String outputText = StringUtils.toUpperCaseOfStringForLocale(
|
||||||
|
rawOutputText, needsToUpperCase, locale);
|
||||||
// Choose the first letter of the label as primary code if not specified.
|
// Choose the first letter of the label as primary code if not specified.
|
||||||
if (code == CODE_UNSPECIFIED && TextUtils.isEmpty(outputText)
|
if (code == CODE_UNSPECIFIED && TextUtils.isEmpty(outputText)
|
||||||
&& !TextUtils.isEmpty(mLabel)) {
|
&& !TextUtils.isEmpty(mLabel)) {
|
||||||
|
|
Loading…
Reference in New Issue