Merge "Vertically center app in landscape size compat mode" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5e30b0076c
@@ -7511,7 +7511,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
/**
|
||||
* Adjusts horizontal position of resolved bounds if they doesn't fill the parent using gravity
|
||||
* requested in the config or via an ADB command. For more context see {@link
|
||||
* WindowManagerService#getLetterboxHorizontalPositionMultiplier}.
|
||||
* LetterboxUiController#getHorizontalPositionMultiplier(Configuration)}.
|
||||
*/
|
||||
private void updateResolvedBoundsHorizontalPosition(Configuration newParentConfiguration) {
|
||||
final Configuration resolvedConfig = getResolvedOverrideConfiguration();
|
||||
@@ -7848,7 +7848,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
// Below figure is an example that puts an activity which was launched in a larger container
|
||||
// into a smaller container.
|
||||
// The outermost rectangle is the real display bounds.
|
||||
// "@" is the container app bounds (parent bounds or fixed orientation bouds)
|
||||
// "@" is the container app bounds (parent bounds or fixed orientation bounds)
|
||||
// "#" is the {@code resolvedBounds} that applies to application.
|
||||
// "*" is the {@code mSizeCompatBounds} that used to show on screen if scaled.
|
||||
// ------------------------------
|
||||
@@ -7891,12 +7891,15 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
mSizeCompatBounds = null;
|
||||
}
|
||||
|
||||
// Align to top of parent (bounds) - this is a UX choice and exclude the horizontal decor
|
||||
// if needed. Horizontal position is adjusted in updateResolvedBoundsHorizontalPosition.
|
||||
// Vertically center within parent (bounds) - this is a UX choice and exclude the horizontal
|
||||
// decor if needed. Horizontal position is adjusted in
|
||||
// updateResolvedBoundsHorizontalPosition.
|
||||
// Above coordinates are in "@" space, now place "*" and "#" to screen space.
|
||||
final boolean fillContainer = resolvedBounds.equals(containingBounds);
|
||||
final int screenPosX = fillContainer ? containerBounds.left : containerAppBounds.left;
|
||||
final int screenPosY = containerBounds.top;
|
||||
final int screenPosY = mSizeCompatBounds == null
|
||||
? (containerBounds.height() - resolvedBounds.height()) / 2
|
||||
: (containerBounds.height() - mSizeCompatBounds.height()) / 2;
|
||||
if (screenPosX != 0 || screenPosY != 0) {
|
||||
if (mSizeCompatBounds != null) {
|
||||
mSizeCompatBounds.offset(screenPosX, screenPosY);
|
||||
|
||||
@@ -174,7 +174,9 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
|
||||
// The activity should be able to accept negative x position [-150, 100 - 150, 600].
|
||||
final int dx = bounds.left + bounds.width() / 2;
|
||||
mTask.setBounds(bounds.left - dx, bounds.top, bounds.right - dx, bounds.bottom);
|
||||
final int dy = bounds.top + bounds.height() / 2;
|
||||
mTask.setBounds(bounds.left - dx, bounds.top - dy, bounds.right - dx, bounds.bottom - dy);
|
||||
// expected:<Rect(-150, 100 - 150, 600)> but was:<Rect(-150, 0 - 150, 500)>
|
||||
assertEquals(mTask.getBounds(), mActivity.getBounds());
|
||||
|
||||
final int density = mActivity.getConfiguration().densityDpi;
|
||||
@@ -1850,7 +1852,7 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
// At launch.
|
||||
/* fixedOrientationLetterbox */ new Rect(0, 0, 700, 1400),
|
||||
// After 90 degree rotation.
|
||||
/* sizeCompatUnscaled */ new Rect(0, 0, 700, 1400),
|
||||
/* sizeCompatUnscaled */ new Rect(0, 700, 700, 2100),
|
||||
// After the display is resized to (700, 1400).
|
||||
/* sizeCompatScaled */ new Rect(0, 0, 350, 700));
|
||||
}
|
||||
@@ -1863,7 +1865,7 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
// At launch.
|
||||
/* fixedOrientationLetterbox */ new Rect(1050, 0, 1750, 1400),
|
||||
// After 90 degree rotation.
|
||||
/* sizeCompatUnscaled */ new Rect(350, 0, 1050, 1400),
|
||||
/* sizeCompatUnscaled */ new Rect(350, 700, 1050, 2100),
|
||||
// After the display is resized to (700, 1400).
|
||||
/* sizeCompatScaled */ new Rect(525, 0, 875, 700));
|
||||
}
|
||||
@@ -1878,7 +1880,7 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
// At launch.
|
||||
/* fixedOrientationLetterbox */ new Rect(1050, 0, 1750, 1400),
|
||||
// After 90 degree rotation.
|
||||
/* sizeCompatUnscaled */ new Rect(350, 0, 1050, 1400),
|
||||
/* sizeCompatUnscaled */ new Rect(350, 700, 1050, 2100),
|
||||
// After the display is resized to (700, 1400).
|
||||
/* sizeCompatScaled */ new Rect(525, 0, 875, 700));
|
||||
|
||||
@@ -1888,7 +1890,7 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
// At launch.
|
||||
/* fixedOrientationLetterbox */ new Rect(1050, 0, 1750, 1400),
|
||||
// After 90 degree rotation.
|
||||
/* sizeCompatUnscaled */ new Rect(350, 0, 1050, 1400),
|
||||
/* sizeCompatUnscaled */ new Rect(350, 700, 1050, 2100),
|
||||
// After the display is resized to (700, 1400).
|
||||
/* sizeCompatScaled */ new Rect(525, 0, 875, 700));
|
||||
}
|
||||
@@ -1901,7 +1903,7 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
// At launch.
|
||||
/* fixedOrientationLetterbox */ new Rect(2100, 0, 2800, 1400),
|
||||
// After 90 degree rotation.
|
||||
/* sizeCompatUnscaled */ new Rect(700, 0, 1400, 1400),
|
||||
/* sizeCompatUnscaled */ new Rect(700, 700, 1400, 2100),
|
||||
// After the display is resized to (700, 1400).
|
||||
/* sizeCompatScaled */ new Rect(1050, 0, 1400, 700));
|
||||
}
|
||||
@@ -2093,7 +2095,7 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
|
||||
assertTrue(mActivity.inSizeCompatMode());
|
||||
// Activity is in size compat mode but not scaled.
|
||||
assertEquals(new Rect(0, 0, 1400, 700), mActivity.getBounds());
|
||||
assertEquals(new Rect(0, 1050, 1400, 1750), mActivity.getBounds());
|
||||
}
|
||||
|
||||
private static WindowState addWindowToActivity(ActivityRecord activity) {
|
||||
|
||||
Reference in New Issue
Block a user