Merge "Constranit the magnification window size for large screen devices" into sc-v2-dev
This commit is contained in:
@@ -1338,6 +1338,7 @@
|
|||||||
<dimen name="magnifier_up_down_controls_height">40dp</dimen>
|
<dimen name="magnifier_up_down_controls_height">40dp</dimen>
|
||||||
<!-- The extra padding to show the whole outer border -->
|
<!-- The extra padding to show the whole outer border -->
|
||||||
<dimen name="magnifier_drag_handle_padding">3dp</dimen>
|
<dimen name="magnifier_drag_handle_padding">3dp</dimen>
|
||||||
|
<dimen name="magnification_max_frame_size">300dp</dimen>
|
||||||
|
|
||||||
<!-- Home Controls -->
|
<!-- Home Controls -->
|
||||||
<dimen name="controls_header_side_margin">4dp</dimen>
|
<dimen name="controls_header_side_margin">4dp</dimen>
|
||||||
|
|||||||
@@ -499,9 +499,12 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setMagnificationFrameWith(Rect windowBounds, int centerX, int centerY) {
|
private void setMagnificationFrameWith(Rect windowBounds, int centerX, int centerY) {
|
||||||
// Sets the initial frame area for the mirror and places it in the center of the display.
|
// Sets the initial frame area for the mirror and place it to the given center on the
|
||||||
final int initSize = Math.min(windowBounds.width(), windowBounds.height()) / 2
|
// display.
|
||||||
+ 2 * mMirrorSurfaceMargin;
|
int initSize = Math.min(windowBounds.width(), windowBounds.height()) / 2;
|
||||||
|
initSize = Math.min(mResources.getDimensionPixelSize(R.dimen.magnification_max_frame_size),
|
||||||
|
initSize);
|
||||||
|
initSize += 2 * mMirrorSurfaceMargin;
|
||||||
final int initX = centerX - initSize / 2;
|
final int initX = centerX - initSize / 2;
|
||||||
final int initY = centerY - initSize / 2;
|
final int initY = centerY - initSize / 2;
|
||||||
mMagnificationFrame.set(initX, initY, initX + initSize, initY + initSize);
|
mMagnificationFrame.set(initX, initY, initX + initSize, initY + initSize);
|
||||||
|
|||||||
@@ -170,6 +170,29 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
|
|||||||
assertFalse(rects.isEmpty());
|
assertFalse(rects.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void enableWindowMagnification_LargeScreen_windowSizeIsConstrained() {
|
||||||
|
final int screenSize = mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.magnification_max_frame_size) * 10;
|
||||||
|
mWindowManager.setWindowBounds(new Rect(0, 0, screenSize, screenSize));
|
||||||
|
//We need to initialize new one because the window size is determined when initialization.
|
||||||
|
final WindowMagnificationController controller = new WindowMagnificationController(mContext,
|
||||||
|
mHandler, mSfVsyncFrameProvider,
|
||||||
|
mMirrorWindowControl, mTransaction, mWindowMagnifierCallback, mSysUiState);
|
||||||
|
|
||||||
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
|
controller.enableWindowMagnification(Float.NaN, Float.NaN,
|
||||||
|
Float.NaN);
|
||||||
|
});
|
||||||
|
|
||||||
|
final int halfScreenSize = screenSize / 2;
|
||||||
|
WindowManager.LayoutParams params = mWindowManager.getLayoutParamsFromAttachedView();
|
||||||
|
// The frame size should be the half of smaller value of window height/width unless it
|
||||||
|
//exceed the max frame size.
|
||||||
|
assertTrue(params.width < halfScreenSize);
|
||||||
|
assertTrue(params.height < halfScreenSize);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deleteWindowMagnification_destroyControl() {
|
public void deleteWindowMagnification_destroyControl() {
|
||||||
mInstrumentation.runOnMainSync(() -> {
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
@@ -318,6 +341,27 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
|
|||||||
mWindowMagnificationController.getCenterY() / testWindowBounds.height(),
|
mWindowMagnificationController.getCenterY() / testWindowBounds.height(),
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void screenSizeIsChangedToLarge_enabled_windowSizeIsConstrained() {
|
||||||
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
|
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
|
||||||
|
Float.NaN);
|
||||||
|
});
|
||||||
|
final int screenSize = mContext.getResources().getDimensionPixelSize(
|
||||||
|
R.dimen.magnification_max_frame_size) * 10;
|
||||||
|
mWindowManager.setWindowBounds(new Rect(0, 0, screenSize, screenSize));
|
||||||
|
|
||||||
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
|
mWindowMagnificationController.onConfigurationChanged(ActivityInfo.CONFIG_SCREEN_SIZE);
|
||||||
|
});
|
||||||
|
|
||||||
|
final int halfScreenSize = screenSize / 2;
|
||||||
|
WindowManager.LayoutParams params = mWindowManager.getLayoutParamsFromAttachedView();
|
||||||
|
// The frame size should be the half of smaller value of window height/width unless it
|
||||||
|
//exceed the max frame size.
|
||||||
|
assertTrue(params.width < halfScreenSize);
|
||||||
|
assertTrue(params.height < halfScreenSize);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onDensityChanged_enabled_updateDimensionsAndResetWindowMagnification() {
|
public void onDensityChanged_enabled_updateDimensionsAndResetWindowMagnification() {
|
||||||
|
|||||||
Reference in New Issue
Block a user