Skip to content

Commit c92a907

Browse files
committed
Respect cutouts when playing in MultiWindow
1 parent ef91214 commit c92a907

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
@@ -1958,7 +1958,9 @@ private void showSystemUi() {
19581958
// Prevent jumping of the player on devices with cutout
19591959
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
19601960
activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
1961-
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
1961+
isMultiWindowOrFullscreen()
1962+
? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
1963+
: WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
19621964
}
19631965
activity.getWindow().getDecorView().setSystemUiVisibility(0);
19641966
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
@@ -1980,7 +1982,9 @@ private void hideSystemUi() {
19801982
// Prevent jumping of the player on devices with cutout
19811983
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
19821984
activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
1983-
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
1985+
isMultiWindowOrFullscreen()
1986+
? WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
1987+
: WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
19841988
}
19851989
int visibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
19861990
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
@@ -1997,7 +2001,7 @@ private void hideSystemUi() {
19972001
activity.getWindow().getDecorView().setSystemUiVisibility(visibility);
19982002

19992003
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
2000-
&& (isInMultiWindow || (isPlayerAvailable() && player.isFullscreen()))) {
2004+
&& isMultiWindowOrFullscreen()) {
20012005
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
20022006
activity.getWindow().setNavigationBarColor(Color.TRANSPARENT);
20032007
}
@@ -2013,6 +2017,11 @@ public void hideSystemUiIfNeeded() {
20132017
}
20142018
}
20152019

2020+
private boolean isMultiWindowOrFullscreen() {
2021+
return DeviceUtils.isInMultiWindow(activity)
2022+
|| (isPlayerAvailable() && player.isFullscreen());
2023+
}
2024+
20162025
private boolean playerIsNotStopped() {
20172026
return isPlayerAvailable() && !player.isStopped();
20182027
}

0 commit comments

Comments
 (0)