Add replied to you in notifications.

This commit is contained in:
Michelle Tang
2026-09-09 16:37:43 -04:00
committed by Cody Henthorne
parent 04616e5caa
commit 62f24ce25f
4 changed files with 11 additions and 2 deletions
@@ -112,6 +112,10 @@ public final class ThreadBodyUtil {
return format(EmojiStrings.POLL, context.getString(R.string.Poll__poll_end, record.getFromRecipient().getDisplayName(context), record.getMessageExtras().pollTerminate.question), null).body;
}
public static CharSequence getFormattedBodyForReply(@NonNull Context context, @NonNull CharSequence body) {
return context.getString(R.string.MessageNotifier_replied_to_you, body);
}
private static @NonNull String getGiftSummary(@NonNull Context context, @NonNull MessageRecord messageRecord) {
if (messageRecord.isOutgoing()) {
return context.getString(R.string.ThreadRecord__you_donated_for_s, messageRecord.getToRecipient().getShortDisplayName(context));
@@ -210,7 +210,7 @@ object NotificationFactory {
private fun shouldAlert(conversation: NotificationConversation, lastNotificationTimestamp: Long, alertOverride: Boolean): Boolean {
val throttle: Duration = when {
!AppDependencies.incomingMessageObserver.decryptionDrained -> STILL_DECRYPTING_THROTTLE
conversation.recipient.isGroup && (conversation.mostRecentNotification as? MessageNotification)?.hasSelfMention == false -> GROUP_THROTTLE
conversation.recipient.isGroup && (conversation.mostRecentNotification as? MessageNotification)?.hasSelfMention != true && (conversation.mostRecentNotification as? MessageNotification)?.isReplyToSelf != true -> GROUP_THROTTLE
else -> INDIVIDUAL_THROTTLE
}
val canAlertBasedOnTime: Boolean = lastNotificationTimestamp < System.currentTimeMillis() - throttle.inWholeMilliseconds || lastNotificationTimestamp > System.currentTimeMillis()
@@ -236,7 +236,8 @@ class MessageNotification(threadRecipient: Recipient, record: MessageRecord, val
override val timestamp: Long = record.timestamp
override val authorRecipient: Recipient = record.fromRecipient.resolve()
override val isNewNotification: Boolean = notifiedTimestamp == 0L && !record.isEditMessage
val hasSelfMention = record.hasSelfMention() || (record is MmsMessageRecord && record.quote?.author == Recipient.self().id)
val isReplyToSelf = record is MmsMessageRecord && threadRecipient.isGroup && record.quote?.author == Recipient.self().id
val hasSelfMention = record.hasSelfMention()
private var thumbnailInfo: ThumbnailInfo = NotificationThumbnails.getWithoutModifying(this)
@@ -264,6 +265,8 @@ class MessageNotification(threadRecipient: Recipient, record: MessageRecord, val
ThreadBodyUtil.getFormattedBodyForPollNotification(context, record as MmsMessageRecord)
} else if (record.hasPollTerminate()) {
ThreadBodyUtil.getFormattedBodyForPollEndNotification(context, record as MmsMessageRecord)
} else if (isReplyToSelf) {
ThreadBodyUtil.getFormattedBodyForReply(context, getBodyWithMentionsAndStyles(context, record))
} else {
getBodyWithMentionsAndStyles(context, record)
}
+2
View File
@@ -3307,6 +3307,8 @@
<!-- MessageNotifier -->
<!-- Text shown in a system notification that is used to summarize your notification. The first placeholder is a pluralized string that describes how many messages (e.g. "3 messages"), and the second placeholder is a pluralized string that describes the number of unique chats those message appear in (e.g. "2 chats"). -->
<string name="MessageNotifier_s_in_s">%1$s in %2$s</string>
<!-- Subtext shown in a group chat notification when the most recent message is a direct reply to a message you sent. -->
<string name="MessageNotifier_replied_to_you">Replied to you: %1$s</string>
<!-- Text shown in a system notification that is used to summary how many messages you received. -->
<plurals name="MessageNotifier_d_messages">
<item quantity="one">%1$d message</item>