mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-03-28 18:51: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
@ -1962,6 +1962,7 @@ class Account(
|
|||||||
if (isImage) {
|
if (isImage) {
|
||||||
PictureEvent.create(
|
PictureEvent.create(
|
||||||
url = url,
|
url = url,
|
||||||
|
msg = alt,
|
||||||
mimeType = headerInfo.mimeType,
|
mimeType = headerInfo.mimeType,
|
||||||
hash = headerInfo.hash,
|
hash = headerInfo.hash,
|
||||||
size = headerInfo.size.toLong(),
|
size = headerInfo.size.toLong(),
|
||||||
|
@ -250,6 +250,7 @@ fun VideoView(
|
|||||||
onControllerVisibilityChanged: ((Boolean) -> Unit)? = null,
|
onControllerVisibilityChanged: ((Boolean) -> Unit)? = null,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
alwaysShowVideo: Boolean = false,
|
alwaysShowVideo: Boolean = false,
|
||||||
|
showControls: Boolean = true,
|
||||||
) {
|
) {
|
||||||
val defaultToStart by remember(videoUri) { mutableStateOf(DEFAULT_MUTED_SETTING.value) }
|
val defaultToStart by remember(videoUri) { mutableStateOf(DEFAULT_MUTED_SETTING.value) }
|
||||||
|
|
||||||
@ -337,6 +338,7 @@ fun VideoView(
|
|||||||
onControllerVisibilityChanged = onControllerVisibilityChanged,
|
onControllerVisibilityChanged = onControllerVisibilityChanged,
|
||||||
onDialog = onDialog,
|
onDialog = onDialog,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
|
showControls = showControls,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import androidx.compose.animation.fadeOut
|
|||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.aspectRatio
|
import androidx.compose.foundation.layout.aspectRatio
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.text.InlineTextContent
|
import androidx.compose.foundation.text.InlineTextContent
|
||||||
@ -222,7 +223,7 @@ fun GalleryContentView(
|
|||||||
}
|
}
|
||||||
is MediaUrlVideo ->
|
is MediaUrlVideo ->
|
||||||
SensitivityWarning(content.contentWarning != null, accountViewModel) {
|
SensitivityWarning(content.contentWarning != null, accountViewModel) {
|
||||||
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||||
VideoView(
|
VideoView(
|
||||||
videoUri = content.url,
|
videoUri = content.url,
|
||||||
mimeType = content.mimeType,
|
mimeType = content.mimeType,
|
||||||
@ -230,11 +231,13 @@ fun GalleryContentView(
|
|||||||
artworkUri = content.artworkUri,
|
artworkUri = content.artworkUri,
|
||||||
borderModifier = MaterialTheme.colorScheme.videoGalleryModifier,
|
borderModifier = MaterialTheme.colorScheme.videoGalleryModifier,
|
||||||
authorName = content.authorName,
|
authorName = content.authorName,
|
||||||
dimensions = content.dim,
|
dimensions = Dimension(1, 1), // fit video in 1:1 ratio
|
||||||
blurhash = content.blurhash,
|
blurhash = content.blurhash,
|
||||||
isFiniteHeight = isFiniteHeight,
|
isFiniteHeight = isFiniteHeight,
|
||||||
nostrUriCallback = content.uri,
|
nostrUriCallback = content.uri,
|
||||||
accountViewModel = accountViewModel,
|
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.amethyst.model.User
|
||||||
import com.vitorpamplona.quartz.events.MuteListEvent
|
import com.vitorpamplona.quartz.events.MuteListEvent
|
||||||
import com.vitorpamplona.quartz.events.PeopleListEvent
|
import com.vitorpamplona.quartz.events.PeopleListEvent
|
||||||
|
import com.vitorpamplona.quartz.events.PictureEvent
|
||||||
import com.vitorpamplona.quartz.events.ProfileGalleryEntryEvent
|
import com.vitorpamplona.quartz.events.ProfileGalleryEntryEvent
|
||||||
|
import com.vitorpamplona.quartz.events.VideoEvent
|
||||||
|
|
||||||
class UserProfileGalleryFeedFilter(
|
class UserProfileGalleryFeedFilter(
|
||||||
val user: User,
|
val user: User,
|
||||||
@ -65,7 +67,7 @@ class UserProfileGalleryFeedFilter(
|
|||||||
): Boolean {
|
): Boolean {
|
||||||
val noteEvent = it.event
|
val noteEvent = it.event
|
||||||
return (
|
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) &&
|
params.match(noteEvent) &&
|
||||||
account.isAcceptable(it)
|
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.FeedPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.HalfPadding
|
import com.vitorpamplona.amethyst.ui.theme.HalfPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
|
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.ProfileGalleryEntryEvent
|
||||||
|
import com.vitorpamplona.quartz.events.VideoEvent
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RenderGalleryFeed(
|
fun RenderGalleryFeed(
|
||||||
@ -171,11 +174,22 @@ fun GalleryCardCompose(
|
|||||||
nav = nav,
|
nav = nav,
|
||||||
) { canPreview ->
|
) { canPreview ->
|
||||||
|
|
||||||
val galleryEvent = (baseNote.event as? ProfileGalleryEntryEvent) ?: return@CheckHiddenFeedWatchBlockAndReport
|
var galleryEvent = baseNote.event
|
||||||
|
var url = ""
|
||||||
|
var sourceEvent = galleryEvent?.id()
|
||||||
|
|
||||||
galleryEvent.url()?.let { image ->
|
if (baseNote.event is ProfileGalleryEntryEvent) {
|
||||||
val sourceEvent = galleryEvent.fromEvent()
|
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) {
|
if (sourceEvent != null) {
|
||||||
LoadNote(baseNoteHex = sourceEvent, accountViewModel = accountViewModel) { sourceNote ->
|
LoadNote(baseNoteHex = sourceEvent, accountViewModel = accountViewModel) { sourceNote ->
|
||||||
if (sourceNote != null) {
|
if (sourceNote != null) {
|
||||||
@ -338,7 +352,31 @@ fun InnerRenderGalleryThumb(
|
|||||||
note: Note,
|
note: Note,
|
||||||
accountViewModel: AccountViewModel,
|
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(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
@ -347,11 +385,6 @@ fun InnerRenderGalleryThumb(
|
|||||||
contentAlignment = BottomStart,
|
contentAlignment = BottomStart,
|
||||||
) {
|
) {
|
||||||
card.image?.let {
|
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
|
var content: BaseMediaContent? = null
|
||||||
|
|
||||||
if (isVideoUrl(it)) {
|
if (isVideoUrl(it)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user