File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
java/com/topjohnwu/magisk/ui/module Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change
1
+
2
+ package com.topjohnwu.magisk.ui.module
3
+
4
+ import android.widget.Button
5
+ import androidx.databinding.BindingAdapter
6
+ import com.google.android.material.R
7
+ import com.google.android.material.color.MaterialColors
8
+ import android.content.res.ColorStateList
9
+
10
+ @BindingAdapter(" updateButtonAppearance" )
11
+ fun setUpdateButtonAppearance (button : Button , isReady : Boolean ) {
12
+ button.alpha = if (isReady) 1.0f else 0.38f
13
+ val colorAttr = if (isReady) R .attr.colorPrimary else R .attr.colorOnSurface
14
+ val color = MaterialColors .getColor(button, colorAttr)
15
+ button.setTextColor(color)
16
+ button.iconTint = ColorStateList .valueOf(color)
17
+ }
Original file line number Diff line number Diff line change 139
139
android : clickable =" true"
140
140
android : enabled =" true"
141
141
android : focusable =" true"
142
- android : alpha =" @{item.updateReady ? 1.0f : 0.38f}"
143
- android : textColor =" @{item.updateReady ? (?attr/colorPrimary) : (?attr/colorOnSurfaceVariant)}"
144
- app : iconTint =" @{item.updateReady ? (?attr/colorPrimary) : (?attr/colorOnSurfaceVariant)}"
142
+ app : updateButtonAppearance =" @{item.updateReady}"
145
143
android : onClick =" @{() -> viewModel.onUpdateClicked(item)}"
146
144
android : text =" @string/update"
147
145
android : textAllCaps =" false"
You can’t perform that action at this time.
0 commit comments