Skip to content

Commit

Permalink
fix(android): improve color resource handling in Common.java (#913)
Browse files Browse the repository at this point in the history
The changes handle the fetching of color resources more accurately in our Common.java file. The old method was simplified to one line, but this didn't consider raw color values. Now, the code correctly handles both cases: when the type value is resolved to a color resource ID, and when it's resolved to a raw color value.

Co-authored-by: Solera <[email protected]>
  • Loading branch information
andvalsol and Solera authored Jul 9, 2024
1 parent 8d9ba88 commit 8527354
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ public static int getDefaultDialogButtonTextColor(@NonNull Context activity) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = activity.getTheme();
theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
@ColorRes int colorRes = (typedValue.resourceId != 0) ? typedValue.resourceId : typedValue.data;
@ColorInt int colorId = ContextCompat.getColor(activity, colorRes);
@ColorInt int colorId;
if (typedValue.resourceId != 0) {
// Resolved to a color resource ID
colorId = ContextCompat.getColor(activity, typedValue.resourceId);
} else {
// Resolved to a raw color value
colorId = typedValue.data;
}
return colorId;
}

Expand Down

0 comments on commit 8527354

Please sign in to comment.