From 3266c109c4183d06c7b2f13e6934cefa8cb2f942 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 15 Feb 2020 20:09:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/read/config/ChineseConverter.kt | 23 ++----------------- .../app/ui/widget/text/StrokeTextView.kt | 7 +++--- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ChineseConverter.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ChineseConverter.kt index 1c5973978..dc8f36d67 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ChineseConverter.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ChineseConverter.kt @@ -5,39 +5,20 @@ import android.text.Spannable import android.text.SpannableString import android.text.style.ForegroundColorSpan import android.util.AttributeSet -import androidx.appcompat.widget.AppCompatTextView import io.legado.app.R import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.alert -import io.legado.app.lib.theme.Selector -import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.accentColor -import io.legado.app.utils.dp -import io.legado.app.utils.getCompatColor +import io.legado.app.ui.widget.text.StrokeTextView import org.jetbrains.anko.sdk27.listeners.onClick -class ChineseConverter(context: Context, attrs: AttributeSet?) : AppCompatTextView(context, attrs) { +class ChineseConverter(context: Context, attrs: AttributeSet?) : StrokeTextView(context, attrs) { private val spannableString = SpannableString("简/繁") private var enabledSpan: ForegroundColorSpan = ForegroundColorSpan(context.accentColor) private var onChanged: (() -> Unit)? = null init { - background = Selector.shapeBuild() - .setCornerRadius(1.dp) - .setStrokeWidth(1.dp) - .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) - .setDefaultStrokeColor(ThemeStore.textColorSecondary(context)) - .setSelectedStrokeColor(ThemeStore.accentColor(context)) - .setPressedBgColor(context.getCompatColor(R.color.transparent30)) - .create() - setTextColor( - Selector.colorBuild() - .setDefaultColor(ThemeStore.textColorSecondary(context)) - .setSelectedColor(ThemeStore.accentColor(context)) - .setDisabledColor(context.getCompatColor(R.color.md_grey_500)) - .create() - ) text = spannableString if (!isInEditMode) { upUi(AppConfig.chineseConverterType) diff --git a/app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt index c899e1c42..df4da33ea 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt @@ -9,7 +9,8 @@ import io.legado.app.lib.theme.ThemeStore import io.legado.app.utils.dp import io.legado.app.utils.getCompatColor -class StrokeTextView(context: Context, attrs: AttributeSet) : AppCompatTextView(context, attrs) { +open class StrokeTextView(context: Context, attrs: AttributeSet?) : + AppCompatTextView(context, attrs) { init { if (isInEditMode) { @@ -21,7 +22,7 @@ class StrokeTextView(context: Context, attrs: AttributeSet) : AppCompatTextView( .setSelectedStrokeColor(context.getCompatColor(R.color.colorAccent)) .setPressedBgColor(context.getCompatColor(R.color.transparent30)) .create() - setTextColor( + this.setTextColor( Selector.colorBuild() .setDefaultColor(context.getCompatColor(R.color.tv_text_secondary)) .setSelectedColor(context.getCompatColor(R.color.colorAccent)) @@ -37,7 +38,7 @@ class StrokeTextView(context: Context, attrs: AttributeSet) : AppCompatTextView( .setSelectedStrokeColor(ThemeStore.accentColor(context)) .setPressedBgColor(context.getCompatColor(R.color.transparent30)) .create() - setTextColor( + this.setTextColor( Selector.colorBuild() .setDefaultColor(ThemeStore.textColorSecondary(context)) .setSelectedColor(ThemeStore.accentColor(context))