Skip to content

Migrate App resources snippets - #1157

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

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

Conversation

@djubinville

Copy link
Copy Markdown
Contributor

Code snippets are for:

compose/snippets/src/main/res/animator/property_animator.xml and supporting resource declarations in compose/snippets/src/main/res/values/strings.xml, colors.xml, and dimens.xml are included because tagged Kotlin snippets reference R.animator.property_animator, R.string.hello, R.string.welcome_messages, R.array.planets_array, R.plurals.numberOfSongsAvailable, R.bool.screen_small, R.color.opaque_red, R.dimen.font_size, R.integer.max_speed, R.array.bits, R.array.icons, and R.array.colors and will not build without them. Existing repository assets R.font.raleway_regular and R.drawable.cupcake are reused in place of R.font.permanent_marker and R.drawable.myimage to avoid adding duplicate font or bitmap files.

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.
  • App-languages page: Extracted 6 Kotlin snippets into AppLanguages.kt, commented out inline import statements inside region tags so imports remain at the top of the file, updated overrideLocaleConfig.supportedLocales() to the nullable SDK property overrideLocaleConfig?.supportedLocales so the code compiles, and standardized inline comment punctuation.
  • Localization page: Extracted 1 Compose snippet into Localization.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 added res/animator/property_animator.xml (required for the Kotlin snippet to compile).
  • Drawable-resource page: Extracted 1 ResourcesCompat.getDrawable snippet into DrawableResources.kt, reusing existing drawable asset R.drawable.cupcake in place of R.drawable.myimage.
  • String-resource page: Extracted 8 Compose snippets into StringResources.kt, added type argument Array<String> to raw Array in PlanetList, commented out inline import statements inside region tags, standardized inline comment punctuation, and reused existing font asset R.font.raleway_regular in place of R.font.permanent_marker.
  • More-resources page: Extracted 6 resource lookup Kotlin snippets into MoreResources.kt, updated resources.getColor(R.color.opaque_red) to resources.getColor(R.color.opaque_red, null) to match the current two-argument Resources.getColor signature, 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, and illustrative <resources> XML syntax blocks left hardcoded on the guide page.
  • Runtime-changes page: Lines 163–168 and 201–207 because they are AndroidManifest.xml <activity> configuration blocks.
  • App-languages page: Gradle build blocks, gradle.properties configuration, AndroidManifest.xml snippets, and <locale-config> XML configuration lists left hardcoded on the guide page.
  • Localization page: Illustrative <string> and XLIFF XML examples left hardcoded on the guide page.
  • 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 examples 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 examples left hardcoded on the guide page.
  • String-resource page: Illustrative <string>, <string-array>, <plurals>, and AndroidManifest.xml XML snippets 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 examples left hardcoded on the guide page.

@djubinville
djubinville force-pushed the djubinville/app-resources-snippets branch from 8d8add4 to c52a1a3 Compare October 9, 2026 17:08

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