Skip to content

New SMS pop-up notification shows oldest unread message #3

Description

@wheatleychad

I've noticed a bug on the pop-up overlay when receiving a new text message.

If I have any older unread text messages, new SMS notification will show the content of the older one- not the new one that the notification is intended for.

Preliminary review of the code suggests this block is the culprit:

val text = try {
extras.getCharSequence(Notification.EXTRA_TEXT)?.toString()
?: extras.getString(Notification.EXTRA_TEXT) ?: ""
} catch (_: Exception) { "" }

Suggested fix:

val text = try {
val lines = extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES)
when {
!lines.isNullOrEmpty() -> lines.last().toString()
else -> extras.getCharSequence(Notification.EXTRA_TEXT)?.toString()
?: extras.getString(Notification.EXTRA_TEXT) ?: ""
}
} catch (_: Exception) { "" }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions