mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Minor system theme tweaks
This commit is contained in:
parent
02b5c3da71
commit
9942227c6c
5 changed files with 22 additions and 18 deletions
|
@ -6,14 +6,11 @@ package eu.kanade.tachiyomi.data.preference
|
||||||
object PreferenceValues {
|
object PreferenceValues {
|
||||||
|
|
||||||
const val THEME_MODE_LIGHT = "light"
|
const val THEME_MODE_LIGHT = "light"
|
||||||
|
|
||||||
const val THEME_MODE_DARK = "dark"
|
const val THEME_MODE_DARK = "dark"
|
||||||
|
|
||||||
const val THEME_MODE_SYSTEM = "system"
|
const val THEME_MODE_SYSTEM = "system"
|
||||||
|
|
||||||
const val THEME_DARK_DEFAULT = "default"
|
const val THEME_DARK_DEFAULT = "default"
|
||||||
|
const val THEME_DARK_BLUE = "blue"
|
||||||
const val THEME_DARK_AMOLED = "amoled"
|
const val THEME_DARK_AMOLED = "amoled"
|
||||||
|
|
||||||
const val THEME_DARK_BLUE = "blue"
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class PreferencesHelper(val context: Context) {
|
||||||
|
|
||||||
fun clear() = prefs.edit().clear().apply()
|
fun clear() = prefs.edit().clear().apply()
|
||||||
|
|
||||||
fun themeMode() = prefs.getString(Keys.themeMode, Values.THEME_MODE_LIGHT)
|
fun themeMode() = rxPrefs.getString(Keys.themeMode, Values.THEME_MODE_LIGHT)
|
||||||
|
|
||||||
fun themeDark() = prefs.getString(Keys.themeDark, Values.THEME_DARK_DEFAULT)
|
fun themeDark() = prefs.getString(Keys.themeDark, Values.THEME_DARK_DEFAULT)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
||||||
|
@ -15,12 +16,13 @@ abstract class BaseActivity : AppCompatActivity() {
|
||||||
|
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
private val darkTheme: Int
|
private val darkTheme: Int by lazy {
|
||||||
get() = when (preferences.themeDark()) {
|
when (preferences.themeDark()) {
|
||||||
Values.THEME_DARK_DEFAULT -> R.style.Theme_Tachiyomi_Dark
|
Values.THEME_DARK_DEFAULT -> R.style.Theme_Tachiyomi_Dark
|
||||||
Values.THEME_DARK_AMOLED -> R.style.Theme_Tachiyomi_Amoled
|
Values.THEME_DARK_AMOLED -> R.style.Theme_Tachiyomi_Amoled
|
||||||
else -> R.style.Theme_Tachiyomi_DarkBlue
|
else -> R.style.Theme_Tachiyomi_DarkBlue
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@Suppress("LeakingThis")
|
@Suppress("LeakingThis")
|
||||||
|
@ -28,10 +30,9 @@ abstract class BaseActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
setTheme(when (preferences.themeMode()) {
|
setTheme(when (preferences.themeMode().getOrDefault()) {
|
||||||
Values.THEME_MODE_LIGHT -> R.style.Theme_Tachiyomi
|
|
||||||
Values.THEME_MODE_DARK -> darkTheme
|
Values.THEME_MODE_DARK -> darkTheme
|
||||||
else -> {
|
Values.THEME_MODE_SYSTEM -> {
|
||||||
val mode = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
|
val mode = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager
|
||||||
if (mode.nightMode == AppCompatDelegate.MODE_NIGHT_YES) {
|
if (mode.nightMode == AppCompatDelegate.MODE_NIGHT_YES) {
|
||||||
darkTheme
|
darkTheme
|
||||||
|
@ -39,7 +40,9 @@ abstract class BaseActivity : AppCompatActivity() {
|
||||||
R.style.Theme_Tachiyomi
|
R.style.Theme_Tachiyomi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else -> R.style.Theme_Tachiyomi
|
||||||
})
|
})
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.setting
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.util.preference.*
|
import eu.kanade.tachiyomi.util.preference.*
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
|
@ -83,17 +84,20 @@ class SettingsGeneralController : SettingsController() {
|
||||||
titleRes = R.string.pref_theme_dark
|
titleRes = R.string.pref_theme_dark
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.theme_dark_default,
|
R.string.theme_dark_default,
|
||||||
R.string.theme_dark_amoled,
|
R.string.theme_dark_blue,
|
||||||
R.string.theme_dark_blue)
|
R.string.theme_dark_amoled)
|
||||||
entryValues = arrayOf(
|
entryValues = arrayOf(
|
||||||
Values.THEME_DARK_DEFAULT,
|
Values.THEME_DARK_DEFAULT,
|
||||||
Values.THEME_DARK_AMOLED,
|
Values.THEME_DARK_BLUE,
|
||||||
Values.THEME_DARK_BLUE)
|
Values.THEME_DARK_AMOLED)
|
||||||
defaultValue = Values.THEME_DARK_DEFAULT
|
defaultValue = Values.THEME_DARK_DEFAULT
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
|
|
||||||
|
preferences.themeMode().asObservable()
|
||||||
|
.subscribeUntilDestroy { isVisible = it != Values.THEME_MODE_LIGHT }
|
||||||
|
|
||||||
onChange {
|
onChange {
|
||||||
if (preferences.themeMode() != Values.THEME_MODE_LIGHT) {
|
if (preferences.themeMode().getOrDefault() != Values.THEME_MODE_LIGHT) {
|
||||||
activity?.recreate()
|
activity?.recreate()
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
|
|
@ -122,10 +122,10 @@
|
||||||
<string name="theme_light">Light</string>
|
<string name="theme_light">Light</string>
|
||||||
<string name="theme_dark">Dark</string>
|
<string name="theme_dark">Dark</string>
|
||||||
<string name="theme_system">Follow system</string>
|
<string name="theme_system">Follow system</string>
|
||||||
<string name="pref_theme_dark">Dark theme</string>
|
<string name="pref_theme_dark">Dark theme variant</string>
|
||||||
<string name="theme_dark_default">Default</string>
|
<string name="theme_dark_default">Default</string>
|
||||||
<string name="theme_dark_amoled">AMOLED</string>
|
|
||||||
<string name="theme_dark_blue">Dark blue</string>
|
<string name="theme_dark_blue">Dark blue</string>
|
||||||
|
<string name="theme_dark_amoled">AMOLED black</string>
|
||||||
<string name="pref_start_screen">Start screen</string>
|
<string name="pref_start_screen">Start screen</string>
|
||||||
<string name="pref_language">Language</string>
|
<string name="pref_language">Language</string>
|
||||||
<string name="system_default">System default</string>
|
<string name="system_default">System default</string>
|
||||||
|
|
Loading…
Reference in a new issue