Archived
Added support for obeying system dark mode toggle on Android 10
This commit is contained in:
@@ -73,50 +73,32 @@ internal class Main : AppCompatActivity(R.layout.app_bar_main) {
|
||||
|
||||
setTheme(R.style.AppTheme0)
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
window.statusBarColor = ContextCompat.getColor(this,
|
||||
R.color.legacyBlack
|
||||
)
|
||||
window.navigationBarColor = ContextCompat.getColor(this,
|
||||
R.color.legacyBlack
|
||||
)
|
||||
}
|
||||
|
||||
when (prefs.getInt("themeInt", 0)) {
|
||||
0 -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (Build.VERSION.SDK_INT in 23..28) {
|
||||
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
window.statusBarColor = ContextCompat.getColor(this,
|
||||
R.color.colorBackground
|
||||
)
|
||||
window.navigationBarColor = ContextCompat.getColor(this,
|
||||
R.color.colorBackground
|
||||
)
|
||||
} else {
|
||||
window.statusBarColor = ContextCompat.getColor(this,
|
||||
R.color.legacyBlack
|
||||
)
|
||||
window.navigationBarColor = ContextCompat.getColor(this,
|
||||
R.color.legacyBlack
|
||||
)
|
||||
window.navigationBarColor = ContextCompat.getColor(context, R.color.colorBackground)
|
||||
}
|
||||
}
|
||||
2 -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
|
||||
}
|
||||
else -> {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
window.navigationBarColor = ContextCompat.getColor(this,
|
||||
R.color.colorBackground
|
||||
)
|
||||
window.statusBarColor = ContextCompat.getColor(this,
|
||||
R.color.colorBackground
|
||||
)
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) {
|
||||
window.navigationBarColor = ContextCompat.getColor(context, R.color.colorBackground)
|
||||
}
|
||||
}
|
||||
// else -> {
|
||||
// when (context.resources.configuration.uiMode) {
|
||||
// Configuration.UI_MODE_NIGHT_YES, Configuration.UI_MODE_NIGHT_UNDEFINED -> {
|
||||
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
// window.navigationBarColor = ContextCompat.getColor(this, R.color.background)
|
||||
// }
|
||||
// }
|
||||
// Configuration.UI_MODE_NIGHT_NO -> {
|
||||
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES)
|
||||
// window.navigationBarColor = ContextCompat.getColor(this, R.color.background)
|
||||
// }
|
||||
// }
|
||||
// } // TODO theming based on system settings for Android Q
|
||||
}
|
||||
|
||||
if (!prefs.getBoolean("autoRefresh", false) && prefs.getInt("firstTimeOpening", 0) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user