From a3b6baceadcc5cb806cef77e5e71758ce6c72791 Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Thu, 21 May 2026 11:31:33 +0200 Subject: [PATCH] Stop syncing system bars from activity on Android --- .../react/views/modal/ReactModalHostView.kt | 60 ------------------- 1 file changed, 60 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt index f36a1e3e1386..e704143c009c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt @@ -14,7 +14,6 @@ import android.app.Activity import android.app.Dialog import android.content.Context import android.content.DialogInterface -import android.os.Build import android.view.KeyEvent import android.view.MotionEvent import android.view.View @@ -27,8 +26,6 @@ import android.widget.FrameLayout import androidx.activity.ComponentDialog import androidx.activity.OnBackPressedCallback import androidx.annotation.UiThread -import androidx.core.view.WindowInsetsCompat -import androidx.core.view.WindowInsetsControllerCompat import com.facebook.common.logging.FLog import com.facebook.react.R import com.facebook.react.bridge.GuardedRunnable @@ -342,7 +339,6 @@ public class ReactModalHostView(context: ThemedReactContext) : } if (currentActivity?.isFinishing == false) { newDialog.show() - updateSystemAppearance() window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) (context as ThemedReactContext).onExtraWindowCreate(window) } @@ -415,62 +411,6 @@ public class ReactModalHostView(context: ThemedReactContext) : } } - /** - * Updates the system appearance of the dialog to match the activity that it is being displayed - * on. - */ - private fun updateSystemAppearance() { - val currentActivity = getCurrentActivity() ?: return - val dialog = checkNotNull(dialog) { "dialog must exist when we call updateProperties" } - val dialogWindow = - checkNotNull(dialog.window) { "dialog must have window when we call updateProperties" } - val activityWindow = currentActivity.window - // Modeled after the version check in StatusBarModule.setStyle - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) { - val activityWindowInsetsController = - WindowInsetsControllerCompat(activityWindow, activityWindow.decorView) - val dialogWindowInsetsController = - WindowInsetsControllerCompat(dialogWindow, dialogWindow.decorView) - - if (isEdgeToEdgeFeatureFlagOn) { - activityWindowInsetsController.systemBarsBehavior = - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE - dialogWindowInsetsController.systemBarsBehavior = - WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE - } - - dialogWindowInsetsController.isAppearanceLightStatusBars = - activityWindowInsetsController.isAppearanceLightStatusBars - - activityWindow.decorView.rootWindowInsets?.let { insets -> - val activityRootWindowInsets = WindowInsetsCompat.toWindowInsetsCompat(insets) - syncSystemBarsVisibility(activityRootWindowInsets, dialogWindowInsetsController) - } - } else { - dialogWindow.decorView.systemUiVisibility = activityWindow.decorView.systemUiVisibility - } - } - - /** - * Syncs the visibility of the system bars based on their visibility in the root window insets. - * This ensures consistency between the system bars visibility in the activity and the dialog. - */ - private fun syncSystemBarsVisibility( - activityRootWindowInsets: WindowInsetsCompat, - dialogWindowInsetsController: WindowInsetsControllerCompat?, - types: List = - listOf(WindowInsetsCompat.Type.statusBars(), WindowInsetsCompat.Type.navigationBars()), - ) { - types.forEach { type -> - val isVisible = activityRootWindowInsets.isVisible(type) - if (isVisible) { - dialogWindowInsetsController?.show(type) - } else { - dialogWindowInsetsController?.hide(type) - } - } - } - /** * Sets the testID on the DialogRootViewGroup. Since the accessibility events are not triggered on * the on the ReactModalHostView, the testID is forwarded to the DialogRootViewGroup to set the