@@ -106,23 +106,40 @@ private fun Window.statusBarShow() {
106106internal fun Window.enableEdgeToEdge () {
107107 WindowCompat .setDecorFitsSystemWindows(this , false )
108108
109+ val insetsController = WindowInsetsControllerCompat (this , decorView)
109110 val isDarkMode = UiModeUtils .isDarkMode(context)
110111
112+ statusBarColor = Color .TRANSPARENT
113+
111114 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
115+ navigationBarColor = Color .TRANSPARENT
116+
117+ val attrs = intArrayOf(android.R .attr.enforceNavigationBarContrast)
118+ val typedArray = context.theme.obtainStyledAttributes(attrs)
119+
120+ val isContrastEnforced =
121+ try {
122+ typedArray.getBoolean(0 , true )
123+ } finally {
124+ typedArray.recycle()
125+ }
126+
112127 isStatusBarContrastEnforced = false
113- isNavigationBarContrastEnforced = true
114- }
128+ isNavigationBarContrastEnforced = isContrastEnforced
115129
116- statusBarColor = Color .TRANSPARENT
117- navigationBarColor =
118- when {
119- Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q -> Color .TRANSPARENT
120- Build .VERSION .SDK_INT >= Build .VERSION_CODES .O && ! isDarkMode -> LightNavigationBarColor
121- else -> DarkNavigationBarColor
122- }
123-
124- WindowInsetsControllerCompat (this , decorView).run {
125- isAppearanceLightNavigationBars = ! isDarkMode
130+ if (isContrastEnforced) {
131+ insetsController.isAppearanceLightNavigationBars = ! isDarkMode
132+ }
133+ } else {
134+ val isAppearanceLight = Build .VERSION .SDK_INT >= Build .VERSION_CODES .O && ! isDarkMode
135+
136+ navigationBarColor =
137+ when {
138+ isAppearanceLight -> LightNavigationBarColor
139+ else -> DarkNavigationBarColor
140+ }
141+
142+ insetsController.isAppearanceLightNavigationBars = isAppearanceLight
126143 }
127144
128145 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .P ) {
0 commit comments