@@ -340,7 +340,9 @@ public Key(@Nullable final String keySpec, @Nonnull final TypedArray keyAttr,
340340 final int disabledIconId = KeySpecParser .getIconId (style .getString (keyAttr ,
341341 R .styleable .Keyboard_Key_keyIconDisabled ));
342342
343- final int code = KeySpecParser .getCode (keySpec );
343+ final String keySpecUpper = style .getString (keyAttr , R .styleable .Keyboard_Key_keySpecUpper );
344+ final int code = KeySpecParser .getCode (
345+ (needsToUpcase && keySpecUpper != null ) ? keySpecUpper : keySpec );
344346 if ((mLabelFlags & LABEL_FLAGS_FROM_CUSTOM_ACTION_LABEL ) != 0 ) {
345347 mLabel = params .mId .mCustomActionLabel ;
346348 } else if (code >= Character .MIN_SUPPLEMENTARY_CODE_POINT ) {
@@ -351,7 +353,9 @@ public Key(@Nullable final String keySpec, @Nonnull final TypedArray keyAttr,
351353 } else {
352354 final String label = KeySpecParser .getLabel (keySpec );
353355 mLabel = needsToUpcase
354- ? StringUtils .toTitleCaseOfKeyLabel (label , localeForUpcasing )
356+ ? keySpecUpper != null
357+ ? KeySpecParser .getLabel (keySpecUpper )
358+ : StringUtils .toTitleCaseOfKeyLabel (label , localeForUpcasing )
355359 : label ;
356360 }
357361 if ((mLabelFlags & LABEL_FLAGS_DISABLE_HINT_LABEL ) != 0 ) {
@@ -365,7 +369,9 @@ public Key(@Nullable final String keySpec, @Nonnull final TypedArray keyAttr,
365369 }
366370 String outputText = KeySpecParser .getOutputText (keySpec );
367371 if (needsToUpcase ) {
368- outputText = StringUtils .toTitleCaseOfKeyLabel (outputText , localeForUpcasing );
372+ outputText = keySpecUpper != null
373+ ? KeySpecParser .getOutputText (keySpecUpper )
374+ : StringUtils .toTitleCaseOfKeyLabel (outputText , localeForUpcasing );
369375 }
370376 // Choose the first letter of the label as primary code if not specified.
371377 if (code == CODE_UNSPECIFIED && TextUtils .isEmpty (outputText )
@@ -392,7 +398,9 @@ public Key(@Nullable final String keySpec, @Nonnull final TypedArray keyAttr,
392398 mCode = CODE_OUTPUT_TEXT ;
393399 }
394400 } else {
395- mCode = needsToUpcase ? StringUtils .toTitleCaseOfKeyCode (code , localeForUpcasing )
401+ // If keySpecUpper is not null, we've already upcased the code if required
402+ mCode = (needsToUpcase && keySpecUpper == null )
403+ ? StringUtils .toTitleCaseOfKeyCode (code , localeForUpcasing )
396404 : code ;
397405 }
398406 final int altCodeInAttr = KeySpecParser .parseCode (
0 commit comments