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.
This commit is contained in:
klirktag
2026-07-15 00:41:49 +02:00
committed by Sam Lantinga
parent edafd519b9
commit 8408a664e2

View File

@@ -1012,10 +1012,22 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
}
SDLActivity.mFullscreenModeActive = true;
} else {
int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_VISIBLE;
window.getDecorView().setSystemUiVisibility(flags);
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {
// The legacy setSystemUiVisibility() flags are ignored on
// API 30+, so the bars hidden by the modern enter path above
// would never come back. Restore them via WindowInsetsController.
final WindowInsetsController controller = window.getInsetsController();
if (controller != null) {
controller.setSystemBarsBehavior(
WindowInsetsController.BEHAVIOR_DEFAULT);
controller.show(WindowInsets.Type.systemBars());
}
} else {
int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_VISIBLE;
window.getDecorView().setSystemUiVisibility(flags);
window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
SDLActivity.mFullscreenModeActive = false;
}
if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {