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

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

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

Loading…
Cancel
Save