Automatically dismiss summary notification

pull/367/merge
Alinson S. Xavier 8 years ago
parent 2a4a7c975f
commit 0077d35ff9

@ -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)

Loading…
Cancel
Save