Group every reminder on its own, silent re-posts included (#100)

This commit is contained in:
makiolaj committed 2026-11-18 20:59:32 +01:00
1 parent d3c382dd63
commit 235d16a6f0
1 file changed
+6 -4
@@ -147,8 +147,8 @@ class TaskNotifier @Inject constructor(
.setWhen(shownAt)
.setAutoCancel(!persistent)
.setSilent(!alert)
// A group of its own, so a silent re-post doesn't land in NotificationCompat's shared "silent" group.
.apply { if (persistent) setGroup("$PERSISTENT_GROUP_PREFIX${task.taskId}") }
// Grouped alike either way: silent without a group lands in NotificationCompat's own "silent" group.
.setGroup(groupOf(task.taskId))
.setDeleteIntent(if (persistent) dismissedIntent(task.taskId, occurrence) else null)
.setContentIntent(tapIntent)
.addExtras(
@@ -239,7 +239,7 @@ class TaskNotifier @Inject constructor(
val notification = Notification.Builder.recoverBuilder(context, posted.notification)
.setAutoCancel(!persistent)
.setOnlyAlertOnce(true)
.setGroup(if (persistent) "$PERSISTENT_GROUP_PREFIX${posted.taskId}" else null)
.setGroup(groupOf(posted.taskId))
.setDeleteIntent(if (persistent) dismissedIntent(posted.taskId, occurrence) else null)
.build()
manager.notify(posted.taskId.toString(), NOTIFICATION_ID, notification)
@@ -317,6 +317,8 @@ class TaskNotifier @Inject constructor(
}
}
private fun groupOf(taskId: Long) = "$REMINDER_GROUP_PREFIX$taskId"
private fun dismissedIntent(taskId: Long, occurrence: Long): PendingIntent =
broadcast(taskId, ReminderActionReceiver.dismissedIntent(context, taskId, occurrence, currentStore))
@@ -404,7 +406,7 @@ class TaskNotifier @Inject constructor(
private const val KEY_LEGACY_IMPORTANCE = "legacy_importance"
private const val EXTRA_DUE = "de.jeanlucmakiola.agendula.extra.DUE"
private const val NO_DUE = Long.MIN_VALUE
private const val PERSISTENT_GROUP_PREFIX = "reminder_"
private const val REMINDER_GROUP_PREFIX = "reminder_"
/**
* Whether a reminder can sound anywhere: the group is not blocked and at