Fix '0 tasks' notification

pull/848/head^2
Alex Baker 6 years ago
parent 66c7cd7853
commit 4c7440afe4

@ -128,7 +128,7 @@ public class NotificationManager {
createNotifications(notifications, false, false, false, true); createNotifications(notifications, false, false, false, true);
} else { } else {
createNotifications(notifications, false, false, false, false); createNotifications(notifications, false, false, false, false);
notificationManagerCompat.cancel(SUMMARY_NOTIFICATION_ID); cancelSummaryNotification();
} }
} }
@ -138,12 +138,12 @@ public class NotificationManager {
notificationDao.insertAll(newNotifications); notificationDao.insertAll(newNotifications);
int totalCount = existingNotifications.size() + newNotifications.size(); int totalCount = existingNotifications.size() + newNotifications.size();
if (totalCount == 0) { if (totalCount == 0) {
notificationManagerCompat.cancel(SUMMARY_NOTIFICATION_ID); cancelSummaryNotification();
} else if (totalCount == 1) { } else if (totalCount == 1) {
List<Notification> notifications = List<Notification> notifications =
newArrayList(concat(existingNotifications, newNotifications)); newArrayList(concat(existingNotifications, newNotifications));
createNotifications(notifications, alert, nonstop, fiveTimes, false); createNotifications(notifications, alert, nonstop, fiveTimes, false);
notificationManagerCompat.cancel(SUMMARY_NOTIFICATION_ID); cancelSummaryNotification();
} else if (preferences.bundleNotifications()) { } else if (preferences.bundleNotifications()) {
updateSummary(false, false, false, Collections.emptyList()); updateSummary(false, false, false, Collections.emptyList());
@ -235,6 +235,10 @@ public class NotificationManager {
boolean notify, boolean nonStop, boolean fiveTimes, List<Notification> newNotifications) { boolean notify, boolean nonStop, boolean fiveTimes, List<Notification> newNotifications) {
List<Task> tasks = taskDao.activeNotifications(); List<Task> tasks = taskDao.activeNotifications();
int taskCount = tasks.size(); int taskCount = tasks.size();
if (taskCount == 0) {
cancelSummaryNotification();
return;
}
ArrayList<Long> taskIds = newArrayList(transform(tasks, Task::getId)); ArrayList<Long> taskIds = newArrayList(transform(tasks, Task::getId));
Filter filter = Filter filter =
new Filter( new Filter(
@ -429,4 +433,8 @@ public class NotificationManager {
snoozePendingIntent) snoozePendingIntent)
.extend(wearableExtender); .extend(wearableExtender);
} }
private void cancelSummaryNotification() {
notificationManagerCompat.cancel(SUMMARY_NOTIFICATION_ID);
}
} }

Loading…
Cancel
Save