Use Black as the themeKey for system dark mode on Android

This commit is contained in:
Jackson Harper 2023-04-26 22:53:46 +08:00
parent 29da91e760
commit e9ae10afb7
2 changed files with 5 additions and 4 deletions

View file

@ -47,7 +47,7 @@ fun WebReader(
)
val styledContent = webReaderContent.styledContent()
val isInDarkMode = preferences.themeKey == "Dark"
val isInDarkMode = preferences.themeKey == "Dark" || preferences.themeKey == "Black"
Box {
AndroidView(factory = {

View file

@ -56,7 +56,8 @@ class WebReaderViewModel @Inject constructor(
val showLabelsSelectionSheetLiveData = MutableLiveData(false)
val savedItemLabelsLiveData = dataService.db.savedItemLabelDao().getSavedItemLabelsLiveData()
val systemThemeKeys = listOf("Light", "Dark", "System")
// "Sepia", "Apollo",
val systemThemeKeys = listOf("Light", "Black", "System")
var hasTappedExistingHighlight = false
var lastTapCoordinates: TapCoordinates? = null
@ -279,7 +280,7 @@ class WebReaderViewModel @Inject constructor(
fun themeKey(isDarkMode: Boolean, storedThemePreference: String): String {
if (storedThemePreference == "System") {
return if (isDarkMode) "Dark" else "Light"
return if (isDarkMode) "Black" else "Light"
}
return storedThemePreference
@ -292,7 +293,7 @@ class WebReaderViewModel @Inject constructor(
datastoreRepo.putString(DatastoreKeys.preferredTheme, systemThemeKeys[index])
}
val isDark = newThemeKey == "Dark"
val isDark = newThemeKey == "Dark" || newThemeKey == "Black"
val script = "var event = new Event('updateColorMode');event.isDark = '$isDark';document.dispatchEvent(event);"
enqueueScript(script)
}