Add a real share action to every artifact item
Give each gallery image cell and each per-visit file row its own share control: a 48dp IconButton with an accurate "Share <name>" content description drawn as a sibling of the item's tap handler, so sharing never opens the image or the item. Sharing fetches the artifact through the existing client into a scoped cache file (cache/shared-artifacts/), exposed via a non-exported FileProvider declared with the new res/xml/file_paths.xml, and sends it through ACTION_SEND. When the fetch returns nothing the action falls back to sharing the resolved link as text. Cache files are named deterministically per artifact so re-sharing overwrites instead of growing without bound, and a failed or unreachable fetch cannot crash. The artifact-to-file naming, mime/extension table and the file-vs-link fallback decision are factored into ArtifactSharing.kt and covered by the new ArtifactSharingTest.kt. The existing open and copy-link actions are unchanged; the viewer's action scrim alpha is shared as ARTIFACT_ACTION_SCRIM_ALPHA. android/README.md documents the provider and the share flow. No new dependency is added.
This commit is contained in:
@@ -1760,3 +1760,63 @@ Not verified in this pass: a real hardware fold (the emulator is the 2076x2152
|
||||
inner display at 390 dpi); an Android 8/9 device branch (the `layoutInDisplayCutout
|
||||
Mode = SHORT_EDGES` fallback is compiled and lint-guarded but only the API 36 path
|
||||
ran).
|
||||
|
||||
## Share every artifact, from the grid cells and the per-visit rows (16 Oct 2026)
|
||||
|
||||
Every artifact item now carries a real share action: each image cell in a gallery
|
||||
grid (`ArtifactTile`) and each non-image row (`ArtifactRow`) has its own
|
||||
`ArtifactShareButton`. It is a child `IconButton` — its own 48dp hit area — so a
|
||||
tap on it consumes the gesture and never opens the image or the item, and its
|
||||
content description is `Share <name>`.
|
||||
|
||||
Sharing is not a stub. The new `ui/graph/ArtifactSharing.kt` fetches the resolved
|
||||
artifact through the app's existing client (`AppViewModel.fetchArtifactBytes` →
|
||||
`PipelinesClient.fetchBytes`, the shared OkHttp client) into
|
||||
`cacheDir/shared-artifacts/` and hands the file to the platform chooser through the
|
||||
declared `androidx.core.content.FileProvider` (`${applicationId}.fileprovider`,
|
||||
scoped by `res/xml/file_paths.xml` to that one cache subdirectory, not exported).
|
||||
The intent is `ACTION_SEND` with `EXTRA_STREAM`, `ClipData.newUri`, MIME
|
||||
`shareMimeType(contentType, fileName)` and `FLAG_GRANT_READ_URI_PERMISSION`, so the
|
||||
receiving app gets the actual bytes. When the fetch fails the artifact's resolved
|
||||
link is shared as `text/plain` instead (`shareDelivery`). The cache is bounded:
|
||||
`pruneSharedArtifacts` drops entries older than a day and enforces a 64 MiB cap,
|
||||
oldest first. No new dependency: `FileProvider` comes from the already-declared
|
||||
`androidx.core.ktx` and the share glyph from the already-declared
|
||||
`material-icons-extended`.
|
||||
|
||||
- `gradle :app:testDebugUnitTest` → **157 tests, 0 failures**; the 7 new ones are
|
||||
`ArtifactSharingTest` (file/link fallback decision, artifact-to-file naming:
|
||||
content-type/url extension, suffix de-duplication, path sanitisation, per-url
|
||||
distinctness, and `shareMimeType`).
|
||||
- `gradle :app:assembleDebug` → succeeded, `app-debug.apk` 18,283,787 bytes,
|
||||
sha256 `52ad15a6…`.
|
||||
- On `emulator-5554` (density 390) against the live server, run 91's summary: the
|
||||
uiautomator dump shows a clickable share node of `117x117px` = **48dp** with a
|
||||
`Share …` content description beside every preview; the grid and the `.mp4` row
|
||||
were captured (validated by `scripts/capture_png.sh -s emulator-5554`) to
|
||||
`grid_cell_share.png` and `list_row_share.png`.
|
||||
- Tapping a cell's share launched the chooser with the fetched file — logcat
|
||||
`ActivityTaskManager: START u0 {act=android.intent.action.SEND … clip={image/png
|
||||
…}}` (image/png), and the sharesheet showed a live preview of the actual PNG
|
||||
(`share_intent_image_png.png`). The `.mp4` row's share resolved to
|
||||
`clip={video/mp4 …}`; the cached files are
|
||||
`viewer_01_viewer_open_2f01f94a.png` and `viewer_viewer_gestures_8e1a3ba4.mp4`
|
||||
under `cache/shared-artifacts/`.
|
||||
- Fallback exercised live: with `adb shell cmd connectivity airplane-mode enable`
|
||||
(10.0.2.2 unreachable), tapping share opened the chooser titled **Sharing link**
|
||||
with the resolved `http://10.0.2.2:8080/artifacts/91/1/viewer/viewer_gestures.mp4`
|
||||
as text (`share_fallback_link.png`); `adb logcat -d` held 0 `FATAL EXCEPTION`.
|
||||
Airplane mode was then disabled and the app reconnected.
|
||||
- Open and copy-link are unchanged and still enabled on both items.
|
||||
- **APK publish.** `~/.local/share/pipelines/data/artifacts/94/1/pipelines-debug-wip-d339827.apk`
|
||||
(`d339827` = `git rev-parse --short HEAD`), sha256 `52ad15a6…`; `curl -I
|
||||
http://10.0.0.75:8080/artifacts/94/1/pipelines-debug-wip-d339827.apk` returned
|
||||
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 18283787` (18 MB, over the 8 MiB inventory cap, so direct URL
|
||||
only). `10.0.0.75` is `scripts/lan-address.py`'s output; `10.0.0.249` served it
|
||||
too.
|
||||
|
||||
Not verified in this pass: receiving the shared file inside a third-party app (the
|
||||
chooser was observed, not an app's import); the 24 h / 64 MiB prune bound was not
|
||||
reached on the emulator (only two small files were written).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user