mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-25 10:37:51 +02:00
Pure white light theme
This commit is contained in:
@ -7,6 +7,8 @@ object PreferenceKeys {
|
||||
|
||||
const val themeMode = "pref_theme_mode_key"
|
||||
|
||||
const val themeLight = "pref_theme_light_key"
|
||||
|
||||
const val themeDark = "pref_theme_dark_key"
|
||||
|
||||
const val rotation = "pref_rotation_type_key"
|
||||
|
@ -9,6 +9,9 @@ object PreferenceValues {
|
||||
const val THEME_MODE_DARK = "dark"
|
||||
const val THEME_MODE_SYSTEM = "system"
|
||||
|
||||
const val THEME_LIGHT_DEFAULT = "default"
|
||||
const val THEME_LIGHT_BLUE = "blue"
|
||||
|
||||
const val THEME_DARK_DEFAULT = "default"
|
||||
const val THEME_DARK_BLUE = "blue"
|
||||
const val THEME_DARK_AMOLED = "amoled"
|
||||
|
@ -65,7 +65,9 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun themeMode() = rxPrefs.getString(Keys.themeMode, Values.THEME_MODE_SYSTEM)
|
||||
|
||||
fun themeDark() = prefs.getString(Keys.themeDark, Values.THEME_DARK_DEFAULT)
|
||||
fun themeLight() = prefs.getString(Keys.themeLight, Values.THEME_DARK_DEFAULT)
|
||||
|
||||
fun themeDark() = prefs.getString(Keys.themeDark, Values.THEME_LIGHT_DEFAULT)
|
||||
|
||||
fun rotation() = rxPrefs.getInteger(Keys.rotation, 1)
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.ui.base.activity
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import eu.kanade.tachiyomi.R
|
||||
@ -18,11 +19,33 @@ abstract class BaseActivity : AppCompatActivity() {
|
||||
@Suppress("LeakingThis")
|
||||
private val secureActivityDelegate = SecureActivityDelegate(this)
|
||||
|
||||
private val lightTheme: Int by lazy {
|
||||
when (preferences.themeLight()) {
|
||||
Values.THEME_LIGHT_BLUE -> R.style.Theme_Tachiyomi_LightBlue
|
||||
else -> {
|
||||
when {
|
||||
// Light status + navigation bar
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 -> {
|
||||
R.style.Theme_Tachiyomi_Light_Api27
|
||||
}
|
||||
// Light status bar + fallback gray navigation bar
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> {
|
||||
R.style.Theme_Tachiyomi_Light_Api23
|
||||
}
|
||||
// Fallback gray status + navigation bar
|
||||
else -> {
|
||||
R.style.Theme_Tachiyomi_Light
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val darkTheme: Int by lazy {
|
||||
when (preferences.themeDark()) {
|
||||
Values.THEME_DARK_DEFAULT -> R.style.Theme_Tachiyomi_Dark
|
||||
Values.THEME_DARK_BLUE -> R.style.Theme_Tachiyomi_DarkBlue
|
||||
Values.THEME_DARK_AMOLED -> R.style.Theme_Tachiyomi_Amoled
|
||||
else -> R.style.Theme_Tachiyomi_DarkBlue
|
||||
else -> R.style.Theme_Tachiyomi_Dark
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,15 +56,15 @@ abstract class BaseActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(when (preferences.themeMode().getOrDefault()) {
|
||||
Values.THEME_MODE_DARK -> darkTheme
|
||||
Values.THEME_MODE_SYSTEM -> {
|
||||
if (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES) {
|
||||
darkTheme
|
||||
} else {
|
||||
R.style.Theme_Tachiyomi
|
||||
lightTheme
|
||||
}
|
||||
}
|
||||
else -> R.style.Theme_Tachiyomi
|
||||
Values.THEME_MODE_DARK -> darkTheme
|
||||
else -> lightTheme
|
||||
})
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -118,6 +118,28 @@ class SettingsGeneralController : SettingsController() {
|
||||
true
|
||||
}
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.themeLight
|
||||
titleRes = R.string.pref_theme_light
|
||||
entriesRes = arrayOf(
|
||||
R.string.theme_light_default,
|
||||
R.string.theme_light_blue)
|
||||
entryValues = arrayOf(
|
||||
Values.THEME_LIGHT_DEFAULT,
|
||||
Values.THEME_LIGHT_BLUE)
|
||||
defaultValue = Values.THEME_LIGHT_DEFAULT
|
||||
summary = "%s"
|
||||
|
||||
preferences.themeMode().asObservable()
|
||||
.subscribeUntilDestroy { isVisible = it != Values.THEME_MODE_DARK }
|
||||
|
||||
onChange {
|
||||
if (preferences.themeMode().getOrDefault() == Values.THEME_MODE_LIGHT) {
|
||||
activity?.recreate()
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.themeDark
|
||||
titleRes = R.string.pref_theme_dark
|
||||
|
Reference in New Issue
Block a user