Skip to content

Migrate App resources snippets - #1157

Open
djubinville wants to merge 1 commit into
android:mainfrom
djubinville:djubinville/app-resources-snippets
Open

djubinville wants to merge 1 commit into
android:mainfrom
djubinville:djubinville/app-resources-snippets

Conversation

@djubinville

@djubinville djubinville commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Code snippets are for:

compose/snippets/src/main/res/animator/property_animator.xml (android_resources_animation_property_animator) is a migrated XML snippet, and compose/snippets/src/main/res/values/strings.xml contains supporting resource declarations (R.bool.screen_small, R.integer.max_speed, R.array.bits, R.array.icons, and R.array.colors) alongside colors.xml (R.color.opaque_red) and dimens.xml (R.dimen.font_size) because the tagged Kotlin snippets in MoreResources.kt reference those resource IDs and will not build without them. Existing repository resources R.string.hello_world (in ProvidingResources.kt) and R.drawable.cupcake (reused in place of R.drawable.myimage in DrawableResources.kt and in <array name="icons"> in strings.xml in place of home/settings/logout) are reused to avoid adding duplicate assets or colliding string keys.

List of modifications:

  • Providing-resources page: Extracted 1 Kotlin snippet into ProvidingResources.kt and added a terminal period to the inline comment.
  • Runtime-changes page: Extracted 1 Compose snippet into RuntimeChanges.kt.
  • Internationalization page: Extracted 1 Kotlin snippet into Internationalization.kt.
  • Animation-resource page: Extracted 1 platform AnimatorInflater snippet into AnimationResources.kt, added an explicit as AnimatorSet cast so AnimatorInflater.loadAnimator compiles with AnimatorSet, and extracted the res/animator/property_animator.xml XML snippet (android_resources_animation_property_animator), adding xmlns:android="http://schemas.android.com/apk/res/android" on the root <set> element so aapt2 compiles the resource.
  • Drawable-resource page: Extracted 1 ResourcesCompat.getDrawable snippet into DrawableResources.kt, reusing existing drawable asset R.drawable.cupcake in place of R.drawable.myimage.
  • More-resources page: Extracted 6 resource lookup Kotlin snippets into MoreResources.kt, updated the deprecated one-argument resources.getColor(R.color.opaque_red) overload to resources.getColor(R.color.opaque_red, null) (D2 modernization; prose does not specify the overload), and made val drawable: Drawable? = icons.getDrawable(0) nullable to match the SDK return type.

Snippets not migrated:

  • Providing-resources page: Directory tree diagrams, resource syntax callouts (not code), and <resources> XML syntax/example blocks on a reference-doc-like page left hardcoded on the guide page.
  • Runtime-changes page: Lines 163–168 and 201–207 because they are AndroidManifest.xml <activity> configuration blocks.
  • Internationalization page: Legacy Java duplicate of the migrated Kotlin snippet (removed from the guide page).
  • Animation-resource page: Legacy Java duplicates (removed from the guide page), ImageView/findViewById View-based snippets, and XML animation syntax/example blocks on a reference-doc-like page left hardcoded on the guide page.
  • Drawable-resource page: Legacy Java duplicates (removed from the guide page), findViewById View-based snippets (ImageButton, ImageView, TextView), and XML drawable syntax/example blocks on a reference-doc-like page left hardcoded on the guide page.
  • More-resources page: Legacy Java duplicates (removed from the guide page), deprecated Activity.showDialog/onCreateDialog snippets, and XML resource syntax/example blocks on a reference-doc-like page left hardcoded on the guide page.

@djubinville
djubinville force-pushed the djubinville/app-resources-snippets branch 4 times, most recently from e32a62b to 7c0ac0b Compare October 15, 2026 18:16
@djubinville
djubinville marked this pull request as ready for review October 15, 2026 18:20
@djubinville
djubinville requested a review from a team as a code owner October 15, 2026 18:20
@snippet-bot

snippet-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 12 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-snippets branch from 7c0ac0b to f0efb63 Compare October 15, 2026 18:55
@djubinville

Copy link
Copy Markdown
Contributor Author

Addressed review feedback across commit f0efb638 and the PR description:

  1. B1 (Ready for Review): Confirmed PR Migrate App resources snippets #1157 is marked Ready for Review (isDraft: false).
    • Rule Bypass Note (android-snippets-experimental/SKILL.md Phase 2, Step 6 & Phase 4, Step 1): The workspace copy of SKILL.md instructs creating a Draft PR (--draft) and using Draft PR:, contradicting the 2026-10-12 depot HEAD rulebook. Bypassed with user approval to keep PR Migrate App resources snippets #1157 Ready for Review and use PR: in cl/995144611. To bring the workspace rule set into compliance, morgillo/snippets-skill-share SKILL.md (Phase 2.6 and Phase 4.1) should be synced with depot HEAD (cl/997605355).
  2. B2 (res/animator/property_animator.xml): Replaced the reduced stand-in with the full sequential <set> + nested <set> (x and y <objectAnimator>s) + alpha <objectAnimator> from animation-resource.html L284–303, wrapped it in <!-- [START android_resources_animation_property_animator] --> / <!-- [END android_resources_animation_property_animator] -->, and migrated animation-resource.html L284–303 in cl/995144611. Documented the root xmlns:android namespace attribute under D17 in the PR description.
  3. W1 / D19 (Local Gradle & Spotless Verification): Ran Spotless, Kotlin compilation, and Android Lint locally on f0efb638:
    $ ./gradlew :compose:snippets:spotlessApply :compose:snippets:compileDebugKotlin :compose:snippets:lintDebug
    > Task :compose:snippets:spotlessXmlApply
    > Task :compose:snippets:spotlessApply
    > Task :compose:snippets:compileDebugKotlin UP-TO-DATE
    > Task :compose:snippets:lintDebug
    BUILD SUCCESSFUL in 1m 50s
    
    (Also added tools:ignore="MissingTranslation" on <resources> in compose/snippets/src/main/res/values/strings.xml so :compose:snippets:lintDebug passes with 0 errors alongside values-es/strings.xml.)
  4. W7 (XML Eligibility & "Snippets not migrated" Reasons):
    • Updated the "Snippets not migrated" reasons for the 5 resource-type reference pages (providing-resources, animation-resource, drawable-resource, string-resource, more-resources) and the 83-locale sample table in app-languages (L545–632) to cite "reference-doc-like page".
    • Migrated the guide-page XML blocks on app-languages.md L238–248 (compose/snippets/src/main/res/xml/locale_config.xml, tag android_resources_app_languages_locale_config) and localization.md L262–265 & L285–289 (compose/snippets/src/main/res/values/strings.xml, tags android_resources_localization_context_comment and android_resources_localization_xliff_countdown), while keeping localization.md L297–318 hardcoded because it wraps a root <resources> element containing a literal ... ellipsis.
    • Rule Bypass Note (android-snippets-experimental/SKILL.md D15 & references/eligible_snippets.md): D15 ("Focus on Kotlin") and eligible_snippets.md catalog standalone XML blocks as [SKIP], whereas github/index.md (#eligible-snippets) marks XML snippets on non-reference guide pages as eligible. Bypassed D15/eligible_snippets.md with user approval to migrate the valid guide-page XML snippets above. To bring the rule set into compliance, SKILL.md D15 and references/eligible_snippets.md should be updated to align with github/index.md on eligible guide-page XML vs. excluded "reference-doc-like page" XML.
  5. W8 (colors.xml & strings.xml Supporting Resource Values): Updated opaque_red in colors.xml to #f00, updated <array name="colors"> in strings.xml to include all 3 items (#FFFF0000, #FF00FF00, #FF0000FF), and disclosed @drawable/cupcake reuse in <array name="icons">.
  6. W9 & W10 (PR Description Accuracy): Disclosed reuse of R.string.title (noting that getText(R.string.title) as SpannedString is compile-only because strings.xml:22 is a plain "Title" string) and R.string.hello_world, updated the string-resource Array<String> note, reworded more-resources getColor(id, null) as a D2 deprecation modernization, and renamed gradle.properties to resources.properties in the app-languages row.

@djubinville
djubinville force-pushed the djubinville/app-resources-snippets branch from f0efb63 to ba9369d Compare October 16, 2026 15:40
@djubinville
djubinville force-pushed the djubinville/app-resources-snippets branch from ba9369d to e16dfd7 Compare October 16, 2026 20:33

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