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,37 @@ 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 attributes = intArrayOf(android.R.attr.enforceNavigationBarContrast)
val typedArray = context.theme.obtainStyledAttributes(attributes)

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

isStatusBarContrastEnforced = false
isNavigationBarContrastEnforced = true
}
isNavigationBarContrastEnforced = enforceNavigationBarContrast

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 (enforceNavigationBarContrast) {
insetsController.isAppearanceLightNavigationBars = !isDarkMode
}
} else {
val isAppearanceLightNavigationBars =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isDarkMode

navigationBarColor =
if (isAppearanceLightNavigationBars) LightNavigationBarColor else DarkNavigationBarColor
insetsController.isAppearanceLightNavigationBars = isAppearanceLightNavigationBars
}

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