mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 04:49:15 +01:00
Refactor themepref to use isDarkTheme
This commit is contained in:
parent
225a580018
commit
91498139da
@ -56,8 +56,8 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||||||
selectExtensionLight = fastAdapterLight.getSelectExtension().setThemeListener()
|
selectExtensionLight = fastAdapterLight.getSelectExtension().setThemeListener()
|
||||||
selectExtensionDark = fastAdapterDark.getSelectExtension().setThemeListener()
|
selectExtensionDark = fastAdapterDark.getSelectExtension().setThemeListener()
|
||||||
val enumConstants = Themes.values()
|
val enumConstants = Themes.values()
|
||||||
itemAdapterLight.set(enumConstants.filter { it.nightMode == AppCompatDelegate.MODE_NIGHT_NO }.map(::ThemeItem))
|
itemAdapterLight.set(enumConstants.filter { !it.isDarkTheme }.map(::ThemeItem))
|
||||||
itemAdapterDark.set(enumConstants.filter { it.nightMode == AppCompatDelegate.MODE_NIGHT_YES }.map(::ThemeItem))
|
itemAdapterDark.set(enumConstants.filter { it.isDarkTheme }.map(::ThemeItem))
|
||||||
isSelectable = false
|
isSelectable = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||||||
multiSelect = true
|
multiSelect = true
|
||||||
selectionListener = object : ISelectionListener<ThemeItem> {
|
selectionListener = object : ISelectionListener<ThemeItem> {
|
||||||
override fun onSelectionChanged(item: ThemeItem, selected: Boolean) {
|
override fun onSelectionChanged(item: ThemeItem, selected: Boolean) {
|
||||||
if (item.theme.nightMode == AppCompatDelegate.MODE_NIGHT_YES) {
|
if (item.theme.isDarkTheme) {
|
||||||
preferences.darkTheme().set(item.theme)
|
preferences.darkTheme().set(item.theme)
|
||||||
} else {
|
} else {
|
||||||
preferences.lightTheme().set(item.theme)
|
preferences.lightTheme().set(item.theme)
|
||||||
@ -192,9 +192,9 @@ class ThemePreference @JvmOverloads constructor(context: Context, attrs: Attribu
|
|||||||
|
|
||||||
if (binding.checkbox.isVisible) {
|
if (binding.checkbox.isVisible) {
|
||||||
val themeMatchesApp = if (context.isInNightMode()) {
|
val themeMatchesApp = if (context.isInNightMode()) {
|
||||||
item.theme.nightMode == AppCompatDelegate.MODE_NIGHT_YES
|
item.theme.isDarkTheme
|
||||||
} else {
|
} else {
|
||||||
item.theme.nightMode == AppCompatDelegate.MODE_NIGHT_NO
|
!item.theme.isDarkTheme
|
||||||
}
|
}
|
||||||
binding.themeSelected.alpha = if (themeMatchesApp) 1f else 0.5f
|
binding.themeSelected.alpha = if (themeMatchesApp) 1f else 0.5f
|
||||||
binding.checkbox.alpha = if (themeMatchesApp) 1f else 0.5f
|
binding.checkbox.alpha = if (themeMatchesApp) 1f else 0.5f
|
||||||
|
Loading…
Reference in New Issue
Block a user