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:
2026-10-16 07:03:18 +01:00
parent d339827b5f
commit 1195535852
7 changed files with 430 additions and 6 deletions
+17
View File
@@ -28,6 +28,23 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--
The only exported-URI surface: fetched artifacts are shared out of
the app cache through ACTION_SEND. The provider is not exported
and grants read access per-uri (FLAG_GRANT_READ_URI_PERMISSION), and
file_paths.xml scopes it to the single `shared-artifacts` cache
subdirectory. No other app-visible file path is exposed.
-->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>