diff options
| author | 2018-09-28 13:54:19 +0100 | |
|---|---|---|
| committer | 2018-10-01 14:25:53 +0100 | |
| commit | ddf9fe01be1c104aa393aed586fe008dd248122a (patch) | |
| tree | c9d99a928bfe18aab985df78832a81792ae719a9 | |
| parent | 38304b594fe7b01de2edc39bbba2cb37791b0318 (diff) | |
[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
| -rw-r--r-- | core/java/android/view/View.java | 3 | ||||
| -rw-r--r-- | core/java/android/widget/Editor.java | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 78e6dd8fb139..69af487ce727 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -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(); } diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 9d74c98a04ba..8027dd7cdb10 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -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. |