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

Commit f45b3a11 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Magnifier-35] Do not show when text is large" into pi-dev

parents 0d5bbf77 894469ce
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;