Skip to content

Migrate App resources overview (complex XML, color list, menu, font, style) snippets - #1181

Open
djubinville wants to merge 3 commits into
android:mainfrom
djubinville:djubinville/app-resources-views-snippets
Open

djubinville wants to merge 3 commits into
android:mainfrom
djubinville:djubinville/app-resources-views-snippets

Conversation

@djubinville

@djubinville djubinville commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Code snippets are for:

The XML menu resource compose/snippets/src/main/res/menu/example_menu.xml was migrated because the tagged Kotlin region android_resources_menu_inflate in MenuResource.kt references R.menu.example_menu and cannot compile without it. The guide pages specify the resource filenames res/menu/example_menu.xml, res/color/button_text.xml, res/drawable/avd.xml, res/drawable/vectordrawable.xml, res/anim/rotation.xml, and res/font/lobster.xml. Because the Complex-xml-resources and Font-resource guide pages each print two distinct XML resource files with the same path (res/drawable/avd.xml and res/font/lobster.xml) and aapt2 prohibits duplicate resource names in src/main/res/, the second variant on each page is named res/drawable/avd_inline.xml and res/font/lobster_downloadable.xml so all resources are compiled by aapt2.

List of modifications:

  • Color-list-resource page: Extracted the <selector> color state list XML into compose/snippets/src/main/res/color/button_text.xml (android_resources_color_list_button_text) and removed the redundant xmlns:android attribute from the second <item> element after Spotless XML formatting.
  • Complex-xml-resources page: Extracted the separated animated vector drawable XML files into compose/snippets/src/main/res/drawable/avd.xml (android_resources_complex_xml_avd), compose/snippets/src/main/res/drawable/vectordrawable.xml (android_resources_complex_xml_vectordrawable), and compose/snippets/src/main/res/anim/rotation.xml (android_resources_complex_xml_rotation).
  • Complex-xml-resources page: Extracted the inline <aapt:attr> animated vector drawable XML into compose/snippets/src/main/res/drawable/avd_inline.xml (android_resources_complex_xml_avd_inline), named avd_inline.xml to avoid colliding with res/drawable/avd.xml from the same page so aapt2 compiles both resources.
  • Font-resource page: Extracted the bundled <font-family> XML into compose/snippets/src/main/res/font/lobster.xml (android_resources_font_bundled), replacing @font/lobster_regular and @font/lobster_italic with existing repository font assets @font/raleway_regular and @font/raleway_italic so the resource compiles without adding new binary font files.
  • Font-resource page: Extracted the downloadable <font-family> XML into compose/snippets/src/main/res/font/lobster_downloadable.xml (android_resources_font_downloadable, named lobster_downloadable.xml to avoid colliding with res/font/lobster.xml from the same page so aapt2 compiles both resources) and the certificate <array> XML into compose/snippets/src/main/res/values/font_certs.xml (android_resources_font_certs).
  • Menu-resource page: Extracted the <menu> XML into compose/snippets/src/main/res/menu/example_menu.xml (android_resources_menu_example_xml). Required for the Kotlin snippet to compile (R.menu.example_menu in MenuResource.kt). Replaced non-existent @drawable/ic_new_game and @drawable/ic_help references with @drawable/ic_launcher_foreground so aapt2 compiles the menu resource.
  • Menu-resource page: Added untagged supporting <string> resources (item1, group_item1, group_item2, submenu_title, and submenu_item1) in compose/snippets/src/main/res/values/menu_strings.xml (no region tag; not printed on the guide page). Required for the Kotlin snippet to compile via res/menu/example_menu.xml.
  • Menu-resource page: Extracted the Kotlin onCreateOptionsMenu snippet into compose/snippets/src/main/java/com/example/compose/snippets/resources/MenuResource.kt (android_resources_menu_inflate) and formatted with Spotless.
  • Style-resource page: Extracted the <style name="CustomText"> XML into compose/snippets/src/main/res/values/style_resource.xml (android_resources_style_custom_text) with a silent exclude defining the parent <style name="Text" /> so the style resource links cleanly.

Snippets not migrated:

  • Provide a resource (providing-resources.html) page: Contains only directory-tree listings, naming tables, and 2-line pseudo-syntax examples.
  • More resource types (more-types.html) page: Contains only short 1-4 line syntax templates and attribute tables.
  • Color-list-resource page: Line 46 <selector> block is a syntax template; Line 75 Kotlin resources.getColorStateList snippet is a 2-line snippet inside an explanatory block; Line 79 Java block was removed because Kotlin is sufficient; Line 147 <Button> XML is a 5-line legacy View fragment.
  • Font-resource page: Line 36 <font-family> block is a syntax template; Lines 65, 81, 96, 122, and 188 <TextView> / <EditText> / <style> XML blocks are short legacy View layout or style fragments; Line 113 Kotlin resources.getFont snippet is a 2-line fragment; Line 117 Java block was removed because Kotlin is sufficient.
  • Layout-resource page: Contains only syntax templates and legacy View layout XML fragments (LinearLayout, TextView, Button, include, merge, and findViewById activity stub).
  • Menu-resource page: Lines 34 (<menu> syntax template) and 199 (3-line <item> fragment) are syntax templates; Line 186 Java block was removed because Kotlin is sufficient; Line 204 onOptionsItemSelected Kotlin/Java blocks use placeholder pseudo-code (// Handle item selection.).
  • Style-resource page: Line 36 <style> block is a syntax template (@[package:]style/style_name); Line 108 <TextView> XML is a 4-line legacy View fragment.

@djubinville
djubinville force-pushed the djubinville/app-resources-views-snippets branch from a59b617 to 681fce1 Compare October 14, 2026 19:28
@djubinville

Copy link
Copy Markdown
Contributor Author

Rule Set Alignment & Bypass Note (android-snippets-experimental)

  1. Same-Page Colliding XML Resource Filenames (D10, D11, D27 vs. D17, D19, D30):

    • Rule Bypassed: D10/D11 (which state that reusing an existing repository asset is the only allowed rename of a page-printed resource identifier) and D27 (page-forced filenames res/drawable/avd.xml and res/font/lobster.xml).
    • Reasoning: Both complex-xml-resources and font-resource define two distinct XML files under the exact same path (res/drawable/avd.xml and res/font/lobster.xml). Android's aapt2 compiler forbids duplicate resource names or subdirectories inside src/main/res/drawable/ and src/main/res/font/, and D30 forbids modifying build.gradle.kts (sourceSets) to compile a secondary src/main/res_other/ directory. To satisfy D17 and D19 (all migrated resources must be compiled by aapt2 during :compose:snippets:build), the second variant on each page is placed at compose/snippets/src/main/res/drawable/avd_inline.xml and compose/snippets/src/main/res/font/lobster_downloadable.xml and disclosed in the PR description (D14).
    • Recommended Rule Set Update: Update D10, D11, and D27 in SKILL.md and references/move_to_github.md to explicitly permit disambiguating filenames (e.g., <name>_inline.xml, <name>_downloadable.xml) in src/main/res/<type>/ when a single guide page prints multiple XML resource files with the same path.
  2. Draft PR Status (Phase 2.6 / references/create_github_pr.md):

    • Contradiction: The workspace android-snippets-experimental skill (2026-09-29, Phase 2.6 & references/create_github_pr.md) mandates opening a Draft PR (gh pr create --draft), whereas the depot HEAD copy (2026-10-12) mandates a Ready-for-Review PR (isDraft: false). Per user direction, this PR remains in Draft status in accordance with the loaded workspace skill.
    • Recommended Rule Set Update: Sync /google/src/cloud/morgillo/snippets-skill-share/google3/experimental/users/morgillo/skills/android-snippets-experimental/ with depot HEAD (//depot/configs/users/morgillo/_agents/skills/android-snippets-experimental/).

@djubinville
djubinville force-pushed the djubinville/app-resources-views-snippets branch from 9de924c to 8e7002c Compare October 15, 2026 18:16
@djubinville
djubinville marked this pull request as ready for review October 15, 2026 18:56
@djubinville
djubinville requested a review from a team as a code owner October 15, 2026 18:56
@snippet-bot

snippet-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 11 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@djubinville
djubinville force-pushed the djubinville/app-resources-views-snippets branch 5 times, most recently from 7be6ba1 to 80f555d Compare October 21, 2026 17:46
@djubinville
djubinville force-pushed the djubinville/app-resources-views-snippets branch from 80f555d to df7ce8c Compare October 22, 2026 12:38

This branch has not been deployed

No deployments
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.

1 participant