Fix crash when a formatter XML references a color resource - #134
Merged
Conversation
Fig's parseIntAttr handed any value starting with '@' to Color.parseColor, which only understands hex and named colors, so a formatter XML with linePaint.color="@color/foo" crashed with "Unknown color". Resolve the reference instead and read it by resource type: colors yield the color value, dimens the pixel size, anything else the integer. Also accept negative integers, which previously fell through to Color.parseColor as well. Fig was a separate library (com.halfhp.fig:figlib) whose only consumer is Androidplot and whose publishing pipeline is defunct, so its three sources and test are folded into com.androidplot.util.fig and the external dependency is dropped from the published POM. The demoapp's line_point_formatter now references a color resource as a live regression check. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BWySSrgd1L761915n3mFoo
The quickstart linked to the external Fig repo for the configuration syntax; now that Fig is part of androidplot-core, document the syntax in docs/xml_configuration.md, link it from the quickstart and index, and note the #88 fix and toolchain changes in the release notes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BWySSrgd1L761915n3mFoo
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BWySSrgd1L761915n3mFoo
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #134 +/- ##
============================================
- Coverage 69.26% 69.16% -0.10%
- Complexity 1199 1233 +34
============================================
Files 106 109 +3
Lines 4997 5160 +163
Branches 512 537 +25
============================================
+ Hits 3461 3569 +108
- Misses 1210 1248 +38
- Partials 326 343 +17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #88
Cause
Formatter XML such as
linePaint.color="@color/accent_blue"crashed withIllegalArgumentException: Unknown color. AAPT2 compiles that reference to the form@2131034163, and Fig'sparseIntAttrpassed any value starting with@straight toColor.parseColor, which only understands hex and named colors. The 2019 comment on the issue said this would be fixed in Fig for 1.5.8, but the fix never landed: figlib 1.0.11 on Maven Central still has the bug.Fix
parseIntAttrnow resolves@values as resource references and reads them by resource type:coloryields the color value,dimenthe pixel size, anything else the integer. Both the compiled@<id>form and the@color/namestring form are handled.Color.parseColoras well.IllegalArgumentExceptionnaming the value, instead of the opaque "Unknown color".Fig folded into androidplot-core
Fig (
com.halfhp.fig:figlib) is a three-file library by the same author whose only known consumer is Androidplot, and whose publishing pipeline is defunct. Its sources and test now live incom.androidplot.util.fig, under the SPDX header. Callers inPlot,FormatterandXYRegionFormatterare rewired, and the external dependency is gone from the published POM, which now lists onlyandroidx.annotation. Nothing in Androidplot's public API exposed Fig types.Documentation
docs/xml_configuration.mddescribes the property-path syntax, accepted value types (including resource references), theandroidPlot.layout prefix, and the ProGuard requirement. Adapted from Fig's README in Androidplot terms.docs/release_notes.mdgains a 1.5.12 entry covering this fix, the Fig merge, the SDK 37 toolchain and snapshot publishing.Verification
FigTestcases cover a color reference, an integer reference, hex color, negative int and an unresolvable reference. The reference cases fail on the old logic and pass on the fix (checked both ways).FigTestcases pass after the move.line_point_formatter.xmlnow references a color resource, andaapt2 dump xmltreeconfirms it compiles to a reference. It's used by the Animated XY Plot and FX Plot examples, so those screens act as a live regression check.