From c24e3d145e5d27a7df1bbbf2e482aff3205c5307 Mon Sep 17 00:00:00 2001 From: Solera Date: Wed, 3 Jul 2024 14:19:39 -0600 Subject: [PATCH] Improve color resource handling in Common.java 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. --- .../com/reactcommunity/rndatetimepicker/Common.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/reactcommunity/rndatetimepicker/Common.java b/android/src/main/java/com/reactcommunity/rndatetimepicker/Common.java index 9effd097..5980b17d 100644 --- a/android/src/main/java/com/reactcommunity/rndatetimepicker/Common.java +++ b/android/src/main/java/com/reactcommunity/rndatetimepicker/Common.java @@ -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; }