Skip to content

feat: resource additions & API improvements (cleaned up from #15)#16

Merged
Jawnnypoo merged 3 commits into
mainfrom
feat/comprehensive-improvements-cleaned
Jun 9, 2026
Merged

feat: resource additions & API improvements (cleaned up from #15)#16
Jawnnypoo merged 3 commits into
mainfrom
feat/comprehensive-improvements-cleaned

Conversation

@Jawnnypoo

@Jawnnypoo Jawnnypoo commented Jun 9, 2026

Copy link
Copy Markdown
Member

Supersedes #15 — same valid additions, with the invalid-XML features removed and the docs/tests fixed. Branched from that work so contributor history is preserved.

Adds (valid, tested)

  • fraction resource
  • reference resource (<item type="reference">; type is required)
  • buildBytes()ByteArray
  • translatable = false on string-array / typed-array
  • format attribute on styles
  • create(file, indent, elementType) for font-family files
  • joinToString cleanup of the attr format builder

Removed from #15 (aapt2 rejects these / no valid use)

  • FontFamilyRes — emitted @font/<int>; a resource id can't become @font/name
  • int-quantity / int-quantity-array — not Android resource types (plurals are string-only)
  • color-array / bool-array — not real resource types (use <array> / <integer-array>)
  • addColor(name, Int) — no correct use in a build-time generator (an R.color.* id isn't a color value, and it silently dropped alpha); use addColor(name, String)
  • README docs for a non-existent addString(comment = …) API

Fixes

  • Reference.type now required — a type-less @name isn't a valid reference
  • README corrections; no-op assert(...) tests converted to golden-file / assertTrue assertions

Verification

./gradlew testBUILD SUCCESSFUL, 58 tests passing.

🤖 Generated with Claude Code

VeldtJumper and others added 3 commits June 5, 2026 12:15
…ts, code quality

New resource types:
- fraction (addFraction)
- int-quantity / int-quantity-array (addIntQuantity, addIntQuantityArray)
- color-array (addColorArray)
- bool-array (addBoolArray)
- reference (addReference with Reference data class)

API improvements:
- addColor(name, Int) overload for integer color values
- buildBytes() for ByteArray output
- create(file, indent, elementType) for font-family files
- translatable attribute on addStringArray and addTypedArray
- format attribute on addStyle
- FontFamilyRes data class with addFontFamilyRes method

Code quality:
- Replace manual format string concatenation with joinToString
- Remove stale 'Does this mess up ordering?' comments
- Expand add(type, name, value) to support FRACTION, COLOR_ARRAY, BOOL_ARRAY
- Update add(type) doc to reflect expanded support

Tests: 13 new test files, 73 total tests passing
README: Updated with all new features and examples
…docs

Keeps the additions from the comprehensive-improvements work that produce
valid Android resource XML and removes the ones aapt2 would reject.

Removed (emitted non-standard XML):
- FontFamilyRes / addFontFamilyRes — produced @font/<int>, which never
  resolves (a resource id can't be turned back into @font/name)
- int-quantity / int-quantity-array and the Quantity class — not Android
  resource types (plurals are string-only)
- color-array / bool-array — not real resource types
- the corresponding Type enum entries, plus the unused REFERENCE constant

Kept and fixed:
- Reference.type is now required; a type-less @name is not a valid reference
- add() drops the COLOR_ARRAY/BOOL_ARRAY branches, keeps FRACTION
- README: corrected the addColor(Int) examples (wrong output comment, and the
  0xFF0000FF literal is a Long that did not compile against the Int overload),
  and removed docs for the non-existent addString(comment=) API
- tests: replaced no-op assert() with golden-file / assertTrue assertions

Retained valid additions: fraction, reference, addColor(Int), buildBytes,
translatable on arrays, style format, and create(file, indent, elementType).

All 61 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
No correct use in a build-time resource generator: the documented R.color.*
example is a resource id, not a color value, and would format to garbage; it
silently dropped alpha so it couldn't express #AARRGGBB; and addColor(String)
already covers the real cases. Removes the method, its tests, golden files,
and README section.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Jawnnypoo Jawnnypoo merged commit 7fc62ca into main Jun 9, 2026
2 checks passed
@Jawnnypoo Jawnnypoo deleted the feat/comprehensive-improvements-cleaned branch June 9, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants