From 63d61a6ffe1581776d09618e1a4da7526df19b92 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 3 Oct 2022 00:57:26 +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 --- .../legado/app/ui/widget/SelectActionBar.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt b/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt index d7e50a0be..7b899f3b5 100644 --- a/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt +++ b/app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt @@ -20,20 +20,22 @@ class SelectActionBar @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null ) : FrameLayout(context, attrs) { + + private val bgIsLight = ColorUtils.isColorLight(context.bottomBackground) + private val primaryTextColor = context.getPrimaryTextColor(bgIsLight) + private val disabledColor = context.getSecondaryDisabledTextColor(bgIsLight) + private var callBack: CallBack? = null private var selMenu: PopupMenu? = null - private val binding = - ViewSelectActionBarBinding.inflate(LayoutInflater.from(context), this, true) + private val binding = ViewSelectActionBarBinding + .inflate(LayoutInflater.from(context), this, true) init { setBackgroundColor(context.bottomBackground) elevation = context.elevation - val textIsDark = ColorUtils.isColorLight(context.bottomBackground) - val primaryTextColor = context.getPrimaryTextColor(textIsDark) - val secondaryTextColor = context.getSecondaryTextColor(textIsDark) binding.cbSelectedAll.setTextColor(primaryTextColor) - TintHelper.setTint(binding.cbSelectedAll, context.accentColor, !textIsDark) - binding.ivMenuMore.setColorFilter(secondaryTextColor) + TintHelper.setTint(binding.cbSelectedAll, context.accentColor, !bgIsLight) + binding.ivMenuMore.setColorFilter(disabledColor) binding.cbSelectedAll.setOnCheckedChangeListener { buttonView, isChecked -> if (buttonView.isPressed) { callBack?.selectAll(isChecked) @@ -99,9 +101,9 @@ class SelectActionBar @JvmOverloads constructor( btnSelectActionMain.isEnabled = isClickable btnSelectActionMain.isClickable = isClickable if (isClickable) { - ivMenuMore.setColorFilter(context.primaryTextColor) + ivMenuMore.setColorFilter(primaryTextColor) } else { - ivMenuMore.setColorFilter(context.secondaryTextColor) + ivMenuMore.setColorFilter(disabledColor) } ivMenuMore.isEnabled = isClickable ivMenuMore.isClickable = isClickable