Loading packages/SystemUI/src/com/android/systemui/accessibility/MagnificationModeSwitch.java +7 −7 Original line number Diff line number Diff line Loading @@ -75,7 +75,6 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL private final SfVsyncFrameCallbackProvider mSfVsyncFrameProvider; private int mMagnificationMode = ACCESSIBILITY_MAGNIFICATION_MODE_NONE; private final LayoutParams mParams; private int mWindowHeight; @VisibleForTesting final Rect mDraggableWindowBounds = new Rect(); private boolean mIsVisible = false; Loading @@ -95,7 +94,6 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL mWindowManager = mContext.getSystemService(WindowManager.class); mSfVsyncFrameProvider = sfVsyncFrameProvider; mParams = createLayoutParams(context); mWindowHeight = mWindowManager.getCurrentWindowMetrics().getBounds().height(); mImageView = imageView; mImageView.setOnTouchListener(this::onTouch); mImageView.setAccessibilityDelegate(new View.AccessibilityDelegate() { Loading Loading @@ -313,12 +311,14 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL void onConfigurationChanged(int configDiff) { if ((configDiff & ActivityInfo.CONFIG_ORIENTATION) != 0) { final Rect previousDraggableBounds = new Rect(mDraggableWindowBounds); mDraggableWindowBounds.set(getDraggableWindowBounds()); // Keep the Y position with the same height ratio before the window height is changed. final int windowHeight = mWindowManager.getCurrentWindowMetrics().getBounds().height(); final float windowHeightFraction = (float) mParams.y / mWindowHeight; mParams.y = (int) (windowHeight * windowHeightFraction); mWindowHeight = windowHeight; // Keep the Y position with the same height ratio before the window bounds and // draggable bounds are changed. final float windowHeightFraction = (float) (mParams.y - previousDraggableBounds.top) / previousDraggableBounds.height(); mParams.y = (int) (windowHeightFraction * mDraggableWindowBounds.height()) + mDraggableWindowBounds.top; stickToScreenEdge(mToLeftScreenEdge); return; } Loading packages/SystemUI/tests/src/com/android/systemui/accessibility/MagnificationModeSwitchTest.java +7 −8 Original line number Diff line number Diff line Loading @@ -59,7 +59,6 @@ import android.os.UserHandle; import android.provider.Settings; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.util.MathUtils; import android.view.Choreographer; import android.view.MotionEvent; import android.view.View; Loading Loading @@ -489,20 +488,20 @@ public class MagnificationModeSwitchTest extends SysuiTestCase { @Test public void onRotationChanged_buttonIsShowing_expectedYPosition() { final Rect windowBounds = mWindowManager.getCurrentWindowMetrics().getBounds(); final int oldWindowHeight = windowBounds.height(); mMagnificationModeSwitch.showButton(ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN); final Rect oldDraggableBounds = new Rect(mMagnificationModeSwitch.mDraggableWindowBounds); final float windowHeightFraction = (float) mWindowManager.getLayoutParamsFromAttachedView().y / oldWindowHeight; (float) (mWindowManager.getLayoutParamsFromAttachedView().y - oldDraggableBounds.top) / oldDraggableBounds.height(); // The window bounds are changed due to the rotation change. // The window bounds and the draggable bounds are changed due to the rotation change. final Rect newWindowBounds = new Rect(0, 0, windowBounds.height(), windowBounds.width()); mWindowManager.setWindowBounds(newWindowBounds); mMagnificationModeSwitch.onConfigurationChanged(ActivityInfo.CONFIG_ORIENTATION); int expectedY = (int) (newWindowBounds.height() * windowHeightFraction); expectedY = MathUtils.constrain(expectedY, mMagnificationModeSwitch.mDraggableWindowBounds.top, mMagnificationModeSwitch.mDraggableWindowBounds.bottom); int expectedY = (int) (windowHeightFraction * mMagnificationModeSwitch.mDraggableWindowBounds.height()) + mMagnificationModeSwitch.mDraggableWindowBounds.top; assertEquals( "The Y position does not keep the same height ratio after the rotation changed.", expectedY, mWindowManager.getLayoutParamsFromAttachedView().y); Loading Loading
packages/SystemUI/src/com/android/systemui/accessibility/MagnificationModeSwitch.java +7 −7 Original line number Diff line number Diff line Loading @@ -75,7 +75,6 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL private final SfVsyncFrameCallbackProvider mSfVsyncFrameProvider; private int mMagnificationMode = ACCESSIBILITY_MAGNIFICATION_MODE_NONE; private final LayoutParams mParams; private int mWindowHeight; @VisibleForTesting final Rect mDraggableWindowBounds = new Rect(); private boolean mIsVisible = false; Loading @@ -95,7 +94,6 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL mWindowManager = mContext.getSystemService(WindowManager.class); mSfVsyncFrameProvider = sfVsyncFrameProvider; mParams = createLayoutParams(context); mWindowHeight = mWindowManager.getCurrentWindowMetrics().getBounds().height(); mImageView = imageView; mImageView.setOnTouchListener(this::onTouch); mImageView.setAccessibilityDelegate(new View.AccessibilityDelegate() { Loading Loading @@ -313,12 +311,14 @@ class MagnificationModeSwitch implements MagnificationGestureDetector.OnGestureL void onConfigurationChanged(int configDiff) { if ((configDiff & ActivityInfo.CONFIG_ORIENTATION) != 0) { final Rect previousDraggableBounds = new Rect(mDraggableWindowBounds); mDraggableWindowBounds.set(getDraggableWindowBounds()); // Keep the Y position with the same height ratio before the window height is changed. final int windowHeight = mWindowManager.getCurrentWindowMetrics().getBounds().height(); final float windowHeightFraction = (float) mParams.y / mWindowHeight; mParams.y = (int) (windowHeight * windowHeightFraction); mWindowHeight = windowHeight; // Keep the Y position with the same height ratio before the window bounds and // draggable bounds are changed. final float windowHeightFraction = (float) (mParams.y - previousDraggableBounds.top) / previousDraggableBounds.height(); mParams.y = (int) (windowHeightFraction * mDraggableWindowBounds.height()) + mDraggableWindowBounds.top; stickToScreenEdge(mToLeftScreenEdge); return; } Loading
packages/SystemUI/tests/src/com/android/systemui/accessibility/MagnificationModeSwitchTest.java +7 −8 Original line number Diff line number Diff line Loading @@ -59,7 +59,6 @@ import android.os.UserHandle; import android.provider.Settings; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.util.MathUtils; import android.view.Choreographer; import android.view.MotionEvent; import android.view.View; Loading Loading @@ -489,20 +488,20 @@ public class MagnificationModeSwitchTest extends SysuiTestCase { @Test public void onRotationChanged_buttonIsShowing_expectedYPosition() { final Rect windowBounds = mWindowManager.getCurrentWindowMetrics().getBounds(); final int oldWindowHeight = windowBounds.height(); mMagnificationModeSwitch.showButton(ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN); final Rect oldDraggableBounds = new Rect(mMagnificationModeSwitch.mDraggableWindowBounds); final float windowHeightFraction = (float) mWindowManager.getLayoutParamsFromAttachedView().y / oldWindowHeight; (float) (mWindowManager.getLayoutParamsFromAttachedView().y - oldDraggableBounds.top) / oldDraggableBounds.height(); // The window bounds are changed due to the rotation change. // The window bounds and the draggable bounds are changed due to the rotation change. final Rect newWindowBounds = new Rect(0, 0, windowBounds.height(), windowBounds.width()); mWindowManager.setWindowBounds(newWindowBounds); mMagnificationModeSwitch.onConfigurationChanged(ActivityInfo.CONFIG_ORIENTATION); int expectedY = (int) (newWindowBounds.height() * windowHeightFraction); expectedY = MathUtils.constrain(expectedY, mMagnificationModeSwitch.mDraggableWindowBounds.top, mMagnificationModeSwitch.mDraggableWindowBounds.bottom); int expectedY = (int) (windowHeightFraction * mMagnificationModeSwitch.mDraggableWindowBounds.height()) + mMagnificationModeSwitch.mDraggableWindowBounds.top; assertEquals( "The Y position does not keep the same height ratio after the rotation changed.", expectedY, mWindowManager.getLayoutParamsFromAttachedView().y); Loading