Skip to content

Commit d3562c7

Browse files
authored
Merge pull request #7451 from Cheechaii/respect-cutout-in-multiwindow
Respect cutouts when playing in MultiWindow
2 parents e8d9095 + c92a907 commit d3562c7

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,9 @@ private void showSystemUi() {
19801980
// Prevent jumping of the player on devices with cutout
19811981
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
19821982
activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
1983-
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
1983+
isMultiWindowOrFullscreen()
1984+
? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
1985+
: WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
19841986
}
19851987
activity.getWindow().getDecorView().setSystemUiVisibility(0);
19861988
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
@@ -2002,7 +2004,9 @@ private void hideSystemUi() {
20022004
// Prevent jumping of the player on devices with cutout
20032005
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
20042006
activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
2005-
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
2007+
isMultiWindowOrFullscreen()
2008+
? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
2009+
: WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
20062010
}
20072011
int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
20082012
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
@@ -2019,7 +2023,7 @@ private void hideSystemUi() {
20192023
activity.getWindow().getDecorView().setSystemUiVisibility(visibility);
20202024

20212025
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
2022-
&& (isInMultiWindow || (isPlayerAvailable() && player.isFullscreen()))) {
2026+
&& isMultiWindowOrFullscreen()) {
20232027
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
20242028
activity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
20252029
}
@@ -2035,6 +2039,11 @@ public void hideSystemUiIfNeeded() {
20352039
}
20362040
}
20372041

2042+
private boolean isMultiWindowOrFullscreen() {
2043+
return DeviceUtils.isInMultiWindow(activity)
2044+
|| (isPlayerAvailable() && player.isFullscreen());
2045+
}
2046+
20382047
private boolean playerIsNotStopped() {
20392048
return isPlayerAvailable() && !player.isStopped();
20402049
}

0 commit comments

Comments
 (0)