File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
java/com/topjohnwu/magisk/ui/module Expand file tree Collapse file tree 2 files changed +19
-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
+ import com.google.android.material.button.MaterialButton
10
+
11
+ @BindingAdapter(" updateButtonAppearance" )
12
+ fun setUpdateButtonAppearance (button : MaterialButton , isReady : Boolean ) {
13
+ button.alpha = if (isReady) 1.0f else 0.38f
14
+ val colorAttr = if (isReady) R .attr.colorPrimary else R .attr.colorOnSurface
15
+ val color = MaterialColors .getColor(button, colorAttr)
16
+ button.setTextColor(color)
17
+ button.iconTint = ColorStateList .valueOf(color)
18
+ }
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