Skip to content

Commit

Permalink
Fix resolving color state lists from theme (#3800)
Browse files Browse the repository at this point in the history
Fixes #3748

Signed-off-by: Danny Baumann <[email protected]>
  • Loading branch information
maniac103 authored Aug 15, 2024
1 parent a1a1c86 commit 29176c3
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 29176c3

Please sign in to comment.