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

Commit e9777562 authored by Minche Li's avatar Minche Li Committed by Automerger Merge Worker
Browse files

Merge "Correct magnification switch button position after screen size is...

Merge "Correct magnification switch button position after screen size is changed" into sc-v2-dev am: 35849cd0 am: 9231c7fc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15175501

Change-Id: I4cfe370808463f6917117309b2220fda341d614d
parents 98ac5f2c 9231c7fc
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -310,7 +310,8 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL
    }

    void onConfigurationChanged(int configDiff) {
        if ((configDiff & ActivityInfo.CONFIG_ORIENTATION) != 0) {
        if ((configDiff & (ActivityInfo.CONFIG_ORIENTATION | ActivityInfo.CONFIG_SCREEN_SIZE))
                != 0) {
            final Rect previousDraggableBounds = new Rect(mDraggableWindowBounds);
            mDraggableWindowBounds.set(getDraggableWindowBounds());
            // Keep the Y position with the same height ratio before the window bounds and
+24 −0
Original line number Diff line number Diff line
@@ -505,6 +505,30 @@ public class MagnificationModeSwitchTest extends SysuiTestCase {
                expectedY, mWindowManager.getLayoutParamsFromAttachedView().y);
    }

    @Test
    public void onScreenSizeChanged_buttonIsShowingOnTheRightSide_expectedPosition() {
        final Rect windowBounds = mWindowManager.getCurrentWindowMetrics().getBounds();
        mMagnificationModeSwitch.showButton(ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN);
        final Rect oldDraggableBounds = new Rect(mMagnificationModeSwitch.mDraggableWindowBounds);
        final float windowHeightFraction =
                (float) (mWindowManager.getLayoutParamsFromAttachedView().y
                        - oldDraggableBounds.top) / oldDraggableBounds.height();

        // The window bounds and the draggable bounds are changed due to the screen size change.
        final Rect tmpRect = new Rect(windowBounds);
        tmpRect.scale(2);
        final Rect newWindowBounds = new Rect(tmpRect);
        mWindowManager.setWindowBounds(newWindowBounds);
        mMagnificationModeSwitch.onConfigurationChanged(ActivityInfo.CONFIG_SCREEN_SIZE);

        final int expectedX = mMagnificationModeSwitch.mDraggableWindowBounds.right;
        final int expectedY = (int) (windowHeightFraction
                * mMagnificationModeSwitch.mDraggableWindowBounds.height())
                + mMagnificationModeSwitch.mDraggableWindowBounds.top;
        assertEquals(expectedX, mWindowManager.getLayoutParamsFromAttachedView().x);
        assertEquals(expectedY, mWindowManager.getLayoutParamsFromAttachedView().y);
    }

    private void assertModeUnchanged(int expectedMode) {
        final int actualMode = Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE, 0);