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

Commit 894469ce authored by Mihai Popa's avatar Mihai Popa
Browse files

[Magnifier-35] Do not show when text is large

There is no point in displaying the magnifier when the text is large
enough. In this CL we are using the font metrics of the TextView to
decide whether the magnifier should be displayed or not.

Bug: 70608551
Test: manual testing
Change-Id: Icb2fb4412b6b930dfb3322e51fd0139152cf9d39
parent f67bb19f
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -4824,13 +4824,23 @@ public class Editor {
            return true;
        }

        private boolean tooLargeTextForMagnifier() {
            final float magnifierContentHeight = Math.round(
                    mMagnifierAnimator.mMagnifier.getHeight()
                            / mMagnifierAnimator.mMagnifier.getZoom());
            final Paint.FontMetrics fontMetrics = mTextView.getPaint().getFontMetrics();
            final float glyphHeight = fontMetrics.descent - fontMetrics.ascent;
            return glyphHeight > magnifierContentHeight;
        }

        protected final void updateMagnifier(@NonNull final MotionEvent event) {
            if (mMagnifierAnimator == null) {
                return;
            }

            final PointF showPosInView = new PointF();
            final boolean shouldShow = obtainMagnifierShowCoordinates(event, showPosInView);
            final boolean shouldShow = !tooLargeTextForMagnifier()
                    && obtainMagnifierShowCoordinates(event, showPosInView);
            if (shouldShow) {
                // Make the cursor visible and stop blinking.
                mRenderCursorRegardlessTiming = true;