2727import android .graphics .Rect ;
2828import android .graphics .drawable .Drawable ;
2929import android .net .Uri ;
30- import android .os .Build ;
3130import android .os .Bundle ;
3231import android .os .Handler ;
3332import android .os .Looper ;
5554import androidx .appcompat .widget .Toolbar ;
5655import androidx .coordinatorlayout .widget .CoordinatorLayout ;
5756import androidx .core .content .ContextCompat ;
57+ import androidx .core .view .WindowCompat ;
58+ import androidx .core .view .WindowInsetsCompat ;
59+ import androidx .core .view .WindowInsetsControllerCompat ;
5860import androidx .preference .PreferenceManager ;
5961
6062import com .google .android .exoplayer2 .PlaybackException ;
@@ -1959,15 +1961,17 @@ private void showSystemUi() {
19591961 return ;
19601962 }
19611963
1962- // Prevent jumping of the player on devices with cutout
1963- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
1964- activity .getWindow ().getAttributes ().layoutInDisplayCutoutMode =
1965- WindowManager .LayoutParams .LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT ;
1966- }
1967- activity .getWindow ().getDecorView ().setSystemUiVisibility (0 );
1968- activity .getWindow ().clearFlags (WindowManager .LayoutParams .FLAG_FULLSCREEN );
1969- activity .getWindow ().setStatusBarColor (ThemeHelper .resolveColorFromAttr (
1970- requireContext (), android .R .attr .colorPrimary ));
1964+ final var window = activity .getWindow ();
1965+ final var windowInsetsController = WindowCompat .getInsetsController (window ,
1966+ window .getDecorView ());
1967+
1968+ WindowCompat .setDecorFitsSystemWindows (window , true );
1969+ windowInsetsController .setSystemBarsBehavior (WindowInsetsControllerCompat
1970+ .BEHAVIOR_SHOW_BARS_BY_TOUCH );
1971+ windowInsetsController .show (WindowInsetsCompat .Type .systemBars ());
1972+
1973+ window .setStatusBarColor (ThemeHelper .resolveColorFromAttr (requireContext (),
1974+ android .R .attr .colorPrimary ));
19711975 }
19721976
19731977 private void hideSystemUi () {
@@ -1979,30 +1983,19 @@ private void hideSystemUi() {
19791983 return ;
19801984 }
19811985
1982- // Prevent jumping of the player on devices with cutout
1983- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
1984- activity .getWindow ().getAttributes ().layoutInDisplayCutoutMode =
1985- WindowManager .LayoutParams .LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES ;
1986- }
1987- int visibility = View .SYSTEM_UI_FLAG_LAYOUT_STABLE
1988- | View .SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
1989- | View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
1990- | View .SYSTEM_UI_FLAG_HIDE_NAVIGATION
1991- | View .SYSTEM_UI_FLAG_IMMERSIVE_STICKY ;
1986+ final var window = activity .getWindow ();
1987+ final var windowInsetsController = WindowCompat .getInsetsController (window ,
1988+ window .getDecorView ());
19921989
1993- // In multiWindow mode status bar is not transparent for devices with cutout
1994- // if I include this flag. So without it is better in this case
1995- final boolean isInMultiWindow = DeviceUtils .isInMultiWindow (activity );
1996- if (!isInMultiWindow ) {
1997- visibility |= View .SYSTEM_UI_FLAG_FULLSCREEN ;
1998- }
1999- activity .getWindow ().getDecorView ().setSystemUiVisibility (visibility );
1990+ WindowCompat .setDecorFitsSystemWindows (window , false );
1991+ windowInsetsController .setSystemBarsBehavior (WindowInsetsControllerCompat
1992+ .BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE );
1993+ windowInsetsController .hide (WindowInsetsCompat .Type .systemBars ());
20001994
2001- if (isInMultiWindow || isFullscreen ()) {
2002- activity . getWindow () .setStatusBarColor (Color .TRANSPARENT );
2003- activity . getWindow () .setNavigationBarColor (Color .TRANSPARENT );
1995+ if (DeviceUtils . isInMultiWindow ( activity ) || isFullscreen ()) {
1996+ window .setStatusBarColor (Color .TRANSPARENT );
1997+ window .setNavigationBarColor (Color .TRANSPARENT );
20041998 }
2005- activity .getWindow ().clearFlags (WindowManager .LayoutParams .FLAG_FULLSCREEN );
20061999 }
20072000
20082001 // Listener implementation
0 commit comments