UI tweaks for pre API 21

This commit is contained in:
topjohnwu
2020-08-27 05:46:41 -07:00
parent fd808bd51e
commit 7e133b0cf4
6 changed files with 26 additions and 38 deletions

View File

@@ -3,12 +3,14 @@ package com.topjohnwu.magisk.databinding
import android.animation.ValueAnimator
import android.graphics.Paint
import android.graphics.drawable.Drawable
import android.util.TypedValue
import android.view.ContextThemeWrapper
import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.annotation.DrawableRes
import androidx.appcompat.widget.Toolbar
import androidx.cardview.widget.CardView
import androidx.core.view.isGone
import androidx.core.view.isInvisible
import androidx.core.view.updateLayoutParams
@@ -302,3 +304,10 @@ fun setListeners(
attrChange.onChange()
}
}
@BindingAdapter("cardBackgroundColorAttr")
fun CardView.setCardBackgroundColorAttr(attr: Int) {
val tv = TypedValue()
context.theme.resolveAttribute(attr, tv, true)
setCardBackgroundColor(tv.data)
}

View File

@@ -9,7 +9,7 @@ import com.topjohnwu.magisk.utils.set
import org.json.JSONObject
enum class SafetyNetState {
LOADING, PASS, FAILED, IDLE
LOADING, PASS, FAILED
}
data class SafetyNetResult(
@@ -42,7 +42,7 @@ class SafetynetViewModel : BaseViewModel() {
@get:Bindable
val isSuccess get() = currentState == PASS
private var currentState = IDLE
private var currentState = LOADING
set(value) = set(value, field, { field = it }, BR.checking, BR.failed, BR.success)
init {