mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
Fix video thumbnail not displayed in when replying and in bottom sheet
Also create some extensions for future use
This commit is contained in:
parent
f7949100a7
commit
12c4f3c6f7
9 changed files with 44 additions and 14 deletions
|
@ -47,3 +47,10 @@ data class FileInfo(
|
|||
*/
|
||||
@Json(name = "thumbnail_file") val thumbnailFile: EncryptedFileInfo? = null
|
||||
)
|
||||
|
||||
/**
|
||||
* Get the url of the encrypted thumbnail or of the thumbnail
|
||||
*/
|
||||
fun FileInfo.getThumbnailUrl(): String? {
|
||||
return thumbnailFile?.url ?: thumbnailUrl
|
||||
}
|
||||
|
|
|
@ -57,3 +57,10 @@ data class ImageInfo(
|
|||
*/
|
||||
@Json(name = "thumbnail_file") val thumbnailFile: EncryptedFileInfo? = null
|
||||
)
|
||||
|
||||
/**
|
||||
* Get the url of the encrypted thumbnail or of the thumbnail
|
||||
*/
|
||||
fun ImageInfo.getThumbnailUrl(): String? {
|
||||
return thumbnailFile?.url ?: thumbnailUrl
|
||||
}
|
||||
|
|
|
@ -37,3 +37,10 @@ data class LocationInfo(
|
|||
*/
|
||||
@Json(name = "thumbnail_file") val thumbnailFile: EncryptedFileInfo? = null
|
||||
)
|
||||
|
||||
/**
|
||||
* Get the url of the encrypted thumbnail or of the thumbnail
|
||||
*/
|
||||
fun LocationInfo.getThumbnailUrl(): String? {
|
||||
return thumbnailFile?.url ?: thumbnailUrl
|
||||
}
|
||||
|
|
|
@ -62,3 +62,10 @@ data class VideoInfo(
|
|||
*/
|
||||
@Json(name = "thumbnail_file") val thumbnailFile: EncryptedFileInfo? = null
|
||||
)
|
||||
|
||||
/**
|
||||
* Get the url of the encrypted thumbnail or of the thumbnail
|
||||
*/
|
||||
fun VideoInfo.getThumbnailUrl(): String? {
|
||||
return thumbnailFile?.url ?: thumbnailUrl
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ import org.matrix.android.sdk.api.session.room.model.message.OPTION_TYPE_BUTTONS
|
|||
import org.matrix.android.sdk.api.session.room.model.message.OPTION_TYPE_POLL
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getFileName
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getFileUrl
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getThumbnailUrl
|
||||
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
|
||||
import org.matrix.android.sdk.api.util.MimeTypes
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
||||
|
@ -337,8 +338,7 @@ class MessageItemFactory @Inject constructor(
|
|||
eventId = informationData.eventId,
|
||||
filename = messageContent.body,
|
||||
mimeType = messageContent.mimeType,
|
||||
url = messageContent.videoInfo?.thumbnailFile?.url
|
||||
?: messageContent.videoInfo?.thumbnailUrl,
|
||||
url = messageContent.videoInfo?.getThumbnailUrl(),
|
||||
elementToDecrypt = messageContent.videoInfo?.thumbnailFile?.toElementToDecrypt(),
|
||||
height = messageContent.videoInfo?.height,
|
||||
maxHeight = maxHeight,
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.matrix.android.sdk.api.session.events.model.toModel
|
|||
import org.matrix.android.sdk.api.session.room.model.message.MessageImageContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageVideoContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getFileUrl
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getThumbnailUrl
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
||||
|
||||
|
@ -45,15 +46,16 @@ fun TimelineEvent.buildImageContentRendererData(maxHeight: Int): ImageContentRen
|
|||
}
|
||||
root.isVideoMessage() -> root.getClearContent().toModel<MessageVideoContent>()
|
||||
?.let { messageVideoContent ->
|
||||
val videoInfo = messageVideoContent.videoInfo
|
||||
ImageContentRenderer.Data(
|
||||
eventId = eventId,
|
||||
filename = messageVideoContent.body,
|
||||
mimeType = messageVideoContent.mimeType,
|
||||
url = messageVideoContent.getFileUrl(),
|
||||
elementToDecrypt = messageVideoContent.encryptedFileInfo?.toElementToDecrypt(),
|
||||
height = messageVideoContent.videoInfo?.height,
|
||||
mimeType = videoInfo?.thumbnailInfo?.mimeType,
|
||||
url = videoInfo?.getThumbnailUrl(),
|
||||
elementToDecrypt = videoInfo?.thumbnailFile?.toElementToDecrypt(),
|
||||
height = videoInfo?.thumbnailInfo?.height,
|
||||
maxHeight = maxHeight,
|
||||
width = messageVideoContent.videoInfo?.width,
|
||||
width = videoInfo?.thumbnailInfo?.width,
|
||||
maxWidth = maxHeight * 2,
|
||||
allowNonMxcUrls = false
|
||||
)
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.matrix.android.sdk.api.session.room.model.message.MessageImageContent
|
|||
import org.matrix.android.sdk.api.session.room.model.message.MessageVideoContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageWithAttachmentContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getFileUrl
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getThumbnailUrl
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import org.matrix.android.sdk.api.util.MimeTypes
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
||||
|
@ -78,8 +79,7 @@ class RoomEventsAttachmentProvider(
|
|||
eventId = it.eventId,
|
||||
filename = content.body,
|
||||
mimeType = content.mimeType,
|
||||
url = content.videoInfo?.thumbnailFile?.url
|
||||
?: content.videoInfo?.thumbnailUrl,
|
||||
url = content.videoInfo?.getThumbnailUrl(),
|
||||
elementToDecrypt = content.videoInfo?.thumbnailFile?.toElementToDecrypt(),
|
||||
height = content.videoInfo?.height,
|
||||
maxHeight = -1,
|
||||
|
@ -102,8 +102,7 @@ class RoomEventsAttachmentProvider(
|
|||
data = data,
|
||||
thumbnail = AttachmentInfo.Image(
|
||||
uid = it.eventId,
|
||||
url = content.videoInfo?.thumbnailFile?.url
|
||||
?: content.videoInfo?.thumbnailUrl ?: "",
|
||||
url = content.videoInfo?.getThumbnailUrl() ?: "",
|
||||
data = thumbnailData
|
||||
|
||||
)
|
||||
|
|
|
@ -50,6 +50,7 @@ import im.vector.app.features.roomprofile.uploads.RoomUploadsViewState
|
|||
import org.matrix.android.sdk.api.session.room.model.message.MessageImageContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageVideoContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getFileUrl
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getThumbnailUrl
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -141,8 +142,7 @@ class RoomUploadsMediaFragment @Inject constructor(
|
|||
eventId = it.eventId,
|
||||
filename = content.body,
|
||||
mimeType = content.mimeType,
|
||||
url = content.videoInfo?.thumbnailFile?.url
|
||||
?: content.videoInfo?.thumbnailUrl,
|
||||
url = content.videoInfo?.getThumbnailUrl(),
|
||||
elementToDecrypt = content.videoInfo?.thumbnailFile?.toElementToDecrypt(),
|
||||
height = content.videoInfo?.height,
|
||||
maxHeight = -1,
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.matrix.android.sdk.api.session.room.model.message.MessageImageContent
|
|||
import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
||||
import org.matrix.android.sdk.api.session.room.model.message.MessageVideoContent
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getFileUrl
|
||||
import org.matrix.android.sdk.api.session.room.model.message.getThumbnailUrl
|
||||
import org.matrix.android.sdk.api.session.room.uploads.UploadEvent
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
||||
import javax.inject.Inject
|
||||
|
@ -131,7 +132,7 @@ class UploadsMediaController @Inject constructor(
|
|||
eventId = eventId,
|
||||
filename = messageContent.body,
|
||||
mimeType = messageContent.mimeType,
|
||||
url = messageContent.videoInfo?.thumbnailFile?.url ?: messageContent.videoInfo?.thumbnailUrl,
|
||||
url = messageContent.videoInfo?.getThumbnailUrl(),
|
||||
elementToDecrypt = messageContent.videoInfo?.thumbnailFile?.toElementToDecrypt(),
|
||||
height = messageContent.videoInfo?.height,
|
||||
maxHeight = itemSize,
|
||||
|
|
Loading…
Reference in a new issue