diff --git a/domains/android/compose-core/src/main/kotlin/app/dapk/st/core/DapkActivity.kt b/domains/android/compose-core/src/main/kotlin/app/dapk/st/core/DapkActivity.kt index 59cec14..29ee41b 100644 --- a/domains/android/compose-core/src/main/kotlin/app/dapk/st/core/DapkActivity.kt +++ b/domains/android/compose-core/src/main/kotlin/app/dapk/st/core/DapkActivity.kt @@ -1,5 +1,6 @@ package app.dapk.st.core +import android.os.Build import android.os.Bundle import android.view.WindowManager import androidx.activity.ComponentActivity @@ -20,10 +21,13 @@ abstract class DapkActivity : ComponentActivity(), EffectScope { private lateinit var themeConfig: ThemeConfig + private val needsBackLeakWorkaround = Build.VERSION.SDK_INT == Build.VERSION_CODES.Q + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) this.themeConfig = ThemeConfig(themeStore.isMaterialYouEnabled()) + window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); } @@ -53,4 +57,11 @@ abstract class DapkActivity : ComponentActivity(), EffectScope { } } } + + override fun onBackPressed() { + if (needsBackLeakWorkaround && !onBackPressedDispatcher.hasEnabledCallbacks()) { + finishAfterTransition() + } else + super.onBackPressed() + } }