mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Improve the text for mentions and replies in notifications (#3328)
This commit is contained in:
committed by
GitHub
parent
eeeb8fc35c
commit
7859526280
+4
-6
@@ -104,11 +104,6 @@ class DefaultNotifiableEventResolver @Inject constructor(
|
||||
is NotificationContent.MessageLike.RoomMessage -> {
|
||||
val senderDisambiguatedDisplayName = getDisambiguatedDisplayName(content.senderId)
|
||||
val messageBody = descriptionFromMessageContent(content, senderDisambiguatedDisplayName)
|
||||
val notificationBody = if (hasMention) {
|
||||
stringProvider.getString(R.string.notification_mentioned_you_body, messageBody)
|
||||
} else {
|
||||
messageBody
|
||||
}
|
||||
buildNotifiableMessageEvent(
|
||||
sessionId = userId,
|
||||
senderId = content.senderId,
|
||||
@@ -117,12 +112,13 @@ class DefaultNotifiableEventResolver @Inject constructor(
|
||||
noisy = isNoisy,
|
||||
timestamp = this.timestamp,
|
||||
senderDisambiguatedDisplayName = senderDisambiguatedDisplayName,
|
||||
body = notificationBody,
|
||||
body = messageBody,
|
||||
imageUriString = fetchImageIfPresent(client)?.toString(),
|
||||
roomName = roomDisplayName,
|
||||
roomIsDm = isDm,
|
||||
roomAvatarPath = roomAvatarUrl,
|
||||
senderAvatarPath = senderAvatarUrl,
|
||||
hasMentionOrReply = hasMention,
|
||||
)
|
||||
}
|
||||
is NotificationContent.StateEvent.RoomMemberContent -> {
|
||||
@@ -340,6 +336,7 @@ internal fun buildNotifiableMessageEvent(
|
||||
isRedacted: Boolean = false,
|
||||
isUpdated: Boolean = false,
|
||||
type: String = EventType.MESSAGE,
|
||||
hasMentionOrReply: Boolean = false,
|
||||
) = NotifiableMessageEvent(
|
||||
sessionId = sessionId,
|
||||
senderId = senderId,
|
||||
@@ -363,4 +360,5 @@ internal fun buildNotifiableMessageEvent(
|
||||
isRedacted = isRedacted,
|
||||
isUpdated = isUpdated,
|
||||
type = type,
|
||||
hasMentionOrReply = hasMentionOrReply,
|
||||
)
|
||||
|
||||
+14
-2
@@ -397,10 +397,22 @@ class DefaultNotificationCreator @Inject constructor(
|
||||
val senderPerson = if (event.outGoingMessage) {
|
||||
null
|
||||
} else {
|
||||
val senderName = event.senderDisambiguatedDisplayName.orEmpty()
|
||||
// If the notification is for a mention or reply, we create a fake `Person` with a custom name and key
|
||||
val displayName = if (event.hasMentionOrReply) {
|
||||
stringProvider.getString(R.string.notification_sender_mention_reply, senderName)
|
||||
} else {
|
||||
senderName
|
||||
}
|
||||
val key = if (event.hasMentionOrReply) {
|
||||
"mention-or-reply:${event.eventId.value}"
|
||||
} else {
|
||||
event.senderId.value
|
||||
}
|
||||
Person.Builder()
|
||||
.setName(event.senderDisambiguatedDisplayName?.annotateForDebug(70))
|
||||
.setName(displayName.annotateForDebug(70))
|
||||
.setIcon(bitmapLoader.getUserIcon(event.senderAvatarPath, imageLoader))
|
||||
.setKey(event.senderId.value)
|
||||
.setKey(key)
|
||||
.build()
|
||||
}
|
||||
when {
|
||||
|
||||
+2
-1
@@ -52,7 +52,8 @@ data class NotifiableMessageEvent(
|
||||
val outGoingMessageFailed: Boolean = false,
|
||||
override val isRedacted: Boolean = false,
|
||||
override val isUpdated: Boolean = false,
|
||||
val type: String = EventType.MESSAGE
|
||||
val type: String = EventType.MESSAGE,
|
||||
val hasMentionOrReply: Boolean = false,
|
||||
) : NotifiableEvent {
|
||||
override val description: String = body ?: ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user