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

Commit 9542e0dd authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Add AltGr+Shift combination to Keyboard layout preview

Bug: 293579375
Test: atest InputScreenshotTests
Change-Id: Idf91951160a45cc76ee5ad68c13ca1edf4966e76
parent c80b0a81
Loading
Loading
Loading
Loading
+13 −17
Original line number Diff line number Diff line
@@ -219,26 +219,22 @@ final class KeyboardLayoutPreviewDrawable extends Drawable {
            if (!glyphData.hasBaseText()) {
                return;
            }
            if (glyphData.hasValidShiftText() && glyphData.hasValidAltGrText()) {
            boolean isCenter = !glyphData.hasValidAltGrText() && !glyphData.hasValidAltShiftText();
            mGlyphDrawables.add(new GlyphDrawable(glyphData.getBaseText(), new RectF(),
                        GRAVITY_BOTTOM | GRAVITY_LEFT, mBaseTextPaint));
                    GRAVITY_BOTTOM | (isCenter ? GRAVITY_CENTER_HORIZONTAL : GRAVITY_LEFT),
                    mBaseTextPaint));
            if (glyphData.hasValidShiftText()) {
                mGlyphDrawables.add(new GlyphDrawable(glyphData.getShiftText(), new RectF(),
                        GRAVITY_TOP | GRAVITY_LEFT, mModifierTextPaint));
                mGlyphDrawables.add(new GlyphDrawable(glyphData.getAltGrText(), new RectF(),
                        GRAVITY_BOTTOM | GRAVITY_RIGHT, mModifierTextPaint));
            } else if (glyphData.hasValidShiftText()) {
                mGlyphDrawables.add(new GlyphDrawable(glyphData.getBaseText(), new RectF(),
                        GRAVITY_BOTTOM | GRAVITY_CENTER_HORIZONTAL, mBaseTextPaint));
                mGlyphDrawables.add(new GlyphDrawable(glyphData.getShiftText(), new RectF(),
                        GRAVITY_TOP | GRAVITY_CENTER_HORIZONTAL, mModifierTextPaint));
            } else if (glyphData.hasValidAltGrText()) {
                mGlyphDrawables.add(new GlyphDrawable(glyphData.getBaseText(), new RectF(),
                        GRAVITY_BOTTOM | GRAVITY_LEFT, mBaseTextPaint));
                        GRAVITY_TOP | (isCenter ? GRAVITY_CENTER_HORIZONTAL : GRAVITY_LEFT),
                        mModifierTextPaint));
            }
            if (glyphData.hasValidAltGrText()) {
                mGlyphDrawables.add(new GlyphDrawable(glyphData.getAltGrText(), new RectF(),
                        GRAVITY_BOTTOM | GRAVITY_RIGHT, mModifierTextPaint));
            } else {
                mGlyphDrawables.add(new GlyphDrawable(glyphData.getBaseText(), new RectF(),
                        GRAVITY_CENTER, mBaseTextPaint));
            }
            if (glyphData.hasValidAltShiftText()) {
                mGlyphDrawables.add(new GlyphDrawable(glyphData.getAltGrShiftText(), new RectF(),
                        GRAVITY_TOP | GRAVITY_RIGHT, mModifierTextPaint));
            }
        }

+15 −0
Original line number Diff line number Diff line
@@ -396,6 +396,7 @@ final class PhysicalKeyLayout {
        private final String mBaseText;
        private final String mShiftText;
        private final String mAltGrText;
        private final String mAltGrShiftText;

        public KeyGlyph(KeyCharacterMap kcm, int keyCode) {
            mBaseText = getKeyText(kcm, keyCode, KeyEvent.META_CAPS_LOCK_ON);
@@ -403,6 +404,9 @@ final class PhysicalKeyLayout {
                    KeyEvent.META_SHIFT_ON | KeyEvent.META_SHIFT_LEFT_ON);
            mAltGrText = getKeyText(kcm, keyCode,
                    KeyEvent.META_ALT_ON | KeyEvent.META_ALT_RIGHT_ON | KeyEvent.META_CAPS_LOCK_ON);
            mAltGrShiftText = getKeyText(kcm, keyCode,
                    KeyEvent.META_ALT_ON | KeyEvent.META_ALT_RIGHT_ON | KeyEvent.META_SHIFT_LEFT_ON
                            | KeyEvent.META_SHIFT_ON);
        }

        public String getBaseText() {
@@ -417,6 +421,10 @@ final class PhysicalKeyLayout {
            return mAltGrText;
        }

        public String getAltGrShiftText() {
            return mAltGrShiftText;
        }

        public boolean hasBaseText() {
            return !TextUtils.isEmpty(mBaseText);
        }
@@ -428,5 +436,12 @@ final class PhysicalKeyLayout {
        public boolean hasValidAltGrText() {
            return !TextUtils.isEmpty(mAltGrText) && !TextUtils.equals(mBaseText, mAltGrText);
        }

        public boolean hasValidAltShiftText() {
            return !TextUtils.isEmpty(mAltGrShiftText)
                    && !TextUtils.equals(mBaseText, mAltGrShiftText)
                    && !TextUtils.equals(mAltGrText, mAltGrShiftText)
                    && !TextUtils.equals(mShiftText, mAltGrShiftText);
        }
    }
}