Skip to content

Commit b0ac7f8

Browse files
committed
Merge branch 'master' of https://github.com/Osanosa/Magisk
2 parents 7ef5784 + 7675e56 commit b0ac7f8

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
}

app/apk/src/main/res/layout/item_module_md2.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@
139139
android:clickable="true"
140140
android:enabled="true"
141141
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}"
145143
android:onClick="@{() -> viewModel.onUpdateClicked(item)}"
146144
android:text="@string/update"
147145
android:textAllCaps="false"

0 commit comments

Comments
 (0)