mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 09:38:52 -06:00
Automatically dismiss summary notification
This commit is contained in:
@@ -44,8 +44,15 @@ class AndroidNotificationTray
|
|||||||
private val ringtoneManager: RingtoneManager
|
private val ringtoneManager: RingtoneManager
|
||||||
) : NotificationTray.SystemTray {
|
) : NotificationTray.SystemTray {
|
||||||
|
|
||||||
|
private var active = HashSet<Int>()
|
||||||
|
|
||||||
override fun removeNotification(id: Int) {
|
override fun removeNotification(id: Int) {
|
||||||
NotificationManagerCompat.from(context).cancel(id)
|
val manager = NotificationManagerCompat.from(context)
|
||||||
|
manager.cancel(id)
|
||||||
|
active.remove(id)
|
||||||
|
|
||||||
|
// Clear the group summary notification
|
||||||
|
if(active.isEmpty()) manager.cancelAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showNotification(habit: Habit,
|
override fun showNotification(habit: Habit,
|
||||||
@@ -58,6 +65,7 @@ class AndroidNotificationTray
|
|||||||
notificationManager.notify(Int.MAX_VALUE, summary)
|
notificationManager.notify(Int.MAX_VALUE, summary)
|
||||||
val notification = buildNotification(habit, reminderTime, timestamp)
|
val notification = buildNotification(habit, reminderTime, timestamp)
|
||||||
notificationManager.notify(notificationId, notification)
|
notificationManager.notify(notificationId, notification)
|
||||||
|
active.add(notificationId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -79,8 +87,7 @@ class AndroidNotificationTray
|
|||||||
val removeRepetitionAction = Action(
|
val removeRepetitionAction = Action(
|
||||||
R.drawable.ic_action_cancel,
|
R.drawable.ic_action_cancel,
|
||||||
context.getString(R.string.no),
|
context.getString(R.string.no),
|
||||||
pendingIntents.removeRepetition(habit)
|
pendingIntents.removeRepetition(habit))
|
||||||
)
|
|
||||||
|
|
||||||
val wearableBg = decodeResource(context.resources, R.drawable.stripe)
|
val wearableBg = decodeResource(context.resources, R.drawable.stripe)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user