From f16a7edf51758f8fd29d34637726112813e282f4 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sat, 15 Apr 2023 10:37:43 +0200 Subject: [PATCH] Sticker room summary preview: prefer sticker body like on desktop Change-Id: If3dda509b1acddccf44b3e3267f098de3ee35611 --- FEATURES.md | 1 + .../detail/timeline/format/DisplayableEventFormatter.kt | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index 61168608f6..448f349f30 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -35,6 +35,7 @@ Here you can find some extra features and changes compared to Element Android (w - Send freeform reactions - Render media captions ([MSC2530](https://github.com/matrix-org/matrix-spec-proposals/pull/2530)) - Escape @room in the reply fallback to avoid unintentional room pings when replying +- Render sticker body in room/thread preview - Branding (name, app icon, links) - Show a toast instead of a snackbar after copying text, in order to not block the input area right after copying diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt index bc6380ad30..f4e9489294 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt @@ -40,6 +40,7 @@ import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent import org.matrix.android.sdk.api.session.room.model.message.MessageContent import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent +import org.matrix.android.sdk.api.session.room.model.message.MessageStickerContent import org.matrix.android.sdk.api.session.room.model.message.MessageTextContent import org.matrix.android.sdk.api.session.room.model.message.MessageType import org.matrix.android.sdk.api.session.room.model.message.MessageWithAttachmentContent @@ -130,7 +131,8 @@ class DisplayableEventFormatter @Inject constructor( } ?: span { } } EventType.STICKER -> { - simpleFormat(senderName, stringProvider.getString(R.string.send_a_sticker), appendAuthor) + simpleFormat(senderName, timelineEvent.root.getClearContent().toModel()?.body?.takeIf { it.isNotEmpty() } + ?: stringProvider.getString(R.string.send_a_sticker), appendAuthor) } EventType.REACTION -> { timelineEvent.root.getClearContent().toModel()?.relatesTo?.let { @@ -245,7 +247,7 @@ class DisplayableEventFormatter @Inject constructor( } ?: span { } } EventType.STICKER -> { - stringProvider.getString(R.string.send_a_sticker) + event.getClearContent().toModel()?.body?.takeIf { it.isNotEmpty() } ?: stringProvider.getString(R.string.send_a_sticker) } EventType.REACTION -> { event.getClearContent().toModel()?.relatesTo?.let {