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

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

Merge "[Magnifier-80] Make API getters relative to window"

parents 1047cba3 ef456970
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50443,6 +50443,7 @@ package android.view {
    method protected float getLeftFadingEdgeStrength();
    method protected int getLeftPaddingOffset();
    method public final boolean getLocalVisibleRect(android.graphics.Rect);
    method public void getLocationInSurface(@NonNull @Size(2) int[]);
    method public void getLocationInWindow(@Size(2) int[]);
    method public void getLocationOnScreen(@Size(2) int[]);
    method public android.graphics.Matrix getMatrix();
+2 −3
Original line number Diff line number Diff line
@@ -11095,11 +11095,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * <p>Computes the coordinates of this view in its surface. The argument
     * must be an array of two integers. After the method returns, the array
     * contains the x and y location in that order.</p>
     * @hide
     *
     * @param location an array of two integers in which to hold the coordinates
     */
    @UnsupportedAppUsage
    public void getLocationInSurface(@Size(2) int[] location) {
    public void getLocationInSurface(@NonNull @Size(2) int[] location) {
        getLocationInWindow(location);
        if (mAttachInfo != null && mAttachInfo.mViewRootImpl != null) {
            location[0] += mAttachInfo.mViewRootImpl.mWindowAttributes.surfaceInsets.left;
+0 −3
Original line number Diff line number Diff line
@@ -4984,9 +4984,6 @@ public class Editor {
            if (magnifierTopLeft == null) {
                return;
            }
            final Rect surfaceInsets =
                    mTextView.getViewRootImpl().mWindowAttributes.surfaceInsets;
            magnifierTopLeft.offset(-surfaceInsets.left, -surfaceInsets.top);
            final Rect magnifierRect = new Rect(magnifierTopLeft.x, magnifierTopLeft.y,
                    magnifierTopLeft.x + mMagnifierAnimator.mMagnifier.getWidth(),
                    magnifierTopLeft.y + mMagnifierAnimator.mMagnifier.getHeight());
+30 −19
Original line number Diff line number Diff line
@@ -471,13 +471,13 @@ public final class Magnifier {
    }

    /**
     * Returns the top left coordinates of the magnifier, relative to the surface of the
     * main application window. They will be determined by the coordinates of the last
     * {@link #show(float, float)} or {@link #show(float, float, float, float)} call, adjusted
     * to take into account any potential clamping behavior. The method can be used immediately
     * after a #show call to find out where the magnifier will be positioned. However, the
     * position of the magnifier will not be updated in the same frame due to the async
     * copying of the content copying and of the magnifier rendering.
     * Returns the top left coordinates of the magnifier, relative to the main application
     * window. They will be determined by the coordinates of the last {@link #show(float, float)}
     * or {@link #show(float, float, float, float)} call, adjusted to take into account any
     * potential clamping behavior. The method can be used immediately after a #show
     * call to find out where the magnifier will be positioned. However, the position of the
     * magnifier will not be updated visually in the same frame, due to the async nature of
     * the content copying and of the magnifier rendering.
     * The method will return {@code null} if #show has not yet been called, or if the last
     * operation performed was a #dismiss.
     *
@@ -488,15 +488,18 @@ public final class Magnifier {
        if (mWindow == null) {
            return null;
        }
        return new Point(getCurrentClampedWindowCoordinates());
        final Point position = getCurrentClampedWindowCoordinates();
        position.offset(-mParentSurface.mInsets.left, -mParentSurface.mInsets.top);
        return new Point(position);
    }

    /**
     * Returns the top left coordinates of the magnifier source (i.e. the view region going to
     * be magnified and copied to the magnifier), relative to the surface the content is copied
     * from. The content will be copied:
     * be magnified and copied to the magnifier), relative to the window or surface the content
     * is copied from. The content will be copied:
     * - if the magnified view is a {@link SurfaceView}, from the surface backing it
     * - otherwise, from the surface of the main application window
     * - otherwise, from the surface backing the main application window, and the coordinates
     *   returned will be relative to the main application window
     * The method will return {@code null} if #show has not yet been called, or if the last
     * operation performed was a #dismiss.
     *
@@ -507,7 +510,9 @@ public final class Magnifier {
        if (mWindow == null) {
            return null;
        }
        return new Point(mPixelCopyRequestRect.left, mPixelCopyRequestRect.top);
        final Point position = new Point(mPixelCopyRequestRect.left, mPixelCopyRequestRect.top);
        position.offset(-mContentCopySurface.mInsets.left, -mContentCopySurface.mInsets.top);
        return new Point(position);
    }

    /**
@@ -531,7 +536,7 @@ public final class Magnifier {
                        viewRootImpl.getHeight() + surfaceInsets.top + surfaceInsets.bottom;
                validMainWindowSurface =
                        new SurfaceInfo(viewRootImpl.getSurfaceControl(), mainWindowSurface,
                                surfaceWidth, surfaceHeight, true);
                                surfaceWidth, surfaceHeight, surfaceInsets, true);
            }
        }
        // Get the surface backing the magnified view, if it is a SurfaceView.
@@ -544,7 +549,7 @@ public final class Magnifier {
            if (sc != null && sc.isValid()) {
                final Rect surfaceFrame = surfaceHolder.getSurfaceFrame();
                validSurfaceViewSurface = new SurfaceInfo(sc, surfaceViewSurface,
                        surfaceFrame.right, surfaceFrame.bottom, false);
                        surfaceFrame.right, surfaceFrame.bottom, new Rect(), false);
            }
        }

@@ -708,9 +713,13 @@ public final class Magnifier {
        final Rect windowBounds;
        if (mParentSurface.mIsMainWindowSurface) {
            final Insets systemInsets = mView.getRootWindowInsets().getSystemWindowInsets();
            windowBounds = new Rect(systemInsets.left, systemInsets.top,
                    mParentSurface.mWidth - systemInsets.right,
                    mParentSurface.mHeight - systemInsets.bottom);
            windowBounds = new Rect(
                    systemInsets.left + mParentSurface.mInsets.left,
                    systemInsets.top + mParentSurface.mInsets.top,
                    mParentSurface.mWidth - systemInsets.right - mParentSurface.mInsets.right,
                    mParentSurface.mHeight - systemInsets.bottom
                            - mParentSurface.mInsets.bottom
            );
        } else {
            windowBounds = new Rect(0, 0, mParentSurface.mWidth, mParentSurface.mHeight);
        }
@@ -725,21 +734,23 @@ public final class Magnifier {
     * Contains a surface and metadata corresponding to it.
     */
    private static class SurfaceInfo {
        public static final SurfaceInfo NULL = new SurfaceInfo(null, null, 0, 0, false);
        public static final SurfaceInfo NULL = new SurfaceInfo(null, null, 0, 0, null, false);

        private Surface mSurface;
        private SurfaceControl mSurfaceControl;
        private int mWidth;
        private int mHeight;
        private Rect mInsets;
        private boolean mIsMainWindowSurface;

        SurfaceInfo(final SurfaceControl surfaceControl, final Surface surface,
                final int width, final int height,
                final int width, final int height, final Rect insets,
                final boolean isMainWindowSurface) {
            mSurfaceControl = surfaceControl;
            mSurface = surface;
            mWidth = width;
            mHeight = height;
            mInsets = insets;
            mIsMainWindowSurface = isMainWindowSurface;
        }
    }