mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-04 10:32:34 +00:00
Improve code and use type Video when necessary
This commit is contained in:
committed by
Benoit Marty
parent
566b0c6f86
commit
754eb3d0c1
+15
-7
@@ -111,13 +111,12 @@ internal fun InReplyToDetails.Ready.metadata(hideImage: Boolean): InReplyToMetad
|
|||||||
is GalleryMessageType -> {
|
is GalleryMessageType -> {
|
||||||
val caption = textContent?.takeIf { it.isNotBlank() }
|
val caption = textContent?.takeIf { it.isNotBlank() }
|
||||||
val isMediaGallery = type.items.all { it is GalleryItemType.Image || it is GalleryItemType.Video }
|
val isMediaGallery = type.items.all { it is GalleryItemType.Image || it is GalleryItemType.Video }
|
||||||
val countPlural = if (isMediaGallery) {
|
|
||||||
CommonPlurals.common_gallery_reply_media_items
|
|
||||||
} else {
|
|
||||||
CommonPlurals.common_gallery_reply_attachments
|
|
||||||
}
|
|
||||||
val text = caption ?: pluralStringResource(countPlural, type.items.size, type.items.size)
|
|
||||||
if (isMediaGallery) {
|
if (isMediaGallery) {
|
||||||
|
val text = caption ?: pluralStringResource(
|
||||||
|
CommonPlurals.common_gallery_reply_media_items,
|
||||||
|
type.items.size,
|
||||||
|
type.items.size,
|
||||||
|
)
|
||||||
val firstMediaItem = type.items.firstOrNull { it is GalleryItemType.Image || it is GalleryItemType.Video }
|
val firstMediaItem = type.items.firstOrNull { it is GalleryItemType.Image || it is GalleryItemType.Video }
|
||||||
val thumbnailSource = when (firstMediaItem) {
|
val thumbnailSource = when (firstMediaItem) {
|
||||||
is GalleryItemType.Image -> (firstMediaItem.content.info?.thumbnailSource ?: firstMediaItem.content.source).takeUnless { hideImage }
|
is GalleryItemType.Image -> (firstMediaItem.content.info?.thumbnailSource ?: firstMediaItem.content.source).takeUnless { hideImage }
|
||||||
@@ -129,15 +128,24 @@ internal fun InReplyToDetails.Ready.metadata(hideImage: Boolean): InReplyToMetad
|
|||||||
is GalleryItemType.Video -> firstMediaItem.content.info?.blurhash
|
is GalleryItemType.Video -> firstMediaItem.content.info?.blurhash
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
val type = when (firstMediaItem) {
|
||||||
|
is GalleryItemType.Video -> AttachmentThumbnailType.Video
|
||||||
|
else -> AttachmentThumbnailType.Image
|
||||||
|
}
|
||||||
Thumbnail(
|
Thumbnail(
|
||||||
AttachmentThumbnailInfo(
|
AttachmentThumbnailInfo(
|
||||||
thumbnailSource = thumbnailSource,
|
thumbnailSource = thumbnailSource,
|
||||||
textContent = text,
|
textContent = text,
|
||||||
type = AttachmentThumbnailType.Image,
|
type = type,
|
||||||
blurHash = blurHash,
|
blurHash = blurHash,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
val text = caption ?: pluralStringResource(
|
||||||
|
CommonPlurals.common_gallery_reply_attachments,
|
||||||
|
type.items.size,
|
||||||
|
type.items.size,
|
||||||
|
)
|
||||||
Thumbnail(
|
Thumbnail(
|
||||||
AttachmentThumbnailInfo(
|
AttachmentThumbnailInfo(
|
||||||
textContent = text,
|
textContent = text,
|
||||||
|
|||||||
Reference in New Issue
Block a user