diff --git a/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationFactory.kt b/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationFactory.kt index 61bf94b..9c440c7 100644 --- a/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationFactory.kt +++ b/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationFactory.kt @@ -4,8 +4,11 @@ import android.app.Notification import android.app.PendingIntent import android.app.Person import android.content.Context +import android.content.Intent import android.os.Build import androidx.annotation.RequiresApi +import app.dapk.st.core.AppLogTag +import app.dapk.st.core.log import app.dapk.st.imageloader.IconLoader import app.dapk.st.matrix.sync.RoomEvent import app.dapk.st.matrix.sync.RoomOverview @@ -28,7 +31,7 @@ class NotificationFactory( } } - val summaryNotification = if (notifications.filterIsInstance().size > 1) { + val summaryNotification = if (notifications.filterIsInstance().isNotEmpty()) { createSummary(notifications) } else { null @@ -102,8 +105,9 @@ class NotificationFactory( val openRoomIntent = PendingIntent.getActivity( context, roomOverview.roomId.hashCode(), - MessengerActivity.newInstance(context, roomOverview.roomId), - PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE + MessengerActivity.newInstance(context, roomOverview.roomId) + .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK), + PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE ) return NotificationDelegate.Room( diff --git a/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationRenderer.kt b/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationRenderer.kt index 8ca8992..d380008 100644 --- a/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationRenderer.kt +++ b/features/notifications/src/main/kotlin/app/dapk/st/notifications/NotificationRenderer.kt @@ -2,7 +2,9 @@ package app.dapk.st.notifications import android.app.Notification import android.app.NotificationManager +import app.dapk.st.core.AppLogTag import app.dapk.st.core.extensions.ifNull +import app.dapk.st.core.log import app.dapk.st.matrix.common.RoomId import app.dapk.st.matrix.sync.RoomEvent import app.dapk.st.matrix.sync.RoomOverview @@ -20,6 +22,7 @@ class NotificationRenderer( val notifications = notificationFactory.createNotifications(result) notifications.summaryNotification.ifNull { + log(AppLogTag.NOTIFICATION, "cancelling summary") notificationManager.cancel(SUMMARY_NOTIFICATION_ID) }