重写主题系统

This commit is contained in:
HapeLee committed 2025-06-07 04:39:02 +08:00
1 parent 588ac40282
commit 0bb2528fab
56 files changed
+531 -665

No files matched your search

@@ -6,20 +6,22 @@ import android.widget.TextView
import androidx.preference.ListPreference
import androidx.preference.PreferenceViewHolder
import io.legato.kazusa.R
import androidx.core.content.withStyledAttributes
//import io.legado.app.lib.theme.bottomBackground
//import io.legado.app.lib.theme.getPrimaryTextColor
class NameListPreference(context: Context, attrs: AttributeSet) : ListPreference(context, attrs) {
private val isBottomBackground: Boolean
private var isBottomBackground: Boolean = false
init {
layoutResource = R.layout.view_preference
widgetLayoutResource = R.layout.item_fillet_text
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.Preference)
isBottomBackground = typedArray.getBoolean(R.styleable.Preference_isBottomBackground, false)
typedArray.recycle()
context.withStyledAttributes(attrs, R.styleable.Preference) {
isBottomBackground = getBoolean(R.styleable.Preference_isBottomBackground, false)
}
}
override fun onBindViewHolder(holder: PreferenceViewHolder) {
@@ -107,7 +107,7 @@ open class Preference(context: Context, attrs: AttributeSet) :
}
final override fun onBindViewHolder(holder: PreferenceViewHolder) {
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
onBindView(holder)
onLongClick?.let { listener ->
@@ -6,32 +6,32 @@ import androidx.appcompat.widget.SwitchCompat
import androidx.preference.PreferenceViewHolder
import androidx.preference.SwitchPreferenceCompat
import io.legato.kazusa.R
import androidx.core.content.withStyledAttributes
//import io.legado.app.lib.theme.accentColor
class SwitchPreference(context: Context, attrs: AttributeSet) :
SwitchPreferenceCompat(context, attrs) {
private val isBottomBackground: Boolean
private var isBottomBackground: Boolean = false
private var onLongClick: ((preference: SwitchPreference) -> Boolean)? = null
init {
layoutResource = R.layout.view_preference
widgetLayoutResource = R.layout.preference_widget_material_switch
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.Preference)
isBottomBackground = typedArray.getBoolean(R.styleable.Preference_isBottomBackground, false)
typedArray.recycle()
context.withStyledAttributes(attrs, R.styleable.Preference) {
isBottomBackground = getBoolean(R.styleable.Preference_isBottomBackground, false)
}
}
override fun onBindViewHolder(holder: PreferenceViewHolder) {
val v = Preference.bindView<SwitchCompat>(
Preference.bindView<SwitchCompat>(
context, holder, icon, title, summary,
widgetLayoutResource,
androidx.preference.R.id.switchWidget,
isBottomBackground = isBottomBackground
)
if (v is SwitchCompat && !v.isInEditMode) {
//v.applyTint(context.accentColor)
}
super.onBindViewHolder(holder)
onLongClick?.let { listener ->
holder.itemView.setOnLongClickListener {