pull/34/head
kunfei 5 years ago
parent caa723a4a2
commit 5e1d7ccdcc
  1. 17
      app/src/main/java/io/legado/app/lib/theme/prefs/ATEColorPreference.kt
  2. 11
      app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt
  3. 19
      app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt

@ -15,7 +15,7 @@ import androidx.preference.PreferenceViewHolder
import com.jaredrummler.android.colorpicker.* import com.jaredrummler.android.colorpicker.*
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
class ATEColorPreference : Preference, class ATEColorPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs),
ColorPickerDialogListener { ColorPickerDialogListener {
private val SIZE_NORMAL = 0 private val SIZE_NORMAL = 0
@ -35,20 +35,7 @@ class ATEColorPreference : Preference,
private var presets: IntArray? = null private var presets: IntArray? = null
private var dialogTitle: Int = 0 private var dialogTitle: Int = 0
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { init {
init(attrs)
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(
context,
attrs,
defStyleAttr,
defStyleRes
) {
init(attrs)
}
private fun init(attrs: AttributeSet) {
isPersistent = true isPersistent = true
val a = context.obtainStyledAttributes(attrs, R.styleable.ColorPreference) val a = context.obtainStyledAttributes(attrs, R.styleable.ColorPreference)
showDialog = a.getBoolean(R.styleable.ColorPreference_cpv_showDialog, true) showDialog = a.getBoolean(R.styleable.ColorPreference_cpv_showDialog, true)

@ -1,10 +1,8 @@
package io.legado.app.lib.theme.prefs package io.legado.app.lib.theme.prefs
import android.content.Context import android.content.Context
import android.os.Build
import android.util.AttributeSet import android.util.AttributeSet
import android.widget.TextView import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.preference.PreferenceCategory import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceViewHolder import androidx.preference.PreferenceViewHolder
import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.ThemeStore
@ -12,17 +10,8 @@ import io.legado.app.lib.theme.ThemeStore
class ATEPreferenceCategory : PreferenceCategory { class ATEPreferenceCategory : PreferenceCategory {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) :
super(context, attrs, defStyleAttr, defStyleRes)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) :
super(context, attrs, defStyleAttr)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context) : super(context)
override fun onBindViewHolder(holder: PreferenceViewHolder?) { override fun onBindViewHolder(holder: PreferenceViewHolder?) {
super.onBindViewHolder(holder) super.onBindViewHolder(holder)
holder?.let { holder?.let {

@ -1,9 +1,7 @@
package io.legado.app.lib.theme.prefs package io.legado.app.lib.theme.prefs
import android.content.Context import android.content.Context
import android.os.Build
import android.util.AttributeSet import android.util.AttributeSet
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.SwitchCompat
import androidx.preference.PreferenceViewHolder import androidx.preference.PreferenceViewHolder
import androidx.preference.SwitchPreferenceCompat import androidx.preference.SwitchPreferenceCompat
@ -11,21 +9,8 @@ import io.legado.app.R
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.ThemeStore
class ATESwitchPreference : SwitchPreferenceCompat { class ATESwitchPreference(context: Context, attrs: AttributeSet) :
SwitchPreferenceCompat(context, attrs) {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(
context,
attrs,
defStyleAttr,
defStyleRes
)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context) : super(context)
override fun onBindViewHolder(holder: PreferenceViewHolder?) { override fun onBindViewHolder(holder: PreferenceViewHolder?) {
super.onBindViewHolder(holder) super.onBindViewHolder(holder)

Loading…
Cancel
Save