Merge pull request #6215 from networkException/fix-animated-only-fetching-thumbnail
Fix animated images only autoplaying sometimes
This commit is contained in:
commit
2cb16d9f11
|
@ -0,0 +1 @@
|
||||||
|
Fix animated images not autoplaying sometimes if only a thumbnail was fetched from the server
|
|
@ -453,12 +453,15 @@ class MessageItemFactory @Inject constructor(
|
||||||
maxWidth = maxWidth,
|
maxWidth = maxWidth,
|
||||||
allowNonMxcUrls = informationData.sendState.isSending()
|
allowNonMxcUrls = informationData.sendState.isSending()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val playable = messageContent.mimeType == MimeTypes.Gif
|
||||||
|
|
||||||
return MessageImageVideoItem_()
|
return MessageImageVideoItem_()
|
||||||
.attributes(attributes)
|
.attributes(attributes)
|
||||||
.leftGuideline(avatarSizeProvider.leftGuideline)
|
.leftGuideline(avatarSizeProvider.leftGuideline)
|
||||||
.imageContentRenderer(imageContentRenderer)
|
.imageContentRenderer(imageContentRenderer)
|
||||||
.contentUploadStateTrackerBinder(contentUploadStateTrackerBinder)
|
.contentUploadStateTrackerBinder(contentUploadStateTrackerBinder)
|
||||||
.playable(messageContent.mimeType == MimeTypes.Gif)
|
.playable(playable)
|
||||||
.highlighted(highlight)
|
.highlighted(highlight)
|
||||||
.mediaData(data)
|
.mediaData(data)
|
||||||
.apply {
|
.apply {
|
||||||
|
@ -472,6 +475,10 @@ class MessageItemFactory @Inject constructor(
|
||||||
callback?.onImageMessageClicked(messageContent, data, view, emptyList())
|
callback?.onImageMessageClicked(messageContent, data, view, emptyList())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.apply {
|
||||||
|
if (playable && vectorPreferences.autoplayAnimatedImages()) {
|
||||||
|
mode(ImageContentRenderer.Mode.ANIMATED_THUMBNAIL)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ import im.vector.app.core.glide.GlideRequest
|
||||||
import im.vector.app.core.glide.GlideRequests
|
import im.vector.app.core.glide.GlideRequests
|
||||||
import im.vector.app.core.ui.model.Size
|
import im.vector.app.core.ui.model.Size
|
||||||
import im.vector.app.core.utils.DimensionConverter
|
import im.vector.app.core.utils.DimensionConverter
|
||||||
import im.vector.app.features.settings.VectorPreferences
|
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
|
import org.matrix.android.sdk.api.session.content.ContentUrlResolver
|
||||||
|
@ -65,7 +64,6 @@ class ImageContentRenderer @Inject constructor(
|
||||||
private val localFilesHelper: LocalFilesHelper,
|
private val localFilesHelper: LocalFilesHelper,
|
||||||
private val activeSessionHolder: ActiveSessionHolder,
|
private val activeSessionHolder: ActiveSessionHolder,
|
||||||
private val dimensionConverter: DimensionConverter,
|
private val dimensionConverter: DimensionConverter,
|
||||||
private val vectorPreferences: VectorPreferences
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
|
@ -85,6 +83,7 @@ class ImageContentRenderer @Inject constructor(
|
||||||
|
|
||||||
enum class Mode {
|
enum class Mode {
|
||||||
FULL_SIZE,
|
FULL_SIZE,
|
||||||
|
ANIMATED_THUMBNAIL,
|
||||||
THUMBNAIL,
|
THUMBNAIL,
|
||||||
STICKER
|
STICKER
|
||||||
}
|
}
|
||||||
|
@ -133,7 +132,7 @@ class ImageContentRenderer @Inject constructor(
|
||||||
|
|
||||||
createGlideRequest(data, mode, imageView, size)
|
createGlideRequest(data, mode, imageView, size)
|
||||||
.let {
|
.let {
|
||||||
if (vectorPreferences.autoplayAnimatedImages()) it
|
if (mode == Mode.ANIMATED_THUMBNAIL) it
|
||||||
else it.dontAnimate()
|
else it.dontAnimate()
|
||||||
}
|
}
|
||||||
.transform(cornerTransformation)
|
.transform(cornerTransformation)
|
||||||
|
@ -231,6 +230,7 @@ class ImageContentRenderer @Inject constructor(
|
||||||
val contentUrlResolver = activeSessionHolder.getActiveSession().contentUrlResolver()
|
val contentUrlResolver = activeSessionHolder.getActiveSession().contentUrlResolver()
|
||||||
val resolvedUrl = when (mode) {
|
val resolvedUrl = when (mode) {
|
||||||
Mode.FULL_SIZE,
|
Mode.FULL_SIZE,
|
||||||
|
Mode.ANIMATED_THUMBNAIL,
|
||||||
Mode.STICKER -> resolveUrl(data)
|
Mode.STICKER -> resolveUrl(data)
|
||||||
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, size.width, size.height, ContentUrlResolver.ThumbnailMethod.SCALE)
|
Mode.THUMBNAIL -> contentUrlResolver.resolveThumbnail(data.url, size.width, size.height, ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||||
}
|
}
|
||||||
|
@ -269,6 +269,7 @@ class ImageContentRenderer @Inject constructor(
|
||||||
finalHeight = height
|
finalHeight = height
|
||||||
finalWidth = width
|
finalWidth = width
|
||||||
}
|
}
|
||||||
|
Mode.ANIMATED_THUMBNAIL,
|
||||||
Mode.THUMBNAIL -> {
|
Mode.THUMBNAIL -> {
|
||||||
finalHeight = min(maxImageWidth * height / width, maxImageHeight)
|
finalHeight = min(maxImageWidth * height / width, maxImageHeight)
|
||||||
finalWidth = finalHeight * width / height
|
finalWidth = finalHeight * width / height
|
||||||
|
|
Loading…
Reference in New Issue