diff --git a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEColorPreference.kt b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEColorPreference.kt index 8e1ec7260..517ba8d68 100644 --- a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEColorPreference.kt +++ b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEColorPreference.kt @@ -15,7 +15,7 @@ import androidx.preference.PreferenceViewHolder import com.jaredrummler.android.colorpicker.* import io.legado.app.lib.theme.ATH -class ATEColorPreference : Preference, +class ATEColorPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs), ColorPickerDialogListener { private val SIZE_NORMAL = 0 @@ -35,20 +35,7 @@ class ATEColorPreference : Preference, private var presets: IntArray? = null private var dialogTitle: Int = 0 - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(attrs) - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super( - context, - attrs, - defStyleAttr, - defStyleRes - ) { - init(attrs) - } - - private fun init(attrs: AttributeSet) { + init { isPersistent = true val a = context.obtainStyledAttributes(attrs, R.styleable.ColorPreference) showDialog = a.getBoolean(R.styleable.ColorPreference_cpv_showDialog, true) diff --git a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt index 90a2abfe5..ba4363b15 100644 --- a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt +++ b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt @@ -1,10 +1,8 @@ package io.legado.app.lib.theme.prefs import android.content.Context -import android.os.Build import android.util.AttributeSet import android.widget.TextView -import androidx.annotation.RequiresApi import androidx.preference.PreferenceCategory import androidx.preference.PreferenceViewHolder import io.legado.app.lib.theme.ThemeStore @@ -12,17 +10,8 @@ import io.legado.app.lib.theme.ThemeStore 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) : super(context) - override fun onBindViewHolder(holder: PreferenceViewHolder?) { super.onBindViewHolder(holder) holder?.let { diff --git a/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt b/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt index 2ff1c9c05..998865a7f 100644 --- a/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt +++ b/app/src/main/java/io/legado/app/lib/theme/prefs/ATESwitchPreference.kt @@ -1,9 +1,7 @@ package io.legado.app.lib.theme.prefs import android.content.Context -import android.os.Build import android.util.AttributeSet -import androidx.annotation.RequiresApi import androidx.appcompat.widget.SwitchCompat import androidx.preference.PreferenceViewHolder 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.ThemeStore -class ATESwitchPreference : SwitchPreferenceCompat { - - @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) +class ATESwitchPreference(context: Context, attrs: AttributeSet) : + SwitchPreferenceCompat(context, attrs) { override fun onBindViewHolder(holder: PreferenceViewHolder?) { super.onBindViewHolder(holder)