mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 14:07:28 +01:00
This reverts commit 7a1b6142df.
This commit is contained in:
@@ -284,24 +284,3 @@ fun Context.isTablet(): Boolean {
|
||||
fun Context.isNightMode(): Boolean {
|
||||
return resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates night mode Context depending on reader theme/background
|
||||
*/
|
||||
fun Context.createReaderThemeContext(readerThemeSelected: Int): Context {
|
||||
val isDarkBackground = when (readerThemeSelected) {
|
||||
1, 2 -> true // Black, Gray
|
||||
3 -> isNightMode() // Automatic bg uses activity background by default
|
||||
else -> false // White
|
||||
}
|
||||
val expected = if (isDarkBackground) Configuration.UI_MODE_NIGHT_YES else Configuration.UI_MODE_NIGHT_NO
|
||||
if (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK != expected) {
|
||||
val overrideConfig = Configuration(resources.configuration).apply {
|
||||
uiMode = (uiMode and Configuration.UI_MODE_NIGHT_MASK.inv()) or expected
|
||||
}
|
||||
return createConfigurationContext(overrideConfig).also {
|
||||
it.theme.setTo(theme)
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user