Sticker room summary preview: prefer sticker body like on desktop

Change-Id: If3dda509b1acddccf44b3e3267f098de3ee35611
This commit is contained in:
SpiritCroc 2023-04-15 10:37:43 +02:00
parent 9e0ec534d5
commit f16a7edf51
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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<MessageStickerContent>()?.body?.takeIf { it.isNotEmpty() }
?: stringProvider.getString(R.string.send_a_sticker), appendAuthor)
}
EventType.REACTION -> {
timelineEvent.root.getClearContent().toModel<ReactionContent>()?.relatesTo?.let {
@ -245,7 +247,7 @@ class DisplayableEventFormatter @Inject constructor(
} ?: span { }
}
EventType.STICKER -> {
stringProvider.getString(R.string.send_a_sticker)
event.getClearContent().toModel<MessageStickerContent>()?.body?.takeIf { it.isNotEmpty() } ?: stringProvider.getString(R.string.send_a_sticker)
}
EventType.REACTION -> {
event.getClearContent().toModel<ReactionContent>()?.relatesTo?.let {