Use original URL instead of thumbnail URL for GIFs

- GIFs tend to be small enough to download directly
- Sometimes, thumbnails don't support animating

Change-Id: I9848d05f2f1565570f341847209712b9e4abfbac
This commit is contained in:
SpiritCroc 2021-05-31 13:39:15 +02:00
parent 5f1d0a7c8d
commit 0f43b49cbd
2 changed files with 8 additions and 1 deletions

View File

@ -77,7 +77,9 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
}
}
val animate = mediaData.mimeType == MimeTypes.Gif
imageContentRenderer.render(mediaData, mode, holder.imageView, onImageSizeListener, animate)
// Do not use thumbnails for animated GIFs - sometimes thumbnails do not animate while the original GIF does
val effectiveMode = if (animate && mode == ImageContentRenderer.Mode.THUMBNAIL) ImageContentRenderer.Mode.ANIMATED_THUMBNAIL else mode
imageContentRenderer.render(mediaData, effectiveMode, holder.imageView, onImageSizeListener, animate)
if (!attributes.informationData.sendState.hasFailed()) {
contentUploadStateTrackerBinder.bind(
attributes.informationData.eventId,

View File

@ -82,6 +82,9 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
enum class Mode {
FULL_SIZE,
THUMBNAIL,
// Animated thumbnail: scale like a thumbnail, but use full_size resource,
// since the thumbnail resource might not support animating.
ANIMATED_THUMBNAIL,
STICKER
}
@ -274,6 +277,7 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
val contentUrlResolver = activeSessionHolder.getActiveSession().contentUrlResolver()
val resolvedUrl = when (mode) {
Mode.FULL_SIZE,
Mode.ANIMATED_THUMBNAIL,
Mode.STICKER -> resolveUrl(data)
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, size.width, size.height, ContentUrlResolver.ThumbnailMethod.SCALE)
}
@ -348,6 +352,7 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
finalHeight = height
finalWidth = width
}
Mode.ANIMATED_THUMBNAIL,
Mode.THUMBNAIL -> {
finalHeight = min(maxImageWidth * height / width, maxImageHeight)
finalWidth = finalHeight * width / height