From a99d259281564a30141927c189ff92ccdf5b600d Mon Sep 17 00:00:00 2001 From: HapeLee <1321903405@qq.com> Date: Wed, 24 Sep 2025 01:50:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kazusa/lib/theme/MaterialValueHelper.kt | 8 +-- .../io/legato/kazusa/lib/theme/ThemeStore.kt | 71 ++++++++++--------- .../res/color/chip_background_selector.xml | 2 +- .../main/res/color/chip_stroke_selector.xml | 2 +- 4 files changed, 39 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/io/legato/kazusa/lib/theme/MaterialValueHelper.kt b/app/src/main/java/io/legato/kazusa/lib/theme/MaterialValueHelper.kt index aa08d3a4b..941829c2b 100644 --- a/app/src/main/java/io/legato/kazusa/lib/theme/MaterialValueHelper.kt +++ b/app/src/main/java/io/legato/kazusa/lib/theme/MaterialValueHelper.kt @@ -8,10 +8,4 @@ import android.content.Context * @author Karim Abou Zeid (kabouzeid) */ val Context.primaryColor: Int - get() = ThemeStore.primaryColor(this) - -val Context.secondaryColor: Int - get() = ThemeStore.secondaryColor(this) - -val Context.primaryContainerColor: Int - get() = ThemeStore.primaryContainerColor(this) \ No newline at end of file + get() = ThemeStore.primaryColor(this) \ No newline at end of file diff --git a/app/src/main/java/io/legato/kazusa/lib/theme/ThemeStore.kt b/app/src/main/java/io/legato/kazusa/lib/theme/ThemeStore.kt index ce8be8204..5d6908126 100644 --- a/app/src/main/java/io/legato/kazusa/lib/theme/ThemeStore.kt +++ b/app/src/main/java/io/legato/kazusa/lib/theme/ThemeStore.kt @@ -39,17 +39,17 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { val fallback = color - val secondary = MaterialColors.getColor( - wrapped, - com.google.android.material.R.attr.colorSecondary, - fallback - ) - - val primaryContainer = MaterialColors.getColor( - wrapped, - com.google.android.material.R.attr.colorSecondaryContainer, - fallback - ) +// val secondary = MaterialColors.getColor( +// wrapped, +// com.google.android.material.R.attr.colorSecondary, +// fallback +// ) +// +// val primaryContainer = MaterialColors.getColor( +// wrapped, +// com.google.android.material.R.attr.colorPrimaryContainer, +// fallback +// ) val primary = MaterialColors.getColor( wrapped, @@ -57,8 +57,8 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { fallback ) - mEditor.putInt(ThemeStorePrefKeys.KEY_SECONDARY_COLOR, secondary) - mEditor.putInt(ThemeStorePrefKeys.KEY_PRIMARY_CONTAINER_COLOR, primaryContainer) + //mEditor.putInt(ThemeStorePrefKeys.KEY_SECONDARY_COLOR, secondary) + //mEditor.putInt(ThemeStorePrefKeys.KEY_PRIMARY_CONTAINER_COLOR, primaryContainer) mEditor.putInt(ThemeStorePrefKeys.KEY_PRIMARY_COLOR, primary) return this @@ -67,7 +67,8 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { override fun primaryColor(@ColorInt color: Int): ThemeStore { if (autoGeneratePrimaryDark(mContext)) primaryColorDark(ColorUtils.darkenColor(color)) - addColorScheme(color) + mEditor.putInt(ThemeStorePrefKeys.KEY_PRIMARY_COLOR, color) + //addColorScheme(color) return this } @@ -155,27 +156,27 @@ private constructor(private val mContext: Context) : ThemeStoreInterface { } } - fun primaryContainerColor(context: Context = appCtx): Int { - return if (isCustomThemeEnabled(context)) { - prefs(context).getInt( - ThemeStorePrefKeys.KEY_PRIMARY_CONTAINER_COLOR, - "#FFFFFF".toColorInt() - ) - } else { - ThemeUtils.resolveColor(context, com.google.android.material.R.attr.colorPrimaryContainer) - } - } - - fun secondaryColor(context: Context = appCtx): Int { - return if (isCustomThemeEnabled(context)) { - prefs(context).getInt( - ThemeStorePrefKeys.KEY_SECONDARY_COLOR, - primaryColor(context) - ) - } else { - primaryColor(context) - } - } +// fun primaryContainerColor(context: Context = appCtx): Int { +// return if (isCustomThemeEnabled(context)) { +// prefs(context).getInt( +// ThemeStorePrefKeys.KEY_PRIMARY_CONTAINER_COLOR, +// "#FFFFFF".toColorInt() +// ) +// } else { +// ThemeUtils.resolveColor(context, com.google.android.material.R.attr.colorPrimaryContainer) +// } +// } +// +// fun secondaryColor(context: Context = appCtx): Int { +// return if (isCustomThemeEnabled(context)) { +// prefs(context).getInt( +// ThemeStorePrefKeys.KEY_SECONDARY_COLOR, +// primaryColor(context) +// ) +// } else { +// primaryColor(context) +// } +// } @CheckResult @ColorInt diff --git a/app/src/main/res/color/chip_background_selector.xml b/app/src/main/res/color/chip_background_selector.xml index c3ad46f6c..2e2cdce92 100644 --- a/app/src/main/res/color/chip_background_selector.xml +++ b/app/src/main/res/color/chip_background_selector.xml @@ -1,5 +1,5 @@ - + diff --git a/app/src/main/res/color/chip_stroke_selector.xml b/app/src/main/res/color/chip_stroke_selector.xml index 73f16062d..4c135b77a 100644 --- a/app/src/main/res/color/chip_stroke_selector.xml +++ b/app/src/main/res/color/chip_stroke_selector.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file