diff --git a/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt b/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt index cbff84976..fc79f4584 100644 --- a/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt +++ b/app/src/main/java/io/legado/app/lib/theme/TintHelper.kt @@ -206,7 +206,7 @@ object TintHelper { intArrayOf(android.R.attr.state_enabled, -android.R.attr.state_checked), intArrayOf(android.R.attr.state_enabled, android.R.attr.state_checked) ), intArrayOf( - // Rdio button includes own alpha for disabled state + // Radio button includes own alpha for disabled state ColorUtils.stripAlpha( ContextCompat.getColor( radioButton.context, @@ -223,11 +223,10 @@ object TintHelper { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { radioButton.buttonTintList = sl } else { - val d = createTintedDrawable( + radioButton.buttonDrawable = createTintedDrawable( ContextCompat.getDrawable(radioButton.context, R.drawable.abc_btn_radio_material), sl ) - radioButton.buttonDrawable = d } } diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATEAccentBgTextView.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATEAccentBgTextView.kt index 6de1037b9..6aef2175a 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATEAccentBgTextView.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATEAccentBgTextView.kt @@ -10,19 +10,17 @@ import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.dp class ATEAccentBgTextView : AppCompatTextView { - constructor(context: Context) : super(context) { - init(context) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context) { + init { background = Selector.shapeBuild() .setCornerRadius(3.dp) .setDefaultBgColor(ThemeStore.accentColor(context)) diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATEAccentStrokeTextView.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATEAccentStrokeTextView.kt index c6aea80f0..30ff4da44 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATEAccentStrokeTextView.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATEAccentStrokeTextView.kt @@ -7,33 +7,31 @@ import io.legado.app.R import io.legado.app.lib.theme.Selector import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.dp +import io.legado.app.utils.getCompatColor class ATEAccentStrokeTextView : AppCompatTextView { - constructor(context: Context) : super(context) { - init(context) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - @Suppress("DEPRECATION") - private fun init(context: Context) { + init { background = Selector.shapeBuild() .setCornerRadius(3.dp) .setStrokeWidth(1.dp) - .setDisabledStrokeColor(context.resources.getColor(R.color.md_grey_500)) + .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) .setDefaultStrokeColor(ThemeStore.accentColor(context)) - .setPressedBgColor(context.resources.getColor(R.color.transparent30)) + .setPressedBgColor(context.getCompatColor(R.color.transparent30)) .create() setTextColor( Selector.colorBuild() .setDefaultColor(ThemeStore.accentColor(context)) - .setDisabledColor(context.resources.getColor(R.color.md_grey_500)) + .setDisabledColor(context.getCompatColor(R.color.md_grey_500)) .create() ) } diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATEAutoCompleteTextView.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATEAutoCompleteTextView.kt index 4a4688fbb..f54f24eb4 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATEAutoCompleteTextView.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATEAutoCompleteTextView.kt @@ -10,19 +10,17 @@ import io.legado.app.lib.theme.ThemeStore class ATEAutoCompleteTextView : AppCompatAutoCompleteTextView { - constructor(context: Context) : super(context) { - init(context) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context) { + init { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { backgroundTintList = Selector.colorBuild() .setFocusedColor(ThemeStore.accentColor(context)) diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATECheckBox.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATECheckBox.kt index 643299f35..a9bef21b0 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATECheckBox.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATECheckBox.kt @@ -11,19 +11,17 @@ import io.legado.app.lib.theme.ThemeStore */ class ATECheckBox : AppCompatCheckBox { - constructor(context: Context) : super(context) { - init(context) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context) { + init { ATH.setTint(this, ThemeStore.accentColor(context)) } } diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATEEditText.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATEEditText.kt index c70ea4eda..b38bdd6ab 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATEEditText.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATEEditText.kt @@ -11,19 +11,17 @@ import io.legado.app.lib.theme.ThemeStore */ class ATEEditText : AppCompatEditText { - constructor(context: Context) : super(context) { - init(context, null) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context, attrs: AttributeSet?) { + init { ATH.setTint(this, ThemeStore.accentColor(context)) } } diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATEPrimaryTextView.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATEPrimaryTextView.kt index 97d4d08b1..44d1e1acd 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATEPrimaryTextView.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATEPrimaryTextView.kt @@ -10,19 +10,17 @@ import io.legado.app.lib.theme.ThemeStore */ class ATEPrimaryTextView : AppCompatTextView { - constructor(context: Context) : super(context) { - init(context) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context) { + init { setTextColor(ThemeStore.textColorPrimary(context)) } } diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATEProgressBar.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATEProgressBar.kt index 3a1809f16..aae4d914a 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATEProgressBar.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATEProgressBar.kt @@ -13,17 +13,15 @@ import io.legado.app.lib.theme.ThemeStore */ class ATEProgressBar : ProgressBar { - constructor(context: Context) : super(context) { - init(context, null) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) @TargetApi(Build.VERSION_CODES.LOLLIPOP) constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super( @@ -31,11 +29,9 @@ class ATEProgressBar : ProgressBar { attrs, defStyleAttr, defStyleRes - ) { - init(context, attrs) - } + ) - private fun init(context: Context, attrs: AttributeSet?) { + init { ATH.setTint(this, ThemeStore.accentColor(context)) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATERadioButton.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATERadioButton.kt index 8af025c2f..c8715728e 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATERadioButton.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATERadioButton.kt @@ -11,19 +11,17 @@ import io.legado.app.lib.theme.accentColor */ class ATERadioButton : AppCompatRadioButton { - constructor(context: Context) : super(context) { - init(context) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context) { + init { ATH.setTint(this@ATERadioButton, context.accentColor) } } diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATERadioNoButton.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATERadioNoButton.kt index 2e7763741..41ce5dbe5 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATERadioNoButton.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATERadioNoButton.kt @@ -14,19 +14,17 @@ import io.legado.app.utils.getCompatColor */ class ATERadioNoButton : AppCompatRadioButton { - constructor(context: Context) : super(context) { - init(context, null) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context, attrs: AttributeSet?) { + init { background = Selector.shapeBuild() .setCornerRadius(2.dp) .setStrokeWidth(2.dp) diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATESecondaryTextView.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATESecondaryTextView.kt index f84814b90..d7dc8ca3d 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATESecondaryTextView.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATESecondaryTextView.kt @@ -3,26 +3,24 @@ package io.legado.app.lib.theme.view import android.content.Context import android.util.AttributeSet import androidx.appcompat.widget.AppCompatTextView -import io.legado.app.lib.theme.ThemeStore +import io.legado.app.lib.theme.secondaryTextColor /** * @author Aidan Follestad (afollestad) */ class ATESecondaryTextView : AppCompatTextView { - constructor(context: Context) : super(context) { - init(context) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context) { - setTextColor(ThemeStore.textColorSecondary(context)) + init { + setTextColor(context.secondaryTextColor) } } diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATEStrokeTextView.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATEStrokeTextView.kt index ee6697224..04416929c 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATEStrokeTextView.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATEStrokeTextView.kt @@ -9,19 +9,17 @@ import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.dp class ATEStrokeTextView : AppCompatTextView { - constructor(context: Context) : super(context) { - init(context, null) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context, attrs: AttributeSet?) { + init { background = Selector.shapeBuild() .setCornerRadius(1.dp) .setStrokeWidth(1.dp) diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt index 8009d817a..1a1c331a4 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATESwitch.kt @@ -2,33 +2,27 @@ package io.legado.app.lib.theme.view import android.content.Context import android.util.AttributeSet -import android.view.View import androidx.appcompat.widget.SwitchCompat import io.legado.app.lib.theme.ATH -import io.legado.app.lib.theme.ThemeStore +import io.legado.app.lib.theme.accentColor /** * @author Aidan Follestad (afollestad) */ class ATESwitch : SwitchCompat { - constructor(context: Context) : super(context) { - init(context, null) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context, attrs) - } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context, attrs: AttributeSet?) { - ATH.setTint(this, ThemeStore.accentColor(context)) + init { + ATH.setTint(this, context.accentColor) } - override fun isShown(): Boolean { - return parent != null && visibility == View.VISIBLE - } } diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ATETextInputLayout.kt b/app/src/main/java/io/legado/app/lib/theme/view/ATETextInputLayout.kt index e09b03e2c..b420f3e01 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ATETextInputLayout.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ATETextInputLayout.kt @@ -1,31 +1,24 @@ package io.legado.app.lib.theme.view import android.content.Context -import android.graphics.Canvas import android.util.AttributeSet import com.google.android.material.textfield.TextInputLayout import io.legado.app.lib.theme.Selector import io.legado.app.lib.theme.ThemeStore class ATETextInputLayout : TextInputLayout { - constructor(context: Context) : super(context) { - init(context) - } + constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) { - init(context) - } + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - init(context) - } + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) - private fun init(context: Context) { + init { defaultHintTextColor = Selector.colorBuild().setDefaultColor(ThemeStore.accentColor(context)).create() } - override fun draw(canvas: Canvas) { - - super.draw(canvas) - } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt index 8c44a480c..7f8281eeb 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt @@ -213,10 +213,12 @@ class ReadStyleDialog : DialogFragment() { } private fun changeBg(index: Int) { - ReadBookConfig.styleSelect = index - ReadBookConfig.upBg() - upBg() - postEvent(Bus.UP_CONFIG, true) + if (ReadBookConfig.styleSelect != index) { + ReadBookConfig.styleSelect = index + ReadBookConfig.upBg() + upBg() + postEvent(Bus.UP_CONFIG, true) + } } private fun showBgTextConfig(index: Int): Boolean { diff --git a/app/src/main/res/layout/dialog_read_bg_text.xml b/app/src/main/res/layout/dialog_read_bg_text.xml index 3f0541eb6..073e9b720 100644 --- a/app/src/main/res/layout/dialog_read_bg_text.xml +++ b/app/src/main/res/layout/dialog_read_bg_text.xml @@ -8,8 +8,10 @@ android:padding="10dp"> @@ -39,10 +42,11 @@ android:layout_gravity="center" android:layout_margin="6dp" android:layout_weight="1" + android:background="?attr/selectableItemBackground" android:singleLine="true" android:gravity="center" android:padding="6dp" - android:text="背景颜色" + android:text="@string/bg_color" android:textSize="14sp" tools:ignore="HardcodedText" /> @@ -53,6 +57,7 @@ android:layout_gravity="center" android:layout_margin="6dp" android:layout_weight="1" + android:background="?attr/selectableItemBackground" android:singleLine="true" android:gravity="center" android:padding="6dp" @@ -74,7 +79,7 @@ android:layout_height="wrap_content" android:paddingStart="10dp" android:paddingEnd="10dp" - android:text="背景图片" /> + android:text="@string/bg_image" /> %d分钟 自动亮度%s 按页 + 背景图片 + 背景颜色 + 文字颜色