From 7342cee660a494398ab4c796a2cb839037d0a2e5 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 17 May 2021 15:36:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/lib/theme/MaterialValueHelper.kt | 4 +-- .../ui/widget/text/AccentStrokeTextView.kt | 31 +++++++++++++++++-- app/src/main/res/color/selector_image.xml | 2 +- .../res/layout/view_select_action_bar.xml | 23 ++++++++------ app/src/main/res/values-night/colors.xml | 2 ++ app/src/main/res/values/attrs.xml | 5 +++ app/src/main/res/values/colors.xml | 3 ++ 7 files changed, 54 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt index 5dadc5d85..786db41c9 100644 --- a/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt +++ b/app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt @@ -101,9 +101,9 @@ val Fragment.secondaryDisabledTextColor: Int val Context.buttonDisabledColor: Int get() = if (isDarkTheme) { - ContextCompat.getColor(this, R.color.ate_button_disabled_dark) + ContextCompat.getColor(this, R.color.md_dark_disabled) } else { - ContextCompat.getColor(this, R.color.ate_button_disabled_light) + ContextCompat.getColor(this, R.color.md_light_disabled) } val Context.isDarkTheme: Boolean diff --git a/app/src/main/java/io/legado/app/ui/widget/text/AccentStrokeTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/AccentStrokeTextView.kt index 37b18051a..abd14615a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/AccentStrokeTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/AccentStrokeTextView.kt @@ -6,25 +6,50 @@ import androidx.appcompat.widget.AppCompatTextView import io.legado.app.R import io.legado.app.lib.theme.Selector import io.legado.app.lib.theme.ThemeStore +import io.legado.app.lib.theme.bottomBackground +import io.legado.app.utils.ColorUtils import io.legado.app.utils.dp import io.legado.app.utils.getCompatColor class AccentStrokeTextView(context: Context, attrs: AttributeSet) : AppCompatTextView(context, attrs) { + private var radius = 3.dp + private val isBottomBackground: Boolean + init { + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.AccentStrokeTextView) + radius = typedArray.getDimensionPixelOffset(R.styleable.StrokeTextView_radius, radius) + isBottomBackground = + typedArray.getBoolean(R.styleable.StrokeTextView_isBottomBackground, false) + typedArray.recycle() + upStyle() + } + + private fun upStyle() { + val isLight = ColorUtils.isColorLight(context.bottomBackground) + val disableColor = if (isBottomBackground) { + if (isLight) { + context.getCompatColor(R.color.md_light_disabled) + } else { + context.getCompatColor(R.color.md_dark_disabled) + } + } else { + context.getCompatColor(R.color.disabled) + } background = Selector.shapeBuild() - .setCornerRadius(3.dp) + .setCornerRadius(radius) .setStrokeWidth(1.dp) - .setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500)) + .setDisabledStrokeColor(disableColor) .setDefaultStrokeColor(ThemeStore.accentColor(context)) .setPressedBgColor(context.getCompatColor(R.color.transparent30)) .create() setTextColor( Selector.colorBuild() .setDefaultColor(ThemeStore.accentColor(context)) - .setDisabledColor(context.getCompatColor(R.color.md_grey_500)) + .setDisabledColor(disableColor) .create() ) } + } diff --git a/app/src/main/res/color/selector_image.xml b/app/src/main/res/color/selector_image.xml index 081b03cf0..ffc800f9f 100644 --- a/app/src/main/res/color/selector_image.xml +++ b/app/src/main/res/color/selector_image.xml @@ -1,6 +1,6 @@ - + diff --git a/app/src/main/res/layout/view_select_action_bar.xml b/app/src/main/res/layout/view_select_action_bar.xml index eddfb0fc4..a58f77df7 100644 --- a/app/src/main/res/layout/view_select_action_bar.xml +++ b/app/src/main/res/layout/view_select_action_bar.xml @@ -1,15 +1,16 @@ + android:padding="5dp" + android:text="@string/revert_selection" + app:isBottomBackground="true" /> + app:isBottomBackground="true" /> diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index db09b5da3..bc6e12b19 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -4,6 +4,8 @@ @color/md_blue_grey_700 @color/md_deep_orange_800 + @color/md_dark_disabled + @color/md_grey_900 @color/md_grey_850 @color/md_grey_800 diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index bdb8fd0b1..fd11b974c 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -167,6 +167,11 @@ + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 5eb13fbda..92799cbea 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -3,6 +3,9 @@ @color/md_light_blue_600 @color/md_light_blue_700 @color/md_pink_800 + + @color/md_light_disabled + #66666666 #FF578FCC