Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5275911 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Use KCM to capitalize characters, instead of toUpperCase()

Some charaters don't get capitalized by the the keyboard based on
what is configured in the respective KCM, so we should use KCM
to see what the capitalized version of the character would look like.

Bug: 321938411
Test: manual
Change-Id: I896bb8f7526c7e2d6c516d3cc0d30c4567f65236
parent 9812a64b
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@ import android.util.SparseIntArray;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;

import java.util.Locale;

/**
 * A complimentary class to {@link KeyboardLayoutPreviewDrawable} describing the physical key layout
 * of a Physical keyboard and provides information regarding the scan codes produced by the physical
@@ -339,9 +337,9 @@ final class PhysicalKeyLayout {
        }
        int utf8Char = (kcm.get(keyCode, modifierState) & KeyCharacterMap.COMBINING_ACCENT_MASK);
        if (Character.isValidCodePoint(utf8Char)) {
            return String.valueOf(Character.toChars(utf8Char)).toUpperCase(Locale.getDefault());
            return String.valueOf(Character.toChars(utf8Char));
        } else {
            return String.valueOf(kcm.getDisplayLabel(keyCode)).toUpperCase(Locale.getDefault());
            return String.valueOf(kcm.getDisplayLabel(keyCode));
        }
    }

@@ -400,11 +398,11 @@ final class PhysicalKeyLayout {
        private final String mAltGrText;

        public KeyGlyph(KeyCharacterMap kcm, int keyCode) {
            mBaseText = getKeyText(kcm, keyCode, 0);
            mBaseText = getKeyText(kcm, keyCode, KeyEvent.META_CAPS_LOCK_ON);
            mShiftText = getKeyText(kcm, keyCode,
                    KeyEvent.META_SHIFT_ON | KeyEvent.META_SHIFT_LEFT_ON);
            mAltGrText = getKeyText(kcm, keyCode,
                    KeyEvent.META_ALT_ON | KeyEvent.META_ALT_RIGHT_ON);
                    KeyEvent.META_ALT_ON | KeyEvent.META_ALT_RIGHT_ON | KeyEvent.META_CAPS_LOCK_ON);
        }

        public String getBaseText() {