diff --git a/vector/src/main/java/im/vector/riotredesign/features/notifications/NotificationDrawerManager.kt b/vector/src/main/java/im/vector/riotredesign/features/notifications/NotificationDrawerManager.kt index d673cc35fa..8c81570b7e 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/notifications/NotificationDrawerManager.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/notifications/NotificationDrawerManager.kt @@ -20,13 +20,13 @@ import android.content.Context import android.graphics.Bitmap import androidx.core.app.NotificationCompat import androidx.core.app.Person -import im.vector.matrix.android.api.Matrix import im.vector.matrix.android.api.session.content.ContentUrlResolver import im.vector.riotredesign.BuildConfig import im.vector.riotredesign.R import im.vector.riotredesign.core.di.ActiveSessionHolder import im.vector.riotredesign.core.utils.SecretStoringUtils import im.vector.riotredesign.features.settings.PreferencesManager +import me.gujun.android.span.span import timber.log.Timber import java.io.File import java.io.FileInputStream @@ -275,9 +275,32 @@ class NotificationDrawerManager @Inject constructor(private val context: Context } try { - val summaryLine = context.resources.getQuantityString( - R.plurals.notification_compat_summary_line_for_room, events.size, roomName, events.size) - summaryInboxStyle.addLine(summaryLine) + if (events.size == 1) { + val event = events[0] + if (roomEventGroupInfo.isDirect) { + val line = span { + span { + textStyle = "bold" + +String.format("%s: ", event.senderName) + } + +(event.description ?: "") + } + summaryInboxStyle.addLine(line) + } else { + val line = span { + span { + textStyle = "bold" + +String.format("%s: %s ", roomName, event.senderName) + } + +(event.description ?: "") + } + summaryInboxStyle.addLine(line) + } + } else { + val summaryLine = context.resources.getQuantityString( + R.plurals.notification_compat_summary_line_for_room, events.size, roomName, events.size) + summaryInboxStyle.addLine(summaryLine) + } } catch (e: Throwable) { //String not found or bad format Timber.v("%%%%%%%% REFRESH NOTIFICATION DRAWER failed to resolve string") @@ -343,6 +366,11 @@ class NotificationDrawerManager @Inject constructor(private val context: Context val sumTitle = context.resources.getQuantityString( R.plurals.notification_compat_summary_title, nbEvents, nbEvents) summaryInboxStyle.setBigContentTitle(sumTitle) + //TODO get latest event? + .setSummaryText( + context.resources + .getQuantityString(R.plurals.notification_unread_notified_messages, nbEvents, nbEvents)) + NotificationUtils.buildSummaryListNotification( context, summaryInboxStyle, diff --git a/vector/src/main/java/im/vector/riotredesign/features/notifications/NotificationUtils.kt b/vector/src/main/java/im/vector/riotredesign/features/notifications/NotificationUtils.kt index 365343346e..e91b4d7495 100755 --- a/vector/src/main/java/im/vector/riotredesign/features/notifications/NotificationUtils.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/notifications/NotificationUtils.kt @@ -606,7 +606,7 @@ object NotificationUtils { * Build the summary notification */ fun buildSummaryListNotification(context: Context, - style: NotificationCompat.Style, + style: NotificationCompat.InboxStyle, compatSummary: String, noisy: Boolean, lastMessageTimestamp: Long): Notification? {