From 5aa001229a046272fe49ba88b4ff7adc461469cb Mon Sep 17 00:00:00 2001 From: davotoula Date: Sun, 3 May 2026 20:33:12 +0200 Subject: [PATCH] refactor(gallery): use HlsContentTypes constant and tighten comments Use the existing HlsContentTypes.HLS_PLAYLIST constant for the canonical HLS playlist mime in GalleryThumb's isHlsMimeType so the read-side stays in sync with the publish path (HlsVideoEventBuilder, HlsPublishOrchestrator). Trim two block comments down to the non-obvious WHY only. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../amethyst/ui/components/ZoomableContentView.kt | 7 +++---- .../ui/screen/loggedIn/profile/gallery/GalleryThumb.kt | 7 ++++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt index e530ec028..372834263 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt @@ -940,10 +940,9 @@ fun ShareMediaAction( if (videoUri != null) { val n19 = Nip19Parser.uriToRoute(postNostrUri)?.entity as? NEvent if (n19 != null) { - // Forward the imeta poster (only MediaUrlVideo carries it) so HLS - // gallery entries have a still to render — without this, a video - // event whose imeta only contains a .m3u8 URL renders as a black - // play-icon tile in the gallery. + // Forward the imeta poster so HLS gallery entries have a decodable + // still — the .m3u8 URL itself is a text manifest. Only + // MediaUrlVideo carries an artworkUri. val posterUrl = (content as? MediaUrlVideo)?.artworkUri accountViewModel.addMediaToGallery(n19.hex, videoUri, n19.relay.getOrNull(0), blurhash, dim, hash, mimeType, image = posterUrl) accountViewModel.toastManager.toast(R.string.media_added, R.string.media_added_to_profile_gallery) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt index fa499ea17..a3c6af09c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/gallery/GalleryThumb.kt @@ -39,6 +39,7 @@ import androidx.media3.common.util.UnstableApi import coil3.compose.AsyncImagePainter import coil3.compose.SubcomposeAsyncImage import coil3.compose.SubcomposeAsyncImageContent +import com.davotoula.lightcompressor.hls.HlsContentTypes import com.vitorpamplona.amethyst.R import com.vitorpamplona.amethyst.commons.icons.symbols.Icon import com.vitorpamplona.amethyst.commons.icons.symbols.MaterialSymbols @@ -66,11 +67,11 @@ import com.vitorpamplona.quartz.nip53LiveActivities.clip.LiveActivitiesClipEvent import com.vitorpamplona.quartz.nip68Picture.PictureEvent import com.vitorpamplona.quartz.nip71Video.VideoEvent -// HLS playlist mime types as published in NIP-71 imeta tags. Mirrors the canonical list used in -// MediaItemCache.toExoPlayerMimeType. Kept inline to avoid creating a one-off helper module. +// Mirrors the canonical HLS-playlist mime list used in MediaItemCache.toExoPlayerMimeType. +// Kept inline rather than extracting a shared helper for one read-side caller. private fun isHlsMimeType(mimeType: String?): Boolean = when (mimeType?.lowercase()) { - "application/vnd.apple.mpegurl", + HlsContentTypes.HLS_PLAYLIST, "application/x-mpegurl", "audio/x-mpegurl", "audio/mpegurl",