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

Commit 54fb35fa authored by Candice Lo's avatar Candice Lo Committed by Android (Google) Code Review
Browse files

Merge "refactor(magnification): Rename enableWindowMagnificationInternal for...

Merge "refactor(magnification): Rename enableWindowMagnificationInternal for better readability" into main
parents 16769d7f 9f2da35c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ class WindowMagnificationAnimationController implements ValueAnimator.AnimatorUp
            if (mState == STATE_ENABLING || mState == STATE_DISABLING) {
                mValueAnimator.cancel();
            }
            mController.enableWindowMagnificationInternal(scale, centerX, centerY,
            mController.updateWindowMagnificationInternal(scale, centerX, centerY,
                    mMagnificationFrameOffsetRatioX, mMagnificationFrameOffsetRatioY);
            updateState();
            return;
@@ -159,7 +159,7 @@ class WindowMagnificationAnimationController implements ValueAnimator.AnimatorUp

        if (mEndSpec.equals(mStartSpec)) {
            if (mState == STATE_DISABLED) {
                mController.enableWindowMagnificationInternal(scale, centerX, centerY,
                mController.updateWindowMagnificationInternal(scale, centerX, centerY,
                        mMagnificationFrameOffsetRatioX, mMagnificationFrameOffsetRatioY);
            } else if (mState == STATE_ENABLING || mState == STATE_DISABLING) {
                mValueAnimator.cancel();
@@ -306,7 +306,7 @@ class WindowMagnificationAnimationController implements ValueAnimator.AnimatorUp
        // If the animation is playing backwards, mStartSpec will be the final spec we would
        // like to reach.
        AnimationSpec spec = isReverse ? mStartSpec : mEndSpec;
        mController.enableWindowMagnificationInternal(
        mController.updateWindowMagnificationInternal(
                spec.mScale, spec.mCenterX, spec.mCenterY,
                mMagnificationFrameOffsetRatioX, mMagnificationFrameOffsetRatioY);

@@ -358,7 +358,7 @@ class WindowMagnificationAnimationController implements ValueAnimator.AnimatorUp
                mStartSpec.mCenterX + (mEndSpec.mCenterX - mStartSpec.mCenterX) * fract;
        final float centerY =
                mStartSpec.mCenterY + (mEndSpec.mCenterY - mStartSpec.mCenterY) * fract;
        mController.enableWindowMagnificationInternal(sentScale, centerX, centerY,
        mController.updateWindowMagnificationInternal(sentScale, centerX, centerY,
                mMagnificationFrameOffsetRatioX, mMagnificationFrameOffsetRatioY);
    }

+17 −14
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
    /**
     * SourceBound is the bound of the magnified region which projects the magnified content.
     * SourceBound's center is equal to the parameters centerX and centerY in
     * {@link WindowMagnificationController#enableWindowMagnificationInternal(float, float, float)}}
     * {@link WindowMagnificationController#updateWindowMagnificationInternal(float, float, float)}}
     * but it is calculated from {@link #mMagnificationFrame}'s center in the runtime.
     */
    private final Rect mSourceBounds = new Rect();
@@ -566,7 +566,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
        // window size changed not caused by rotation.
        if (isActivated() && reCreateWindow) {
            deleteWindowMagnification();
            enableWindowMagnificationInternal(Float.NaN, Float.NaN, Float.NaN);
            updateWindowMagnificationInternal(Float.NaN, Float.NaN, Float.NaN);
        }
    }

@@ -1317,7 +1317,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
    }

    /**
     * Wraps {@link WindowMagnificationController#enableWindowMagnificationInternal(float, float,
     * Wraps {@link WindowMagnificationController#updateWindowMagnificationInternal(float, float,
     * float, float, float)}
     * with transition animation. If the window magnification is not enabled, the scale will start
     * from 1.0 and the center won't be changed during the animation. If animator is
@@ -1344,10 +1344,12 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
    }

    /**
     * Enables window magnification with specified parameters. If the given scale is <strong>less
     * than or equal to 1.0f</strong>, then
     * Updates window magnification status with specified parameters. If the given scale is
     * <strong>less than 1.0f</strong>, then
     * {@link WindowMagnificationController#deleteWindowMagnification()} will be called instead to
     * be consistent with the behavior of display magnification.
     * be consistent with the behavior of display magnification. If the given scale is
     * <strong>larger than or equal to 1.0f</strong>, and the window magnification is not activated
     * yet, window magnification will be enabled.
     *
     * @param scale   the target scale, or {@link Float#NaN} to leave unchanged
     * @param centerX the screen-relative X coordinate around which to center for magnification,
@@ -1355,16 +1357,17 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
     * @param centerY the screen-relative Y coordinate around which to center for magnification,
     *                or {@link Float#NaN} to leave unchanged.
     */
    void enableWindowMagnificationInternal(float scale, float centerX, float centerY) {
        enableWindowMagnificationInternal(scale, centerX, centerY, Float.NaN, Float.NaN);
    void updateWindowMagnificationInternal(float scale, float centerX, float centerY) {
        updateWindowMagnificationInternal(scale, centerX, centerY, Float.NaN, Float.NaN);
    }

    /**
     * Enables window magnification with specified parameters. If the given scale is <strong>less
     * than 1.0f</strong>, then
     * Updates window magnification status with specified parameters. If the given scale is
     * <strong>less than 1.0f</strong>, then
     * {@link WindowMagnificationController#deleteWindowMagnification()} will be called instead to
     * be consistent with the behavior of display magnification.
     *
     * be consistent with the behavior of display magnification. If the given scale is
     * <strong>larger than or equal to 1.0f</strong>, and the window magnification is not activated
     * yet, window magnification will be enabled.
     * @param scale   the target scale, or {@link Float#NaN} to leave unchanged
     * @param centerX the screen-relative X coordinate around which to center for magnification,
     *                or {@link Float#NaN} to leave unchanged.
@@ -1377,7 +1380,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
     *                                       between frame position Y and centerY,
     *                                       or {@link Float#NaN} to leave unchanged.
     */
    void enableWindowMagnificationInternal(float scale, float centerX, float centerY,
    void updateWindowMagnificationInternal(float scale, float centerX, float centerY,
                float magnificationFrameOffsetRatioX, float magnificationFrameOffsetRatioY) {
        if (Float.compare(scale, 1.0f) < 0) {
            deleteWindowMagnification();
@@ -1433,7 +1436,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
            return;
        }

        enableWindowMagnificationInternal(scale, Float.NaN, Float.NaN);
        updateWindowMagnificationInternal(scale, Float.NaN, Float.NaN);
        mHandler.removeCallbacks(mUpdateStateDescriptionRunnable);
        mHandler.postDelayed(mUpdateStateDescriptionRunnable, UPDATE_STATE_DESCRIPTION_DELAY_MS);
    }
+20 −20
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
            throws RemoteException {
        enableWindowMagnificationAndWaitAnimating(mWaitAnimationDuration, mAnimationCallback);

        verify(mSpyController, atLeast(2)).enableWindowMagnificationInternal(
        verify(mSpyController, atLeast(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -220,7 +220,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
                mWaitAnimationDuration, /* targetScale= */ 1.0f,
                DEFAULT_CENTER_X, DEFAULT_CENTER_Y, mAnimationCallback);

        verify(mSpyController).enableWindowMagnificationInternal(1.0f, DEFAULT_CENTER_X,
        verify(mSpyController).updateWindowMagnificationInternal(1.0f, DEFAULT_CENTER_X,
                DEFAULT_CENTER_Y, 0f, 0f);
        verify(mAnimationCallback).onResult(true);
    }
@@ -244,7 +244,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
            advanceTimeBy(mWaitAnimationDuration);
        });

        verify(mSpyController, atLeast(2)).enableWindowMagnificationInternal(
        verify(mSpyController, atLeast(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -299,7 +299,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
            advanceTimeBy(mWaitAnimationDuration);
        });

        verify(mSpyController, atLeast(2)).enableWindowMagnificationInternal(
        verify(mSpyController, atLeast(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -341,7 +341,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
            advanceTimeBy(mWaitAnimationDuration);
        });

        verify(mSpyController, atLeast(2)).enableWindowMagnificationInternal(
        verify(mSpyController, atLeast(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -377,7 +377,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
            advanceTimeBy(mWaitAnimationDuration);
        });

        verify(mSpyController, atLeast(2)).enableWindowMagnificationInternal(
        verify(mSpyController, atLeast(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -439,7 +439,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
        enableWindowMagnificationAndWaitAnimating(
                mWaitAnimationDuration, Float.NaN, Float.NaN, Float.NaN, mAnimationCallback2);

        verify(mSpyController, never()).enableWindowMagnificationInternal(anyFloat(), anyFloat(),
        verify(mSpyController, never()).updateWindowMagnificationInternal(anyFloat(), anyFloat(),
                anyFloat());
        verify(mAnimationCallback).onResult(false);
        verify(mAnimationCallback2).onResult(true);
@@ -479,7 +479,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
        // Verify the method is called in
        // {@link ValueAnimator.AnimatorUpdateListener#onAnimationUpdate} once and
        // {@link Animator.AnimatorListener#onAnimationEnd} once in {@link ValueAnimator#end()}
        verify(mSpyController, times(2)).enableWindowMagnificationInternal(
        verify(mSpyController, times(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -526,7 +526,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
        enableWindowMagnificationAndWaitAnimating(mWaitAnimationDuration, Float.NaN,
                Float.NaN, Float.NaN, mAnimationCallback2);

        verify(mSpyController, never()).enableWindowMagnificationInternal(anyFloat(), anyFloat(),
        verify(mSpyController, never()).updateWindowMagnificationInternal(anyFloat(), anyFloat(),
                anyFloat());
        verify(mSpyController, never()).deleteWindowMagnification();
        verify(mAnimationCallback).onResult(false);
@@ -551,7 +551,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
            advanceTimeBy(mWaitAnimationDuration);
        });

        verify(mSpyController, atLeast(2)).enableWindowMagnificationInternal(
        verify(mSpyController, atLeast(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -720,7 +720,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {

        enableWindowMagnificationAndWaitAnimating(mWaitAnimationDuration, mAnimationCallback);

        verify(mSpyController, never()).enableWindowMagnificationInternal(anyFloat(), anyFloat(),
        verify(mSpyController, never()).updateWindowMagnificationInternal(anyFloat(), anyFloat(),
                anyFloat());
        verify(mAnimationCallback).onResult(true);
    }
@@ -733,7 +733,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
        resetMockObjects();
        deleteWindowMagnificationAndWaitAnimating(mWaitAnimationDuration, mAnimationCallback);

        verify(mSpyController, atLeast(2)).enableWindowMagnificationInternal(
        verify(mSpyController, atLeast(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -790,7 +790,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
        // Verify the method is called in
        // {@link ValueAnimator.AnimatorUpdateListener#onAnimationUpdate} once and
        // {@link Animator.AnimatorListener#onAnimationEnd} once in {@link ValueAnimator#end()}
        verify(mSpyController, times(2)).enableWindowMagnificationInternal(
        verify(mSpyController, times(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -835,7 +835,7 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
        // {@link ValueAnimator.AnimatorUpdateListener#onAnimationUpdate} once and
        // {@link Animator.AnimatorListener#onAnimationEnd} once when running the animation at
        // the final duration time.
        verify(mSpyController, times(2)).enableWindowMagnificationInternal(
        verify(mSpyController, times(2)).updateWindowMagnificationInternal(
                mScaleCaptor.capture(),
                mCenterXCaptor.capture(), mCenterYCaptor.capture(),
                mOffsetXCaptor.capture(), mOffsetYCaptor.capture());
@@ -1040,17 +1040,17 @@ public class WindowMagnificationAnimationControllerTest extends SysuiTestCase {
        }

        @Override
        void enableWindowMagnificationInternal(float scale, float centerX, float centerY) {
            super.enableWindowMagnificationInternal(scale, centerX, centerY);
            mSpyController.enableWindowMagnificationInternal(scale, centerX, centerY);
        void updateWindowMagnificationInternal(float scale, float centerX, float centerY) {
            super.updateWindowMagnificationInternal(scale, centerX, centerY);
            mSpyController.updateWindowMagnificationInternal(scale, centerX, centerY);
        }

        @Override
        void enableWindowMagnificationInternal(float scale, float centerX, float centerY,
        void updateWindowMagnificationInternal(float scale, float centerX, float centerY,
                float magnificationOffsetFrameRatioX, float magnificationOffsetFrameRatioY) {
            super.enableWindowMagnificationInternal(scale, centerX, centerY,
            super.updateWindowMagnificationInternal(scale, centerX, centerY,
                    magnificationOffsetFrameRatioX, magnificationOffsetFrameRatioY);
            mSpyController.enableWindowMagnificationInternal(scale, centerX, centerY,
            mSpyController.updateWindowMagnificationInternal(scale, centerX, centerY,
                    magnificationOffsetFrameRatioX, magnificationOffsetFrameRatioY);
        }

+45 −45

File changed.

Preview size limit exceeded, changes collapsed.

+45 −45

File changed.

Preview size limit exceeded, changes collapsed.