优化透明主题选择逻辑

This commit is contained in:
HapeLee
2025-10-18 01:31:20 +08:00
parent f92f386e08
commit ec215ccf5e
2 changed files with 12 additions and 6 deletions
@@ -18,8 +18,12 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.card.MaterialCardView
import io.legato.kazusa.R
import io.legato.kazusa.constant.EventBus
import io.legato.kazusa.constant.PreferKey
import io.legato.kazusa.utils.getPrefString
import io.legato.kazusa.utils.postEvent
import io.legato.kazusa.utils.restart
import io.legato.kazusa.utils.toastOnUi
import splitties.init.appCtx
@SuppressLint("ResourceType")
class ThemeCardPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs) {
@@ -76,6 +80,14 @@ class ThemeCardPreference(context: Context, attrs: AttributeSet) : Preference(co
holder.card.setOnClickListener {
if (value != currentValue) {
if (value == "12") {
val hasLightBg = !appCtx.getPrefString(PreferKey.bgImage).isNullOrEmpty()
val hasDarkBg = !appCtx.getPrefString(PreferKey.bgImageN).isNullOrEmpty()
if (!hasLightBg || !hasDarkBg) {
context.toastOnUi(R.string.transparent_theme_alarm)
return@setOnClickListener
}
}
val oldValue = currentValue
currentValue = value
persistString(value)
@@ -24,12 +24,6 @@
android:entryValues="@array/themes_value"
android:defaultValue="0" />
<io.legato.kazusa.lib.prefs.TipPreference
android:key="theme_tip"
android:selectable="false"
app:iconSpaceReserved="false"
app:tipText="@string/transparent_theme_alarm" />
<io.legato.kazusa.lib.prefs.SwitchPreference
android:defaultValue="false"
android:key="pure_black"