Skip to content

feat: implement Jetpack Compose sample catalog - #2422

Open
dkhawk wants to merge 3 commits into
mainfrom
feat/compose-sample-catalog
Open

dkhawk wants to merge 3 commits into
mainfrom
feat/compose-sample-catalog

Conversation

@dkhawk

@dkhawk dkhawk commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Introduce :ApiDemos:common-ui with SampleCatalogRegistry, SampleMetadata, and SampleEvaluation domain models.
  • Implement CatalogScreen and CatalogActivity using Jetpack Compose with search, complexity/category filtering, and key API call signatures.
  • Wire CatalogActivity as the main launcher in kotlin-app and java-app manifests and MainActivity.
  • Per catalog architecture, rely on concise @Sample(apiCalls) signatures rather than embedding raw source code strings in the APK.

Stacked Base

Stacked on #2421 (chore/build-security-hygiene).

Reviewers

@kikoso @LoyalAbbas

@dkhawk
dkhawk force-pushed the feat/compose-sample-catalog branch from 7f4845b to d9bc7d6 Compare September 15, 2026 00:24
@dkhawk
dkhawk force-pushed the feat/compose-sample-catalog branch from d9bc7d6 to 970df98 Compare September 15, 2026 00:32
@dkhawk
dkhawk marked this pull request as ready for review September 15, 2026 00:38
@dkhawk
dkhawk requested review from LoyalAbbas and kikoso September 15, 2026 00:38
@snippet-bot

snippet-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

No region tags are edited in this PR.

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

@dkhawk
dkhawk added this pull request to stack #2429 September 15, 2026 00:42
popupMenu.show();
});
}
// [END_EXCLUDE]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocker (Why CI snippet-bot check is Failing)
SampleCodeProvider.kt Contains Unbalanced / Duplicate Region Tags
File: SampleCodeProvider.kt:L2426-L3029
Problem: SampleCodeProvider.kt embeds copy-pasted source code inside raw Kotlin string literals ("""..."""), including literal // [START ...] and // [END ...] documentation tags, plus an orphan // [END_EXCLUDE] at line 3029 with no matching // [START_EXCLUDE].
Impact: Google's snippet-bot scans all .kt/.java files in the repo for region tags and fails the PR because of duplicate tags and the unmatched [END_EXCLUDE].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LoyalAbbas! In 4ab1994b we stripped the literal region tags to resolve the snippet-bot failure. Furthermore, per our catalog architectural standard (favoring concise @Sample(apiCalls) signatures over embedding ~4,000 lines of raw source code strings in the APK), in 35231636 we completely removed SampleCodeProvider and unused snippet views. All CI checks are green.

@dkhawk
dkhawk force-pushed the feat/compose-sample-catalog branch from 970df98 to 4ab1994 Compare September 15, 2026 17:16

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android Lint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Base automatically changed from chore/build-security-hygiene to main September 17, 2026 22:33
- Introduce :ApiDemos:common-ui with SampleCatalogRegistry and pure domain SampleEvaluation model
- Implement CatalogScreen and CatalogActivity using Jetpack Compose with search, framework filtering, and sample details
- Add syntax-highlighted CodeSnippetView and SampleCodeProvider
- Wire CatalogActivity as the main launcher in kotlin-app and java-app manifests and MainActivity
@dkhawk
dkhawk force-pushed the feat/compose-sample-catalog branch from 4ab1994 to 4206975 Compare September 17, 2026 22:33
@@ -0,0 +1,19101 @@
<?xml version="1.0" encoding="UTF-8"?>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking. This file is 569,870 bytes (0.54 MB) and accounts for 19,101 of this PR's 23,277 added lines, but nothing references it.

I grepped the PR tree for both fowler_rattlesnake and R.raw. across .kt / .java / .xml. The other raw resources are used (mapstyle_retro, mapstyle_night, mapstyle_grayscale, geojson_file, police_stations), this one has zero references anywhere.

Because it lands in common-ui, which both :ApiDemos:java-app and :ApiDemos:kotlin-app depend on, it ships inside both sample APKs as dead weight.

If it is a fixture for work still in flight, src/androidTest/assets/ keeps it out of the shipped APK. Otherwise I'd drop it from this PR and add it alongside whatever demo consumes it.

implementation(libs.ui.graphics)
implementation(libs.ui.tooling.preview)
implementation(libs.material3)
implementation(libs.material.icons.extended)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking, but worth a deliberate decision rather than inheriting it.

common-ui is the shared View-based library that both :ApiDemos:java-app and :ApiDemos:kotlin-app depend on, and it keeps viewBinding = true. This PR turns it into a Compose module as well, so every consumer now pulls the full Compose runtime, material3, and material-icons-extended whether or not they render any Compose.

material-icons-extended is the one I'd look at hardest. It is a very large artifact (thousands of vector assets), and it is easy to pay for all of it if R8 cannot prove the icons are unused, which is common when icons are selected indirectly. If only a handful of icons are needed, importing them individually from material-icons-core, or keeping the local vector drawables this PR already adds (ic_status_passing, ic_drag_pan, and the rest), avoids the question entirely.

The alternative shape is a separate :ApiDemos:catalog module that depends on common-ui, leaving the shared View library unchanged for the Java app. Either way, a before and after APK size for :ApiDemos:java-app would settle it.

@@ -0,0 +1,1038 @@
/*

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is 1,038 lines, and it's the largest hand-written file in the PR. For a sample repo, where the code is itself the documentation and people read it to learn the API, that works against the goal. Splitting the catalog list, the detail pane and the filter/search UI into their own files would make each one readable on its own.

More generally: this PR adds ~4,000 lines of hand-written code (23k total, minus the 19k GPX file) and no tests. The catalog has genuinely testable logic that doesn't need a device, SampleCatalogRegistry and SampleEvaluation in particular. A JVM test asserting the registry is well-formed (no duplicate ids, every entry resolves to a real Activity, no empty titles) would be cheap and would catch the most likely way this breaks later, which is someone adding a sample and mistyping an entry.

Worth noting #2426 and #2427 both ship androidTest suites, so the catalog work here is the outlier.

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.

4 participants