datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

Improve color resource handling in Common.java

Open andvalsol opened this issue 4 days ago • 0 comments

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.

Summary

Handling Default Values If the textColorPrimary attribute is not explicitly defined in your theme, the typedValue.resourceId might still be 0, and typedValue.data might contain a raw color value instead of a resource ID. This could lead to unexpected behavior if you're expecting a resource ID. Explicit Check: We now explicitly check if typedValue.resourceId is non-zero before assuming it's a resource ID. Raw Color Handling: If typedValue.resourceId is 0, we directly use typedValue.data as the color value since it likely represents a raw color. This modification ensures that your code gracefully handles cases where the resolved attribute value is either a color resource ID or a raw color value.

Test Plan

What's required for testing (prerequisites)?

N/A

What are the steps to reproduce (after prerequisites)?

If there's no default default text color in the App's theme the app that implements this library will crash.

Compatibility

OS Implemented
iOS ✅ ❌
Android ✅ ❌

Checklist

  • [X] I have tested this on a device and a simulator
  • [ ] I added the documentation in README.md
  • [ ] I updated the typed files (TS and Flow)
  • [ ] I added a sample use of the API in the example project (example/App.js)
  • [ ] I have added automated tests, either in JS or e2e tests, as applicable

andvalsol avatar Jul 03 '24 20:07 andvalsol