pull/2368/head
kunfei 2 years ago
parent ca94434756
commit 63d61a6ffe
  1. 20
      app/src/main/java/io/legado/app/ui/widget/SelectActionBar.kt

@ -20,20 +20,22 @@ class SelectActionBar @JvmOverloads constructor(
context: Context, context: Context,
attrs: AttributeSet? = null attrs: AttributeSet? = null
) : FrameLayout(context, attrs) { ) : 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 callBack: CallBack? = null
private var selMenu: PopupMenu? = null private var selMenu: PopupMenu? = null
private val binding = private val binding = ViewSelectActionBarBinding
ViewSelectActionBarBinding.inflate(LayoutInflater.from(context), this, true) .inflate(LayoutInflater.from(context), this, true)
init { init {
setBackgroundColor(context.bottomBackground) setBackgroundColor(context.bottomBackground)
elevation = context.elevation elevation = context.elevation
val textIsDark = ColorUtils.isColorLight(context.bottomBackground)
val primaryTextColor = context.getPrimaryTextColor(textIsDark)
val secondaryTextColor = context.getSecondaryTextColor(textIsDark)
binding.cbSelectedAll.setTextColor(primaryTextColor) binding.cbSelectedAll.setTextColor(primaryTextColor)
TintHelper.setTint(binding.cbSelectedAll, context.accentColor, !textIsDark) TintHelper.setTint(binding.cbSelectedAll, context.accentColor, !bgIsLight)
binding.ivMenuMore.setColorFilter(secondaryTextColor) binding.ivMenuMore.setColorFilter(disabledColor)
binding.cbSelectedAll.setOnCheckedChangeListener { buttonView, isChecked -> binding.cbSelectedAll.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) { if (buttonView.isPressed) {
callBack?.selectAll(isChecked) callBack?.selectAll(isChecked)
@ -99,9 +101,9 @@ class SelectActionBar @JvmOverloads constructor(
btnSelectActionMain.isEnabled = isClickable btnSelectActionMain.isEnabled = isClickable
btnSelectActionMain.isClickable = isClickable btnSelectActionMain.isClickable = isClickable
if (isClickable) { if (isClickable) {
ivMenuMore.setColorFilter(context.primaryTextColor) ivMenuMore.setColorFilter(primaryTextColor)
} else { } else {
ivMenuMore.setColorFilter(context.secondaryTextColor) ivMenuMore.setColorFilter(disabledColor)
} }
ivMenuMore.isEnabled = isClickable ivMenuMore.isEnabled = isClickable
ivMenuMore.isClickable = isClickable ivMenuMore.isClickable = isClickable

Loading…
Cancel
Save