diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt index 55292064d..bb31eeb9e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/components/ZoomableContentView.kt @@ -80,25 +80,29 @@ abstract class ZoomableContent( abstract class ZoomableUrlContent( val url: String, description: String? = null, - val hash: String? = null + val hash: String? = null, + val uri: String? = null ) : ZoomableContent(description) class ZoomableUrlImage( url: String, description: String? = null, hash: String? = null, - val bluehash: String? = null -) : ZoomableUrlContent(url, description, hash) + val bluehash: String? = null, + uri: String? = null +) : ZoomableUrlContent(url, description, hash, uri) class ZoomableUrlVideo( url: String, description: String? = null, - hash: String? = null -) : ZoomableUrlContent(url, description, hash) + hash: String? = null, + uri: String? = null +) : ZoomableUrlContent(url, description, hash, uri) abstract class ZoomablePreloadedContent( description: String? = null, - val isVerified: Boolean? = null + val isVerified: Boolean? = null, + val uri: String ) : ZoomableContent(description) class ZoomableBitmapImage( @@ -106,15 +110,17 @@ class ZoomableBitmapImage( val mimeType: String? = null, description: String? = null, val bluehash: String? = null, - isVerified: Boolean? = null -) : ZoomablePreloadedContent(description, isVerified) + isVerified: Boolean? = null, + uri: String +) : ZoomablePreloadedContent(description, isVerified, uri) class ZoomableBytesVideo( val byteArray: ByteArray, val mimeType: String? = null, description: String? = null, - isVerified: Boolean? = null -) : ZoomablePreloadedContent(description, isVerified) + isVerified: Boolean? = null, + uri: String +) : ZoomablePreloadedContent(description, isVerified, uri) fun figureOutMimeType(fullUrl: String): ZoomableContent { val removedParamsFromUrl = fullUrl.split("?")[0].lowercase() @@ -189,7 +195,17 @@ fun ZoomableContentView(content: ZoomableContent, images: List if (content is ZoomableUrlContent) { mainImageModifier = mainImageModifier.combinedClickable( onClick = { dialogOpen = true }, - onLongClick = { clipboardManager.setText(AnnotatedString(content.url)) } + onLongClick = { clipboardManager.setText(AnnotatedString(content.uri ?: content.url)) } + ) + } else if (content is ZoomableBitmapImage) { + mainImageModifier = mainImageModifier.combinedClickable( + onClick = { dialogOpen = true }, + onLongClick = { clipboardManager.setText(AnnotatedString(content.uri)) } + ) + } else if (content is ZoomableBytesVideo) { + mainImageModifier = mainImageModifier.combinedClickable( + onClick = { dialogOpen = true }, + onLongClick = { clipboardManager.setText(AnnotatedString(content.uri)) } ) } else { mainImageModifier = mainImageModifier.clickable { diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt index bdc8aba6f..0f2237fd5 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/NoteCompose.kt @@ -795,10 +795,11 @@ fun FileHeaderDisplay(note: Note) { val removedParamsFromUrl = fullUrl.split("?")[0].lowercase() val isImage = imageExtensions.any { removedParamsFromUrl.endsWith(it) } val isVideo = videoExtensions.any { removedParamsFromUrl.endsWith(it) } + val uri = "nostr:" + note.toNEvent() content = if (isImage) { - ZoomableUrlImage(fullUrl, description, hash, blurHash) + ZoomableUrlImage(fullUrl, description, hash, blurHash, uri) } else { - ZoomableUrlVideo(fullUrl, description, hash) + ZoomableUrlVideo(fullUrl, description, hash, uri) } } } @@ -823,16 +824,17 @@ fun FileStorageHeaderDisplay(baseNote: Note) { LaunchedEffect(key1 = eventHeader.id, key2 = noteState) { withContext(Dispatchers.IO) { + val uri = "nostr:" + baseNote.toNEvent() val bytes = eventBytes?.decode() val blurHash = eventHeader.blurhash() val description = eventHeader.content val mimeType = eventHeader.mimeType() content = if (mimeType?.startsWith("image") == true) { - ZoomableBitmapImage(bytes, mimeType, description, blurHash, true) + ZoomableBitmapImage(bytes, mimeType, description, blurHash, true, uri) } else { if (bytes != null) { - ZoomableBytesVideo(bytes, mimeType, description, true) + ZoomableBytesVideo(bytes, mimeType, description, true, uri) } else { null }