Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,40 @@ private fun Window.statusBarShow() {
internal fun Window.enableEdgeToEdge() {
WindowCompat.setDecorFitsSystemWindows(this, false)

val insetsController = WindowInsetsControllerCompat(this, decorView)
val isDarkMode = UiModeUtils.isDarkMode(context)

statusBarColor = Color.TRANSPARENT

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
navigationBarColor = Color.TRANSPARENT

val attrs = intArrayOf(android.R.attr.enforceNavigationBarContrast)
val typedArray = context.theme.obtainStyledAttributes(attrs)

val isContrastEnforced =
try {
typedArray.getBoolean(0, true)
} finally {
typedArray.recycle()
}

isStatusBarContrastEnforced = false
isNavigationBarContrastEnforced = true
}
isNavigationBarContrastEnforced = isContrastEnforced

statusBarColor = Color.TRANSPARENT
navigationBarColor =
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> Color.TRANSPARENT
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isDarkMode -> LightNavigationBarColor
else -> DarkNavigationBarColor
}

WindowInsetsControllerCompat(this, decorView).run {
isAppearanceLightNavigationBars = !isDarkMode
if (isContrastEnforced) {
insetsController.isAppearanceLightNavigationBars = !isDarkMode
}
} else {
val isAppearanceLight = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isDarkMode

navigationBarColor =
when {
isAppearanceLight -> LightNavigationBarColor
else -> DarkNavigationBarColor
}

insetsController.isAppearanceLightNavigationBars = isAppearanceLight
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
Expand Down
Loading