From c41661ece84a0c99827fc0e9dc316e9c7252f1a0 Mon Sep 17 00:00:00 2001 From: Valere Date: Fri, 21 Feb 2020 19:03:16 +0100 Subject: [PATCH 1/2] Fixes #712 --- .../notifications/NotifiableEventResolver.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotifiableEventResolver.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotifiableEventResolver.kt index 17339956e5..b810e13ea1 100644 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotifiableEventResolver.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotifiableEventResolver.kt @@ -31,6 +31,7 @@ import im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResu import im.vector.riotx.BuildConfig import im.vector.riotx.R import im.vector.riotx.core.resources.StringProvider +import im.vector.riotx.features.home.room.detail.timeline.format.DisplayableEventFormatter import im.vector.riotx.features.home.room.detail.timeline.format.NoticeEventFormatter import timber.log.Timber import java.util.UUID @@ -43,7 +44,8 @@ import javax.inject.Inject * this pattern allow decoupling between the object responsible of displaying notifications and the matrix sdk. */ class NotifiableEventResolver @Inject constructor(private val stringProvider: StringProvider, - private val noticeEventFormatter: NoticeEventFormatter) { + private val noticeEventFormatter: NoticeEventFormatter, + private val displayableEventFormatter: DisplayableEventFormatter) { // private val eventDisplay = RiotEventDisplay(context) @@ -90,9 +92,7 @@ class NotifiableEventResolver @Inject constructor(private val stringProvider: St if (room == null) { Timber.e("## Unable to resolve room for eventId [$event]") // Ok room is not known in store, but we can still display something - val body = - event.getLastMessageBody() - ?: stringProvider.getString(R.string.notification_unknown_new_event) + val body = displayableEventFormatter.format(event, false) val roomName = stringProvider.getString(R.string.notification_unknown_room_name) val senderDisplayName = event.getDisambiguatedDisplayName() @@ -103,7 +103,7 @@ class NotifiableEventResolver @Inject constructor(private val stringProvider: St noisy = false, // will be updated senderName = senderDisplayName, senderId = event.root.senderId, - body = body, + body = body.toString(), roomId = event.root.roomId!!, roomName = roomName) @@ -125,8 +125,7 @@ class NotifiableEventResolver @Inject constructor(private val stringProvider: St } } - val body = event.getLastMessageBody() - ?: stringProvider.getString(R.string.notification_unknown_new_event) + val body = displayableEventFormatter.format(event, false).toString() val roomName = room.roomSummary()?.displayName ?: "" val senderDisplayName = event.getDisambiguatedDisplayName() From 3e587af163e486306d491dd6026ce94b1ee89bc6 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 24 Feb 2020 14:07:15 +0100 Subject: [PATCH 2/2] klint --- .../riotx/features/notifications/NotifiableEventResolver.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/NotifiableEventResolver.kt b/vector/src/main/java/im/vector/riotx/features/notifications/NotifiableEventResolver.kt index b810e13ea1..6f881f2b8e 100644 --- a/vector/src/main/java/im/vector/riotx/features/notifications/NotifiableEventResolver.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/NotifiableEventResolver.kt @@ -26,7 +26,6 @@ import im.vector.matrix.android.api.session.room.model.Membership import im.vector.matrix.android.api.session.room.model.RoomMemberContent import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.matrix.android.api.session.room.timeline.getEditedEventId -import im.vector.matrix.android.api.session.room.timeline.getLastMessageBody import im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResult import im.vector.riotx.BuildConfig import im.vector.riotx.R