From 0aa3002b4a8f704d211fa95cb26c0113b8a38623 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 2 May 2022 10:25:13 +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/lib/theme/view/ThemeRadioNoButton.kt | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/theme/view/ThemeRadioNoButton.kt b/app/src/main/java/io/legado/app/lib/theme/view/ThemeRadioNoButton.kt index 40ea925d1..cc23da707 100644 --- a/app/src/main/java/io/legado/app/lib/theme/view/ThemeRadioNoButton.kt +++ b/app/src/main/java/io/legado/app/lib/theme/view/ThemeRadioNoButton.kt @@ -1,6 +1,7 @@ package io.legado.app.lib.theme.view import android.content.Context +import android.graphics.Color import android.util.AttributeSet import androidx.appcompat.widget.AppCompatRadioButton import io.legado.app.R @@ -29,35 +30,47 @@ class ThemeRadioNoButton(context: Context, attrs: AttributeSet) : when { isInEditMode -> Unit isBottomBackground -> { + val accentColor = context.accentColor val isLight = ColorUtils.isColorLight(context.bottomBackground) val textColor = context.getPrimaryTextColor(isLight) + val checkedTextColor = if (ColorUtils.isColorLight(accentColor)) { + Color.BLACK + } else { + Color.WHITE + } background = Selector.shapeBuild() .setCornerRadius(2.dpToPx()) .setStrokeWidth(2.dpToPx()) - .setCheckedBgColor(context.accentColor) - .setCheckedStrokeColor(context.accentColor) + .setCheckedBgColor(accentColor) + .setCheckedStrokeColor(accentColor) .setDefaultStrokeColor(textColor) .create() setTextColor( Selector.colorBuild() .setDefaultColor(textColor) - .setCheckedColor(context.getPrimaryTextColor(ColorUtils.isColorLight(context.accentColor))) + .setCheckedColor(checkedTextColor) .create() ) } else -> { - val textColor = context.getCompatColor(R.color.primaryText) + val accentColor = context.accentColor + val defaultTextColor = context.getCompatColor(R.color.primaryText) + val checkedTextColor = if (ColorUtils.isColorLight(accentColor)) { + Color.BLACK + } else { + Color.WHITE + } background = Selector.shapeBuild() .setCornerRadius(2.dpToPx()) .setStrokeWidth(2.dpToPx()) - .setCheckedBgColor(context.accentColor) - .setCheckedStrokeColor(context.accentColor) - .setDefaultStrokeColor(textColor) + .setCheckedBgColor(accentColor) + .setCheckedStrokeColor(accentColor) + .setDefaultStrokeColor(defaultTextColor) .create() setTextColor( Selector.colorBuild() - .setDefaultColor(textColor) - .setCheckedColor(context.getPrimaryTextColor(ColorUtils.isColorLight(context.accentColor))) + .setDefaultColor(defaultTextColor) + .setCheckedColor(checkedTextColor) .create() ) }