优化透明主题选择逻辑
This commit is contained in:
@@ -18,8 +18,12 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
import io.legato.kazusa.R
|
import io.legato.kazusa.R
|
||||||
import io.legato.kazusa.constant.EventBus
|
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.postEvent
|
||||||
import io.legato.kazusa.utils.restart
|
import io.legato.kazusa.utils.restart
|
||||||
|
import io.legato.kazusa.utils.toastOnUi
|
||||||
|
import splitties.init.appCtx
|
||||||
|
|
||||||
@SuppressLint("ResourceType")
|
@SuppressLint("ResourceType")
|
||||||
class ThemeCardPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs) {
|
class ThemeCardPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs) {
|
||||||
@@ -76,6 +80,14 @@ class ThemeCardPreference(context: Context, attrs: AttributeSet) : Preference(co
|
|||||||
|
|
||||||
holder.card.setOnClickListener {
|
holder.card.setOnClickListener {
|
||||||
if (value != currentValue) {
|
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
|
val oldValue = currentValue
|
||||||
currentValue = value
|
currentValue = value
|
||||||
persistString(value)
|
persistString(value)
|
||||||
|
|||||||
@@ -24,12 +24,6 @@
|
|||||||
android:entryValues="@array/themes_value"
|
android:entryValues="@array/themes_value"
|
||||||
android:defaultValue="0" />
|
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
|
<io.legato.kazusa.lib.prefs.SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pure_black"
|
android:key="pure_black"
|
||||||
|
|||||||
Reference in New Issue
Block a user