Merge pull request #6982 from p1gp1g/fix/autoplay-sticker

Fix autoplayed animated sticker
This commit is contained in:
Benoit Marty 2022-09-01 14:43:23 +02:00 committed by GitHub
commit ed13177376
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 4 deletions

2
changelog.d/6982.bugfix Normal file
View file

@ -0,0 +1,2 @@
Fix autoplayed animated stickers
Increase sticker size

View file

@ -34,9 +34,11 @@ import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
import org.matrix.android.sdk.api.session.events.model.getMsgType import org.matrix.android.sdk.api.session.events.model.getMsgType
import org.matrix.android.sdk.api.session.events.model.isAttachmentMessage import org.matrix.android.sdk.api.session.events.model.isAttachmentMessage
import org.matrix.android.sdk.api.session.events.model.isSticker
import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.ReferencesAggregatedContent import org.matrix.android.sdk.api.session.room.model.ReferencesAggregatedContent
import org.matrix.android.sdk.api.session.room.model.RoomSummary import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.model.message.MessageType
import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationRequestContent import org.matrix.android.sdk.api.session.room.model.message.MessageVerificationRequestContent
import org.matrix.android.sdk.api.session.room.send.SendState import org.matrix.android.sdk.api.session.room.send.SendState
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
@ -122,7 +124,7 @@ class MessageInformationDataFactory @Inject constructor(
isLastFromThisSender = isLastFromThisSender, isLastFromThisSender = isLastFromThisSender,
e2eDecoration = e2eDecoration, e2eDecoration = e2eDecoration,
sendStateDecoration = sendStateDecoration, sendStateDecoration = sendStateDecoration,
messageType = event.root.getMsgType() messageType = if (event.root.isSticker()) { MessageType.MSGTYPE_STICKER_LOCAL } else { event.root.getMsgType() }
) )
} }

View file

@ -82,7 +82,7 @@ abstract class MessageImageVideoItem : AbsMessageItem<MessageImageVideoItem.Hold
holder.mediaContentView.onClick(attributes.itemClickListener) holder.mediaContentView.onClick(attributes.itemClickListener)
holder.mediaContentView.setOnLongClickListener(attributes.itemLongClickListener) holder.mediaContentView.setOnLongClickListener(attributes.itemLongClickListener)
val isImageMessage = attributes.informationData.messageType == MessageType.MSGTYPE_IMAGE val isImageMessage = attributes.informationData.messageType in listOf(MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_STICKER_LOCAL)
val autoplayAnimatedImages = attributes.autoplayAnimatedImages val autoplayAnimatedImages = attributes.autoplayAnimatedImages
holder.playContentView.visibility = if (playable && isImageMessage && autoplayAnimatedImages) { holder.playContentView.visibility = if (playable && isImageMessage && autoplayAnimatedImages) {

View file

@ -68,6 +68,7 @@ class TimelineMessageLayoutFactory @Inject constructor(
private val MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE = setOf( private val MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE = setOf(
MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_IMAGE,
MessageType.MSGTYPE_VIDEO, MessageType.MSGTYPE_VIDEO,
MessageType.MSGTYPE_STICKER_LOCAL,
MessageType.MSGTYPE_BEACON_INFO, MessageType.MSGTYPE_BEACON_INFO,
MessageType.MSGTYPE_LOCATION, MessageType.MSGTYPE_LOCATION,
MessageType.MSGTYPE_BEACON_LOCATION_DATA, MessageType.MSGTYPE_BEACON_LOCATION_DATA,

View file

@ -275,8 +275,7 @@ class ImageContentRenderer @Inject constructor(
} }
Mode.STICKER -> { Mode.STICKER -> {
// limit on width // limit on width
val maxWidthDp = min(dimensionConverter.dpToPx(120), maxImageWidth / 2) finalWidth = min(dimensionConverter.dpToPx(width), maxImageWidth * 3 / 4)
finalWidth = min(dimensionConverter.dpToPx(width), maxWidthDp)
finalHeight = finalWidth * height / width finalHeight = finalWidth * height / width
} }
} }