feat(android): add Photos and Camera tiles to block inserter#509
Merged
Conversation
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/509")Built from 7e94992 |
50da710 to
6353b11
Compare
Adds a Photos / Camera quick-launch row between the inserter's header
and category tabs:
- Photos tile uses the permissionless system photo picker
(`ActivityResultContracts.PickVisualMedia`) — no manifest permission
required.
- Camera tile uses `ACTION_IMAGE_CAPTURE` against a cache-scoped
FileProvider URI; no `CAMERA` permission required since we delegate
to the system camera app.
The library declares its own FileProvider keyed off
`${applicationId}.gutenberg.fileprovider` so it can't collide with one
a host app already declares. No `uses-permission` lines added at this
stage — the recent-photos thumbnail strip that needs
`READ_MEDIA_IMAGES` lands in a follow-up.
The picker / camera result callbacks are intentionally inert until the
WebViewAssetLoader-based URI hand-off lands; the sheet is gated behind
the demo's "Enable Native Inserter" toggle in the meantime.
6353b11 to
0943b8a
Compare
…aUri comment
Wrap PickVisualMediaRequest in `remember { ... }` so the request isn't
rebuilt on each recomposition, and expand the pendingCameraUri comment
to make clear it's set for the follow-up TakePicture callback (the inert
callback today doesn't read it).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
adalpari
approved these changes
May 14, 2026
Contributor
adalpari
left a comment
There was a problem hiding this comment.
Just made a small change related to recomposition.
But overall, the PR looks good to me! 🚢 it!!
The earlier remember wrap pushed MediaStrip to 60 lines, tripping Detekt's LongMethod (threshold 60). Collapse to a single line — fits under MaxLineLength (140). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Photos / Camera quick-launch row between the inserter's header and category tabs. First slice of a four-part split of #479; covers just the permissionless tiles.
ActivityResultContracts.PickVisualMedia— the system photo picker, no manifest permission required.ACTION_IMAGE_CAPTUREagainst a cache-scoped FileProvider URI. The library does not declare or requestCAMERA— but per theMediaStore.ACTION_IMAGE_CAPTUREdocs, if a host app does declareCAMERAin its merged manifest, Android requires the host to hold it at runtime before the intent dispatches. That's a host-app concern, not a library one — flagging it here so the follow-up that wires up the hand-off doesn't get surprised.The library declares its own
FileProviderkeyed off${applicationId}.gutenberg.fileproviderso it can't collide with one a host app already declares.No
uses-permissionlines are added in this PR. The recent-photos thumbnail strip that needsREAD_MEDIA_IMAGESlands in the follow-up.Design notes
Spacerbetween them. The block tiles below use an 8dp gap; the media tiles are intentionally punchier to read as quick actions, not as members of the block grid.What does not land here (follow-ups)
READ_MEDIA_IMAGES/READ_EXTERNAL_STORAGEdeclarations — next PR in the stack.READ_MEDIA_VISUAL_USER_SELECTEDpartial-access support and the "Manage" tile — PR after that.Result-callback inertness
Both launcher result callbacks are intentionally empty:
The picked URI / camera capture needs to round-trip through
WebViewAssetLoaderso the JS editor canfetch()it — that hand-off is a follow-up. Until then, this whole sheet is gated behind the demo's "Enable Native Inserter" toggle, so users outside that opt-in don't see the no-op buttons.A
TODOoncreateCameraOutputUriflags that each Camera tap creates an orphan file in the cache today; cleanup lands when the hand-off does.Test plan
FEATURE_CAMERA_ANY(tablet/emulator without a camera)../gradlew :Gutenberg:detekt :Gutenberg:assembleDebug :Gutenberg:testDebugUnitTestpasses.