Correcly copy pasting NIP94 and NIP95 addresses.

pull/384/head
Vitor Pamplona 2023-04-27 15:40:28 -04:00
rodzic 78cfa98456
commit 362082d608
2 zmienionych plików z 33 dodań i 15 usunięć

Wyświetl plik

@ -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<ZoomableContent>
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 {

Wyświetl plik

@ -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
}