Skip to content

Commit

Permalink
Fix behavior when switching to full-screen mode, hide system bars.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Nov 4, 2022
1 parent 6c15b14 commit 6b87a36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ private void showSystemUi() {
}

final var window = activity.getWindow();
WindowCompat.setDecorFitsSystemWindows(window, false);
WindowCompat.setDecorFitsSystemWindows(window, true);
WindowCompat.getInsetsController(window, window.getDecorView())
.show(WindowInsetsCompat.Type.systemBars());
window.setStatusBarColor(ThemeHelper.resolveColorFromAttr(requireContext(),
Expand All @@ -2029,20 +2029,12 @@ private void hideSystemUi() {
final var windowInsetsController = WindowCompat.getInsetsController(window,
window.getDecorView());

WindowCompat.setDecorFitsSystemWindows(window, true);
WindowCompat.setDecorFitsSystemWindows(window, false);
windowInsetsController.setSystemBarsBehavior(WindowInsetsControllerCompat
.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
int flags = WindowInsetsCompat.Type.navigationBars();

// In multiWindow mode status bar is not transparent for devices with cutout
// if I include this flag. So without it is better in this case
final boolean isInMultiWindow = DeviceUtils.isInMultiWindow(activity);
if (!isInMultiWindow) {
flags |= WindowInsetsCompat.Type.statusBars();
}
windowInsetsController.hide(flags);
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());

if (isInMultiWindow || isFullscreen()) {
if (DeviceUtils.isInMultiWindow(activity) || isFullscreen()) {
window.setStatusBarColor(Color.TRANSPARENT);
window.setNavigationBarColor(Color.TRANSPARENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public void showSystemUIPartially() {
window.setNavigationBarColor(Color.TRANSPARENT);
WindowCompat.setDecorFitsSystemWindows(window, false);
WindowCompat.getInsetsController(window, window.getDecorView())
.hide(WindowInsetsCompat.Type.statusBars());
.show(WindowInsetsCompat.Type.statusBars());
});
}
}
Expand Down

0 comments on commit 6b87a36

Please sign in to comment.