From 6b77d28edcac868319dc7d0f8fe4148fd3db8ba2 Mon Sep 17 00:00:00 2001 From: Danny Baumann Date: Wed, 14 Aug 2024 10:23:36 +0200 Subject: [PATCH] Fix resolving color state lists from theme Fixes #3748 Signed-off-by: Danny Baumann --- .../java/org/openhab/habdroid/util/ExtensionFuncs.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mobile/src/main/java/org/openhab/habdroid/util/ExtensionFuncs.kt b/mobile/src/main/java/org/openhab/habdroid/util/ExtensionFuncs.kt index f05880abdc..52c8d52f63 100644 --- a/mobile/src/main/java/org/openhab/habdroid/util/ExtensionFuncs.kt +++ b/mobile/src/main/java/org/openhab/habdroid/util/ExtensionFuncs.kt @@ -49,6 +49,7 @@ import androidx.preference.PreferenceManager import com.caverock.androidsvg.RenderOptions import com.caverock.androidsvg.SVG import com.google.android.material.color.DynamicColors +import com.google.android.material.color.MaterialColors import java.io.EOFException import java.io.IOException import java.io.InputStream @@ -448,13 +449,7 @@ fun Context.determineDataUsagePolicy(conn: Connection? = null): DataUsagePolicy @ColorInt fun Context.resolveThemedColor(@AttrRes colorAttr: Int, @ColorInt fallbackColor: Int = 0): Int { - val tv = TypedValue() - theme.resolveAttribute(colorAttr, tv, true) - return if (tv.type >= TypedValue.TYPE_FIRST_COLOR_INT && tv.type <= TypedValue.TYPE_LAST_COLOR_INT) { - tv.data - } else { - fallbackColor - } + return MaterialColors.getColor(this, colorAttr, fallbackColor) } @ColorRes