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

Commit ddf9fe01 authored by Mihai Popa's avatar Mihai Popa
Browse files

[Magnifier-63] Hide it for rotated/scaled textview

The magnifier is currently behaving badly when the magnified view is
scaled and/or rotated - the content of the magnifier and its position
are wrong, as we do not take these into account when computing
coordinates for content copy and magnifier positioning. This CL is
making the magnifier remain hidden when such transformations are applied
to the magnified view or a view above it in the view hierarchy.

Bug: 112519631
Test: manual testing
Change-Id: Ibb81fdc9d2ec8ba14914166e408c92a3aad7e312
parent 38304b59
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -14639,9 +14639,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * Recomputes the matrix if necessary.
     *
     * @return True if the transform matrix is the identity matrix, false otherwise.
     * @hide
     */
    @UnsupportedAppUsage
    final boolean hasIdentityMatrix() {
    public final boolean hasIdentityMatrix() {
        return mRenderNode.hasIdentityMatrix();
    }
+20 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ import android.view.View.OnClickListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityNodeInfo;
@@ -4800,6 +4801,24 @@ public class Editor {
            return glyphHeight > magnifierContentHeight;
        }

        private boolean viewIsMatrixTransformed() {
            if (mMagnifierAnimator.mMagnifierIsShowing) {
                // Do not check again when the magnifier is currently showing.
                return false;
            }
            if (!mTextView.hasIdentityMatrix()) {
                return true;
            }
            ViewParent viewParent = mTextView.getParent();
            while (viewParent != null) {
                if (viewParent instanceof View && !((View) viewParent).hasIdentityMatrix()) {
                    return true;
                }
                viewParent = viewParent.getParent();
            }
            return false;
        }

        /**
         * Computes the position where the magnifier should be shown, relative to
         * {@code mTextView}, and writes them to {@code showPosInView}. Also decides
@@ -4928,6 +4947,7 @@ public class Editor {

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