mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-18 22:01:45 +01:00
hybrid solution nip68 / nip93
it keeps the nip93 gallery as before, but also adds all nip68 media to the gallery
This commit is contained in:
parent
9180eeb59f
commit
a3257a365b
amethyst/src/main/java/com/vitorpamplona/amethyst
model
ui
components
dal
screen/loggedIn/profile
@ -1962,6 +1962,7 @@ class Account(
|
||||
if (isImage) {
|
||||
PictureEvent.create(
|
||||
url = url,
|
||||
msg = alt,
|
||||
mimeType = headerInfo.mimeType,
|
||||
hash = headerInfo.hash,
|
||||
size = headerInfo.size.toLong(),
|
||||
|
@ -250,6 +250,7 @@ fun VideoView(
|
||||
onControllerVisibilityChanged: ((Boolean) -> Unit)? = null,
|
||||
accountViewModel: AccountViewModel,
|
||||
alwaysShowVideo: Boolean = false,
|
||||
showControls: Boolean = true,
|
||||
) {
|
||||
val defaultToStart by remember(videoUri) { mutableStateOf(DEFAULT_MUTED_SETTING.value) }
|
||||
|
||||
@ -337,6 +338,7 @@ fun VideoView(
|
||||
onControllerVisibilityChanged = onControllerVisibilityChanged,
|
||||
onDialog = onDialog,
|
||||
accountViewModel = accountViewModel,
|
||||
showControls = showControls,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.text.InlineTextContent
|
||||
@ -222,7 +223,7 @@ fun GalleryContentView(
|
||||
}
|
||||
is MediaUrlVideo ->
|
||||
SensitivityWarning(content.contentWarning != null, accountViewModel) {
|
||||
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
VideoView(
|
||||
videoUri = content.url,
|
||||
mimeType = content.mimeType,
|
||||
@ -230,11 +231,13 @@ fun GalleryContentView(
|
||||
artworkUri = content.artworkUri,
|
||||
borderModifier = MaterialTheme.colorScheme.videoGalleryModifier,
|
||||
authorName = content.authorName,
|
||||
dimensions = content.dim,
|
||||
dimensions = Dimension(1, 1), // fit video in 1:1 ratio
|
||||
blurhash = content.blurhash,
|
||||
isFiniteHeight = isFiniteHeight,
|
||||
nostrUriCallback = content.uri,
|
||||
accountViewModel = accountViewModel,
|
||||
alwaysShowVideo = true,
|
||||
showControls = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,9 @@ import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.amethyst.model.User
|
||||
import com.vitorpamplona.quartz.events.MuteListEvent
|
||||
import com.vitorpamplona.quartz.events.PeopleListEvent
|
||||
import com.vitorpamplona.quartz.events.PictureEvent
|
||||
import com.vitorpamplona.quartz.events.ProfileGalleryEntryEvent
|
||||
import com.vitorpamplona.quartz.events.VideoEvent
|
||||
|
||||
class UserProfileGalleryFeedFilter(
|
||||
val user: User,
|
||||
@ -65,7 +67,7 @@ class UserProfileGalleryFeedFilter(
|
||||
): Boolean {
|
||||
val noteEvent = it.event
|
||||
return (
|
||||
(it.event?.pubKey() == user.pubkeyHex && noteEvent is ProfileGalleryEntryEvent) && noteEvent.hasUrl() && noteEvent.hasFromEvent() // && noteEvent.isOneOf(SUPPORTED_VIDEO_FEED_MIME_TYPES_SET))
|
||||
(it.event?.pubKey() == user.pubkeyHex && (noteEvent is PictureEvent || noteEvent is VideoEvent || (noteEvent is ProfileGalleryEntryEvent) && noteEvent.hasUrl() && noteEvent.hasFromEvent())) // && noteEvent.isOneOf(SUPPORTED_VIDEO_FEED_MIME_TYPES_SET))
|
||||
) &&
|
||||
params.match(noteEvent) &&
|
||||
account.isAcceptable(it)
|
||||
|
@ -77,7 +77,10 @@ import com.vitorpamplona.amethyst.ui.theme.DividerThickness
|
||||
import com.vitorpamplona.amethyst.ui.theme.FeedPadding
|
||||
import com.vitorpamplona.amethyst.ui.theme.HalfPadding
|
||||
import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
|
||||
import com.vitorpamplona.quartz.events.Dimension
|
||||
import com.vitorpamplona.quartz.events.PictureEvent
|
||||
import com.vitorpamplona.quartz.events.ProfileGalleryEntryEvent
|
||||
import com.vitorpamplona.quartz.events.VideoEvent
|
||||
|
||||
@Composable
|
||||
fun RenderGalleryFeed(
|
||||
@ -171,11 +174,22 @@ fun GalleryCardCompose(
|
||||
nav = nav,
|
||||
) { canPreview ->
|
||||
|
||||
val galleryEvent = (baseNote.event as? ProfileGalleryEntryEvent) ?: return@CheckHiddenFeedWatchBlockAndReport
|
||||
var galleryEvent = baseNote.event
|
||||
var url = ""
|
||||
var sourceEvent = galleryEvent?.id()
|
||||
|
||||
galleryEvent.url()?.let { image ->
|
||||
val sourceEvent = galleryEvent.fromEvent()
|
||||
if (baseNote.event is ProfileGalleryEntryEvent) {
|
||||
url = (baseNote.event as ProfileGalleryEntryEvent).url().toString()
|
||||
sourceEvent = (baseNote.event as? ProfileGalleryEntryEvent)?.fromEvent()
|
||||
} else if (baseNote.event is PictureEvent) {
|
||||
url = (baseNote.event as PictureEvent).imetaTags()[0].url
|
||||
sourceEvent = (baseNote.event as PictureEvent).id()
|
||||
} else if (baseNote.event is VideoEvent) {
|
||||
url = (baseNote.event as VideoEvent).url().toString()
|
||||
sourceEvent = (baseNote.event as VideoEvent).id()
|
||||
}
|
||||
|
||||
url.let { image ->
|
||||
if (sourceEvent != null) {
|
||||
LoadNote(baseNoteHex = sourceEvent, accountViewModel = accountViewModel) { sourceNote ->
|
||||
if (sourceNote != null) {
|
||||
@ -338,7 +352,31 @@ fun InnerRenderGalleryThumb(
|
||||
note: Note,
|
||||
accountViewModel: AccountViewModel,
|
||||
) {
|
||||
val noteEvent = note.event as? ProfileGalleryEntryEvent ?: return
|
||||
var noteEvent = note.event
|
||||
var blurHash = ""
|
||||
var description = ""
|
||||
var dimensions: Dimension? = null
|
||||
var mimeType = ""
|
||||
if (note.event is ProfileGalleryEntryEvent) {
|
||||
noteEvent = (note.event as ProfileGalleryEntryEvent)
|
||||
blurHash = noteEvent.blurhash().toString()
|
||||
description = noteEvent.content
|
||||
// var hash = (note.event as ProfileGalleryEntryEvent).hash()
|
||||
dimensions = noteEvent.dimensions()
|
||||
mimeType = noteEvent.mimeType().toString()
|
||||
} else if (note.event is PictureEvent) {
|
||||
noteEvent = (note.event as PictureEvent)
|
||||
blurHash = noteEvent.blurhash().toString()
|
||||
description = noteEvent.content
|
||||
dimensions = noteEvent.dimensions()
|
||||
mimeType = noteEvent.mimeType().toString()
|
||||
} else if (note.event is VideoEvent) {
|
||||
noteEvent = (note.event as VideoEvent)
|
||||
blurHash = noteEvent.blurhash().toString()
|
||||
description = noteEvent.content
|
||||
dimensions = noteEvent.dimensions()
|
||||
mimeType = noteEvent.mimeType().toString()
|
||||
}
|
||||
|
||||
Box(
|
||||
Modifier
|
||||
@ -347,11 +385,6 @@ fun InnerRenderGalleryThumb(
|
||||
contentAlignment = BottomStart,
|
||||
) {
|
||||
card.image?.let {
|
||||
val blurHash = noteEvent.blurhash()
|
||||
val description = noteEvent.content
|
||||
// var hash = (note.event as ProfileGalleryEntryEvent).hash()
|
||||
val dimensions = noteEvent.dimensions()
|
||||
val mimeType = noteEvent.mimeType()
|
||||
var content: BaseMediaContent? = null
|
||||
|
||||
if (isVideoUrl(it)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user