diff --git a/android/src/main/java/com/getcapacitor/community/safearea/SafeArea.kt b/android/src/main/java/com/getcapacitor/community/safearea/SafeArea.kt index f4db684..3d98fcf 100644 --- a/android/src/main/java/com/getcapacitor/community/safearea/SafeArea.kt +++ b/android/src/main/java/com/getcapacitor/community/safearea/SafeArea.kt @@ -12,6 +12,7 @@ import androidx.core.view.WindowInsetsCompat class SafeArea(private val activity: Activity, private val webView: WebView) { var offset = 0 private var appearanceUpdatedInListener = false + private var decorFitsSystemWindowsNegated = false fun enable(updateInsets: Boolean, appearanceConfig: AppearanceConfig) { activity.window.decorView.getRootView().setOnApplyWindowInsetsListener { view, insets -> @@ -28,6 +29,7 @@ class SafeArea(private val activity: Activity, private val webView: WebView) { view.onApplyWindowInsets(insets) } + resetDecorFitsSystemWindows() updateAppearance(appearanceConfig) if (updateInsets) { @@ -45,6 +47,10 @@ class SafeArea(private val activity: Activity, private val webView: WebView) { updateAppearance(appearanceConfig) } + fun resetDecorFitsSystemWindows() { + decorFitsSystemWindowsNegated = false + } + private fun updateAppearance(appearanceConfig: AppearanceConfig) { activity.runOnUiThread { val windowInsetsControllerCompat = @@ -68,7 +74,10 @@ class SafeArea(private val activity: Activity, private val webView: WebView) { private fun updateInsets() { activity.runOnUiThread { - WindowCompat.setDecorFitsSystemWindows(activity.window, false) + if (!decorFitsSystemWindowsNegated) { + decorFitsSystemWindowsNegated = true + WindowCompat.setDecorFitsSystemWindows(activity.window, false) + } val windowInsets = ViewCompat.getRootWindowInsets(activity.window.decorView) val systemBarsInsets = diff --git a/android/src/main/java/com/getcapacitor/community/safearea/SafeAreaPlugin.kt b/android/src/main/java/com/getcapacitor/community/safearea/SafeAreaPlugin.kt index 86a8eb8..160b668 100644 --- a/android/src/main/java/com/getcapacitor/community/safearea/SafeAreaPlugin.kt +++ b/android/src/main/java/com/getcapacitor/community/safearea/SafeAreaPlugin.kt @@ -20,6 +20,11 @@ class SafeAreaPlugin : Plugin() { } } + override fun handleOnPause() { + implementation?.resetDecorFitsSystemWindows() + super.handleOnPause() + } + @PluginMethod(returnType = PluginMethod.RETURN_NONE) fun enable(call: PluginCall) { val jsonObject = call.getObject("config")