From d66cace0a71c9dfd90747b2d95f3798917212576 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 2 May 2022 10:09:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=BA=E8=B0=83=E8=89=B2?= =?UTF-8?q?=E5=92=8C=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2=E4=B8=80=E6=A0=B7?= =?UTF-8?q?=E6=98=AF=E6=96=87=E5=AD=97=E9=A2=9C=E8=89=B2=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/widget/text/AccentBgTextView.kt | 27 ++++++++++--------- .../res/layout-land/activity_book_info.xml | 2 -- .../main/res/layout/activity_book_info.xml | 2 -- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt b/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt index a9442be88..4cdc562dc 100644 --- a/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt @@ -23,7 +23,6 @@ class AccentBgTextView @JvmOverloads constructor( radius = typedArray.getDimensionPixelOffset(R.styleable.AccentBgTextView_radius, radius) typedArray.recycle() upBackground() - setTextColor(Color.WHITE) } fun setRadius(radius: Int) { @@ -32,18 +31,22 @@ class AccentBgTextView @JvmOverloads constructor( } private fun upBackground() { - background = if (isInEditMode) { - Selector.shapeBuild() - .setCornerRadius(radius) - .setDefaultBgColor(context.getCompatColor(R.color.accent)) - .setPressedBgColor(ColorUtils.darkenColor(context.getCompatColor(R.color.accent))) - .create() + val accentColor = if (isInEditMode) { + context.getCompatColor(R.color.accent) } else { - Selector.shapeBuild() - .setCornerRadius(radius) - .setDefaultBgColor(ThemeStore.accentColor(context)) - .setPressedBgColor(ColorUtils.darkenColor(ThemeStore.accentColor(context))) - .create() + ThemeStore.accentColor(context) } + background = Selector.shapeBuild() + .setCornerRadius(radius) + .setDefaultBgColor(accentColor) + .setPressedBgColor(ColorUtils.darkenColor(accentColor)) + .create() + setTextColor( + if (ColorUtils.isColorLight(accentColor)) { + Color.BLACK + } else { + Color.WHITE + } + ) } } diff --git a/app/src/main/res/layout-land/activity_book_info.xml b/app/src/main/res/layout-land/activity_book_info.xml index 47503f120..4ea579f99 100644 --- a/app/src/main/res/layout-land/activity_book_info.xml +++ b/app/src/main/res/layout-land/activity_book_info.xml @@ -402,11 +402,9 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" - android:background="@drawable/selector_btn_accent_bg" android:gravity="center" android:includeFontPadding="false" android:text="@string/reading" - android:textColor="@color/tv_text_button_nor" android:textSize="15sp" /> diff --git a/app/src/main/res/layout/activity_book_info.xml b/app/src/main/res/layout/activity_book_info.xml index 8f9b01219..7dbccbbdc 100644 --- a/app/src/main/res/layout/activity_book_info.xml +++ b/app/src/main/res/layout/activity_book_info.xml @@ -383,11 +383,9 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" - android:background="@drawable/selector_btn_accent_bg" android:gravity="center" android:includeFontPadding="false" android:text="@string/reading" - android:textColor="@color/tv_text_button_nor" android:textSize="15sp" />