ImageContentRenderer: Enable image animation if enabled in preferences

This patch removes dontAnimate() in the createGlideRequest() builder
conditionally depending on the user's animated image autoplay
preferences.

Resolves #1160, #5094

Signed-off-by: networkException <git@nwex.de>
This commit is contained in:
networkException 2022-05-26 17:28:42 +02:00
parent 9b60ee70c5
commit 9d0fe46723
No known key found for this signature in database
GPG Key ID: C1F2658DC370C8FC
1 changed files with 7 additions and 2 deletions

View File

@ -41,6 +41,7 @@ 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
@ -67,7 +68,8 @@ private const val URL_PREVIEW_IMAGE_MIN_FULL_HEIGHT_PX = 315
class ImageContentRenderer @Inject constructor(private val localFilesHelper: LocalFilesHelper, class ImageContentRenderer @Inject constructor(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
data class Data( data class Data(
@ -133,7 +135,10 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
imageView.contentDescription = data.filename imageView.contentDescription = data.filename
createGlideRequest(data, mode, imageView, size) createGlideRequest(data, mode, imageView, size)
.dontAnimate() .let {
if (vectorPreferences.autoplayAnimatedImages()) it
else it.dontAnimate()
}
.transform(cornerTransformation) .transform(cornerTransformation)
// .thumbnail(0.3f) // .thumbnail(0.3f)
.into(imageView) .into(imageView)