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

Commit 72fb8e05 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Use FontMetrics.top and padding to place keyHintLetter

Bug: 6225638
Change-Id: Ia3680d84bd1e7ccbdb87aedca106641c6d270677
parent dd7871b3
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
    /** The canvas for the above mutable keyboard bitmap */
    private Canvas mCanvas;
    private final Paint mPaint = new Paint();
    private final Paint.FontMetrics mFontMetrics = new Paint.FontMetrics();
    // This map caches key label text height in pixel as value and key label text size as map key.
    private static final HashMap<Integer, Float> sTextHeightCache =
            new HashMap<Integer, Float>();
@@ -659,13 +660,14 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
                // The hint label is placed at top-right corner of the key. Used mainly on tablet.
                hintX = keyWidth - params.mKeyShiftedLetterHintPadding
                        - getCharWidth(KEY_LABEL_REFERENCE_CHAR, paint) / 2;
                hintY = -paint.ascent();
                paint.getFontMetrics(mFontMetrics);
                hintY = -mFontMetrics.top + params.mKeyShiftedLetterHintPadding;
                paint.setTextAlign(Align.CENTER);
            } else { // key.hasHintLetter()
                // The hint label is placed at top-right corner of the key. Used mainly on phone.
                hintX = keyWidth - params.mKeyHintLetterPadding
                        - getCharWidth(KEY_NUMERIC_HINT_LABEL_REFERENCE_CHAR, paint) / 2;
                hintY = -paint.ascent();
                hintY = -paint.ascent() + params.mKeyHintLetterPadding;
                paint.setTextAlign(Align.CENTER);
            }
            canvas.drawText(hint, 0, hint.length(), hintX, hintY, paint);