pull/1072/head
gedoor 3 years ago
parent 0c8a421e56
commit 3531a631e3
  1. 3
      app/src/main/java/io/legado/app/help/ThemeConfig.kt
  2. 24
      app/src/main/java/io/legado/app/lib/theme/ThemeStore.kt
  3. 6
      app/src/main/java/io/legado/app/lib/theme/ThemeStoreInterface.kt

@ -173,7 +173,6 @@ object ThemeConfig {
when { when {
AppConfig.isEInkMode -> { AppConfig.isEInkMode -> {
ThemeStore.editTheme(this) ThemeStore.editTheme(this)
.coloredNavigationBar(true)
.primaryColor(Color.WHITE) .primaryColor(Color.WHITE)
.accentColor(Color.BLACK) .accentColor(Color.BLACK)
.backgroundColor(Color.WHITE) .backgroundColor(Color.WHITE)
@ -194,7 +193,6 @@ object ThemeConfig {
val bBackground = val bBackground =
getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850)) getPrefInt(PreferKey.cNBBackground, getCompatColor(R.color.md_grey_850))
ThemeStore.editTheme(this) ThemeStore.editTheme(this)
.coloredNavigationBar(true)
.primaryColor(ColorUtils.withAlpha(primary, 1f)) .primaryColor(ColorUtils.withAlpha(primary, 1f))
.accentColor(ColorUtils.withAlpha(accent, 1f)) .accentColor(ColorUtils.withAlpha(accent, 1f))
.backgroundColor(ColorUtils.withAlpha(background, 1f)) .backgroundColor(ColorUtils.withAlpha(background, 1f))
@ -215,7 +213,6 @@ object ThemeConfig {
val bBackground = val bBackground =
getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200)) getPrefInt(PreferKey.cBBackground, getCompatColor(R.color.md_grey_200))
ThemeStore.editTheme(this) ThemeStore.editTheme(this)
.coloredNavigationBar(true)
.primaryColor(ColorUtils.withAlpha(primary, 1f)) .primaryColor(ColorUtils.withAlpha(primary, 1f))
.accentColor(ColorUtils.withAlpha(accent, 1f)) .accentColor(ColorUtils.withAlpha(accent, 1f))
.backgroundColor(ColorUtils.withAlpha(background, 1f)) .backgroundColor(ColorUtils.withAlpha(background, 1f))

@ -19,12 +19,8 @@ import splitties.init.appCtx
@Suppress("unused") @Suppress("unused")
class ThemeStore @SuppressLint("CommitPrefEdits") class ThemeStore @SuppressLint("CommitPrefEdits")
private constructor(private val mContext: Context) : ThemeStoreInterface { private constructor(private val mContext: Context) : ThemeStoreInterface {
private val mEditor: SharedPreferences.Editor
init {
mEditor = prefs(mContext).edit()
}
private val mEditor = prefs(mContext).edit()
override fun primaryColor(@ColorInt color: Int): ThemeStore { override fun primaryColor(@ColorInt color: Int): ThemeStore {
mEditor.putInt(ThemeStorePrefKeys.KEY_PRIMARY_COLOR, color) mEditor.putInt(ThemeStorePrefKeys.KEY_PRIMARY_COLOR, color)
@ -155,16 +151,6 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
return this return this
} }
override fun coloredStatusBar(colored: Boolean): ThemeStore {
mEditor.putBoolean(ThemeStorePrefKeys.KEY_APPLY_PRIMARYDARK_STATUSBAR, colored)
return this
}
override fun coloredNavigationBar(applyToNavBar: Boolean): ThemeStore {
mEditor.putBoolean(ThemeStorePrefKeys.KEY_APPLY_PRIMARY_NAVBAR, applyToNavBar)
return this
}
override fun autoGeneratePrimaryDark(autoGenerate: Boolean): ThemeStore { override fun autoGeneratePrimaryDark(autoGenerate: Boolean): ThemeStore {
mEditor.putBoolean(ThemeStorePrefKeys.KEY_AUTO_GENERATE_PRIMARYDARK, autoGenerate) mEditor.putBoolean(ThemeStorePrefKeys.KEY_AUTO_GENERATE_PRIMARYDARK, autoGenerate)
return this return this
@ -228,9 +214,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
@CheckResult @CheckResult
@ColorInt @ColorInt
fun statusBarColor(context: Context, transparent: Boolean): Int { fun statusBarColor(context: Context, transparent: Boolean): Int {
return if (!coloredStatusBar(context)) { return if (transparent) {
Color.BLACK
} else if (transparent) {
prefs(context).getInt( prefs(context).getInt(
ThemeStorePrefKeys.KEY_STATUS_BAR_COLOR, ThemeStorePrefKeys.KEY_STATUS_BAR_COLOR,
primaryColor(context) primaryColor(context)
@ -246,9 +230,7 @@ private constructor(private val mContext: Context) : ThemeStoreInterface {
@CheckResult @CheckResult
@ColorInt @ColorInt
fun navigationBarColor(context: Context): Int { fun navigationBarColor(context: Context): Int {
return if (!coloredNavigationBar(context)) { return prefs(context).getInt(
Color.BLACK
} else prefs(context).getInt(
ThemeStorePrefKeys.KEY_NAVIGATION_BAR_COLOR, ThemeStorePrefKeys.KEY_NAVIGATION_BAR_COLOR,
bottomBackground(context) bottomBackground(context)
) )

@ -84,12 +84,6 @@ internal interface ThemeStoreInterface {
fun bottomBackground(@ColorInt color: Int): ThemeStore fun bottomBackground(@ColorInt color: Int): ThemeStore
// Toggle configurations
fun coloredStatusBar(colored: Boolean): ThemeStore
fun coloredNavigationBar(applyToNavBar: Boolean): ThemeStore
// Commit/apply // Commit/apply
fun apply() fun apply()

Loading…
Cancel
Save