Skip to content

Commit

Permalink
Refactor: Handle deprecation for Wiindow.set{Status,Navigation}BarColor
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghai committed Nov 2, 2024
1 parent fc686a8 commit 93ff0bc
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,19 @@ fun AppTheme(
val insetsController = WindowCompat.getInsetsController(window, view)
val lightSystemBars = !(windowIsTranslucent || darkTheme)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.statusBarColor = Color.Transparent.toArgb()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
@Suppress("DEPRECATION")
window.statusBarColor = Color.Transparent.toArgb()
}
insetsController.isAppearanceLightStatusBars = lightSystemBars
}
// android:windowLightNavigationBar is API 27 despite that
// View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR is API 26.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
window.navigationBarColor = Color.Transparent.toArgb()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) {
@Suppress("DEPRECATION")
window.navigationBarColor = Color.Transparent.toArgb()
}
insetsController.isAppearanceLightNavigationBars = lightSystemBars
}
}
Expand Down

0 comments on commit 93ff0bc

Please sign in to comment.