Revert "Avoid duplicated MessagingStyle notification text"

This reverts commit 5c8cb814f6.
This commit is contained in:
ajp_anton
2026-07-27 01:25:20 +00:00
parent 5c8cb814f6
commit 4d84ff98c7
@@ -21,25 +21,14 @@ data class NotificationSnapshot(
object NotificationContents {
fun extract(notification: Notification): String? {
val extras = notification.extras ?: Bundle.EMPTY
messagingContents(extras)?.let { return it }
val parts = linkedSetOf<String>()
val extras = notification.extras ?: Bundle.EMPTY
extras.getCharSequence(Notification.EXTRA_TITLE)?.addTo(parts)
extras.getCharSequence(Notification.EXTRA_TEXT)?.addTo(parts)
extras.getCharSequence(Notification.EXTRA_BIG_TEXT)?.addTo(parts)
extras.getCharSequence(Notification.EXTRA_SUB_TEXT)?.addTo(parts)
extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT)?.addTo(parts)
extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES)?.forEach { it?.addTo(parts) }
return parts.takeIf { it.isNotEmpty() }?.joinToString("")
}
/**
* MessagingStyle also fills generic title and text fields. Those fields commonly duplicate
* the newest structured message, so structured messages are the canonical representation.
*/
private fun messagingContents(extras: Bundle): String? {
val parts = linkedSetOf<String>()
Notification.MessagingStyle.Message.getMessagesFromBundleArray(
extras.getParcelableArray(Notification.EXTRA_MESSAGES, Bundle::class.java),
).forEach { message ->