Merge "Letterbox: Display rounded corners behind navigation bar instead of above." into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e6fb34bd90
@@ -65,6 +65,10 @@ final class LetterboxUiController {
|
|||||||
private final LetterboxConfiguration mLetterboxConfiguration;
|
private final LetterboxConfiguration mLetterboxConfiguration;
|
||||||
private final ActivityRecord mActivityRecord;
|
private final ActivityRecord mActivityRecord;
|
||||||
|
|
||||||
|
// Taskbar expanded height. Used to determine whether to crop an app window to display rounded
|
||||||
|
// corners above the taskbar.
|
||||||
|
private float mExpandedTaskBarHeight;
|
||||||
|
|
||||||
private boolean mShowWallpaperForLetterboxBackground;
|
private boolean mShowWallpaperForLetterboxBackground;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -76,6 +80,8 @@ final class LetterboxUiController {
|
|||||||
// is created in its constructor. It shouldn't be used in this constructor but it's safe
|
// is created in its constructor. It shouldn't be used in this constructor but it's safe
|
||||||
// to use it after since controller is only used in ActivityRecord.
|
// to use it after since controller is only used in ActivityRecord.
|
||||||
mActivityRecord = activityRecord;
|
mActivityRecord = activityRecord;
|
||||||
|
mExpandedTaskBarHeight =
|
||||||
|
getResources().getDimensionPixelSize(R.dimen.taskbar_frame_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Cleans up {@link Letterbox} if it exists.*/
|
/** Cleans up {@link Letterbox} if it exists.*/
|
||||||
@@ -314,12 +320,27 @@ final class LetterboxUiController {
|
|||||||
final InsetsSource taskbarInsetsSource =
|
final InsetsSource taskbarInsetsSource =
|
||||||
insetsState.getSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR);
|
insetsState.getSource(InsetsState.ITYPE_EXTRA_NAVIGATION_BAR);
|
||||||
|
|
||||||
Rect cropBounds = new Rect(mActivityRecord.getBounds());
|
Rect cropBounds = null;
|
||||||
// Activity bounds are in screen coordinates while (0,0) for activity's surface control
|
|
||||||
// is at the top left corner of an app window so offsetting bounds accordingly.
|
// Rounded corners should be displayed above the taskbar. When taskbar is hidden,
|
||||||
cropBounds.offsetTo(0, 0);
|
// an insets frame is equal to a navigation bar which shouldn't affect position of
|
||||||
// Rounded cornerners should be displayed above the taskbar.
|
// rounded corners since apps are expected to handle navigation bar inset.
|
||||||
cropBounds.bottom = Math.min(cropBounds.bottom, taskbarInsetsSource.getFrame().top);
|
// This condition checks whether the taskbar is visible.
|
||||||
|
if (taskbarInsetsSource.getFrame().height() >= mExpandedTaskBarHeight) {
|
||||||
|
cropBounds = new Rect(mActivityRecord.getBounds());
|
||||||
|
// Activity bounds are in screen coordinates while (0,0) for activity's surface
|
||||||
|
// control is at the top left corner of an app window so offsetting bounds
|
||||||
|
// accordingly.
|
||||||
|
cropBounds.offsetTo(0, 0);
|
||||||
|
// Rounded cornerners should be displayed above the taskbar.
|
||||||
|
cropBounds.bottom =
|
||||||
|
Math.min(cropBounds.bottom, taskbarInsetsSource.getFrame().top);
|
||||||
|
if (mActivityRecord.inSizeCompatMode()
|
||||||
|
&& mActivityRecord.getSizeCompatScale() < 1.0f) {
|
||||||
|
cropBounds.scale(1.0f / mActivityRecord.getSizeCompatScale());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
transaction
|
transaction
|
||||||
.setWindowCrop(windowSurface, cropBounds)
|
.setWindowCrop(windowSurface, cropBounds)
|
||||||
.setCornerRadius(windowSurface, getRoundedCorners(insetsState));
|
.setCornerRadius(windowSurface, getRoundedCorners(insetsState));
|
||||||
|
|||||||
Reference in New Issue
Block a user