Fix dark theme
This commit is contained in:
parent
829292399b
commit
cbdd1a2538
3 changed files with 18 additions and 21 deletions
|
@ -109,13 +109,13 @@ fun logger(e: Any?, print: Boolean = true) {
|
||||||
fun initActivity(a: Activity) {
|
fun initActivity(a: Activity) {
|
||||||
val window = a.window
|
val window = a.window
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
val darkMode = PrefManager.getNullableVal(PrefName.DarkMode, null as Boolean?)
|
val darkMode = PrefManager.getVal<Int>(PrefName.DarkMode)
|
||||||
val immersiveMode: Boolean = PrefManager.getVal(PrefName.ImmersiveMode)
|
val immersiveMode: Boolean = PrefManager.getVal(PrefName.ImmersiveMode)
|
||||||
darkMode.apply {
|
darkMode.apply {
|
||||||
AppCompatDelegate.setDefaultNightMode(
|
AppCompatDelegate.setDefaultNightMode(
|
||||||
when (this) {
|
when (this) {
|
||||||
true -> AppCompatDelegate.MODE_NIGHT_YES
|
2 -> AppCompatDelegate.MODE_NIGHT_YES
|
||||||
false -> AppCompatDelegate.MODE_NIGHT_NO
|
1 -> AppCompatDelegate.MODE_NIGHT_NO
|
||||||
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -485,21 +485,18 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
startActivity(Intent(this, ReaderSettingsActivity::class.java))
|
startActivity(Intent(this, ReaderSettingsActivity::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
var previous: View = when (PrefManager.getNullableVal(PrefName.DarkMode, null as Boolean?)) {
|
var previous: View = when (PrefManager.getVal<Int>(PrefName.DarkMode)) {
|
||||||
null -> binding.settingsUiAuto
|
0 -> binding.settingsUiAuto
|
||||||
true -> binding.settingsUiDark
|
1 -> binding.settingsUiLight
|
||||||
false -> binding.settingsUiLight
|
2 -> binding.settingsUiDark
|
||||||
|
else -> binding.settingsUiAuto
|
||||||
}
|
}
|
||||||
previous.alpha = 1f
|
previous.alpha = 1f
|
||||||
fun uiTheme(mode: Boolean?, current: View) {
|
fun uiTheme(mode: Int, current: View) {
|
||||||
previous.alpha = 0.33f
|
previous.alpha = 0.33f
|
||||||
previous = current
|
previous = current
|
||||||
current.alpha = 1f
|
current.alpha = 1f
|
||||||
if (mode == null) {
|
PrefManager.setVal(PrefName.DarkMode, mode)
|
||||||
PrefManager.removeVal(PrefName.DarkMode)
|
|
||||||
} else {
|
|
||||||
PrefManager.setVal(PrefName.DarkMode, mode)
|
|
||||||
}
|
|
||||||
Refresh.all()
|
Refresh.all()
|
||||||
finish()
|
finish()
|
||||||
startActivity(Intent(this, SettingsActivity::class.java))
|
startActivity(Intent(this, SettingsActivity::class.java))
|
||||||
|
@ -507,16 +504,16 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.settingsUiAuto.setOnClickListener {
|
binding.settingsUiAuto.setOnClickListener {
|
||||||
uiTheme(null, it)
|
uiTheme(0, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.settingsUiLight.setOnClickListener {
|
binding.settingsUiLight.setOnClickListener {
|
||||||
binding.settingsUseOLED.isChecked = false
|
binding.settingsUseOLED.isChecked = false
|
||||||
uiTheme(false, it)
|
uiTheme(1, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.settingsUiDark.setOnClickListener {
|
binding.settingsUiDark.setOnClickListener {
|
||||||
uiTheme(true, it)
|
uiTheme(2, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
var previousStart: View = when (PrefManager.getVal<Int>(PrefName.DefaultStartUpTab)) {
|
var previousStart: View = when (PrefManager.getVal<Int>(PrefName.DefaultStartUpTab)) {
|
||||||
|
@ -526,7 +523,7 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
else -> binding.uiSettingsHome
|
else -> binding.uiSettingsHome
|
||||||
}
|
}
|
||||||
previousStart.alpha = 1f
|
previousStart.alpha = 1f
|
||||||
fun uiTheme(mode: Int, current: View) {
|
fun uiDefault(mode: Int, current: View) {
|
||||||
previousStart.alpha = 0.33f
|
previousStart.alpha = 0.33f
|
||||||
previousStart = current
|
previousStart = current
|
||||||
current.alpha = 1f
|
current.alpha = 1f
|
||||||
|
@ -536,15 +533,15 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||||
|
|
||||||
|
|
||||||
binding.uiSettingsAnime.setOnClickListener {
|
binding.uiSettingsAnime.setOnClickListener {
|
||||||
uiTheme(0, it)
|
uiDefault(0, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.uiSettingsHome.setOnClickListener {
|
binding.uiSettingsHome.setOnClickListener {
|
||||||
uiTheme(1, it)
|
uiDefault(1, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.uiSettingsManga.setOnClickListener {
|
binding.uiSettingsManga.setOnClickListener {
|
||||||
uiTheme(2, it)
|
uiDefault(2, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.settingsShowYt.isChecked = PrefManager.getVal(PrefName.ShowYtButton)
|
binding.settingsShowYt.isChecked = PrefManager.getVal(PrefName.ShowYtButton)
|
||||||
|
|
|
@ -30,7 +30,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
||||||
UseMaterialYou(Pref(Location.UI, Boolean::class, false)),
|
UseMaterialYou(Pref(Location.UI, Boolean::class, false)),
|
||||||
Theme(Pref(Location.UI, String::class, "PURPLE")),
|
Theme(Pref(Location.UI, String::class, "PURPLE")),
|
||||||
SkipExtensionIcons(Pref(Location.UI, Boolean::class, false)),
|
SkipExtensionIcons(Pref(Location.UI, Boolean::class, false)),
|
||||||
DarkMode(Pref(Location.UI, Boolean::class, true)),
|
DarkMode(Pref(Location.UI, Int::class, 0)),
|
||||||
ShowYtButton(Pref(Location.UI, Boolean::class, true)),
|
ShowYtButton(Pref(Location.UI, Boolean::class, true)),
|
||||||
AnimeDefaultView(Pref(Location.UI, Int::class, 0)),
|
AnimeDefaultView(Pref(Location.UI, Int::class, 0)),
|
||||||
MangaDefaultView(Pref(Location.UI, Int::class, 0)),
|
MangaDefaultView(Pref(Location.UI, Int::class, 0)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue