Skip to content

Commit 8408a66

Browse files
klirktagslouken
authored andcommitted
Android: restore the system bars when leaving fullscreen on API 30+
My old PR #15867 switched the fullscreen path to WindowInsetsController.hide() for API 30+, because the legacy setSystemUiVisibility() flags are ignored on API 30+. The leaving fullscreen path was left untouched: it still calls setSystemUiVisibility(SYSTEM_UI_FLAG_VISIBLE), which is equally ignored on API 30+. As a result, once fullscreen had hidden the status/navigation bars, they never came back when returning to windowed mode.
1 parent edafd51 commit 8408a66

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

android-project/app/src/main/java/org/libsdl/app/SDLActivity.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,22 @@ public void handleMessage(Message msg) {
10121012
}
10131013
SDLActivity.mFullscreenModeActive = true;
10141014
} else {
1015-
int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_VISIBLE;
1016-
window.getDecorView().setSystemUiVisibility(flags);
1017-
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
1018-
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
1015+
if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {
1016+
// The legacy setSystemUiVisibility() flags are ignored on
1017+
// API 30+, so the bars hidden by the modern enter path above
1018+
// would never come back. Restore them via WindowInsetsController.
1019+
final WindowInsetsController controller = window.getInsetsController();
1020+
if (controller != null) {
1021+
controller.setSystemBarsBehavior(
1022+
WindowInsetsController.BEHAVIOR_DEFAULT);
1023+
controller.show(WindowInsets.Type.systemBars());
1024+
}
1025+
} else {
1026+
int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_VISIBLE;
1027+
window.getDecorView().setSystemUiVisibility(flags);
1028+
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
1029+
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
1030+
}
10191031
SDLActivity.mFullscreenModeActive = false;
10201032
}
10211033
if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {

0 commit comments

Comments
 (0)