Merge branch 'fix-12' into master

# Conflicts:
#	.github/ISSUE_TEMPLATE.md
#	.github/ISSUE_TEMPLATE/report_issue.yml
#	.github/ISSUE_TEMPLATE/request_feature.yml
This commit is contained in:
arkon
2021-08-06 17:33:24 -04:00
10 changed files with 23 additions and 67 deletions

View File

@@ -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
}