From 7e133b0cf4522f2acadb722b653a975d8dfb6fb7 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 27 Aug 2020 05:46:41 -0700 Subject: [PATCH] UI tweaks for pre API 21 --- .../magisk/databinding/DataBindingAdapters.kt | 9 +++++++ .../magisk/ui/safetynet/SafetynetViewModel.kt | 4 +-- .../main/res/layout/fragment_install_md2.xml | 12 +++------ .../res/layout/fragment_safetynet_md2.xml | 26 ++++--------------- app/src/main/res/layout/item_hide_md2.xml | 5 +++- app/src/main/res/values/styles_md2_impl.xml | 8 +++--- 6 files changed, 26 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt b/app/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt index e8925af96..0bb098b3a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt +++ b/app/src/main/java/com/topjohnwu/magisk/databinding/DataBindingAdapters.kt @@ -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) +} diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/SafetynetViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/SafetynetViewModel.kt index c40fbab90..b3abea3ba 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/SafetynetViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/SafetynetViewModel.kt @@ -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 { diff --git a/app/src/main/res/layout/fragment_install_md2.xml b/app/src/main/res/layout/fragment_install_md2.xml index 4d97a6f58..5ff2fda5e 100644 --- a/app/src/main/res/layout/fragment_install_md2.xml +++ b/app/src/main/res/layout/fragment_install_md2.xml @@ -96,33 +96,27 @@ diff --git a/app/src/main/res/layout/fragment_safetynet_md2.xml b/app/src/main/res/layout/fragment_safetynet_md2.xml index 5dac89512..62e402193 100644 --- a/app/src/main/res/layout/fragment_safetynet_md2.xml +++ b/app/src/main/res/layout/fragment_safetynet_md2.xml @@ -7,8 +7,8 @@ - + + app:layout_constraintWidth_max="300dp" + tools:cardBackgroundColor="?colorPrimary"> - - - - ?colorSurfaceVariant @dimen/l_50 0dp - true + false - -