diff --git a/app/src/main/java/com/crossbowffs/nekosms/app/BlockedMessagesFragment.java b/app/src/main/java/com/crossbowffs/nekosms/app/BlockedMessagesFragment.java index ac6de9b..5113d80 100644 --- a/app/src/main/java/com/crossbowffs/nekosms/app/BlockedMessagesFragment.java +++ b/app/src/main/java/com/crossbowffs/nekosms/app/BlockedMessagesFragment.java @@ -142,6 +142,7 @@ private void clearAllMessages() { Context context = getContext(); if (context == null) return; + NotificationHelper.cancelAllNotifications(context); BlockedSmsLoader.get().deleteAll(context); showSnackbar(R.string.cleared_blocked_messages); } @@ -180,7 +181,7 @@ public void showMessageDetailsDialog(final SmsMessageData messageData) { if (context == null) return; // Dismiss notification if present - NotificationHelper.removeNotification(context, messageData.getId()); + NotificationHelper.cancelNotification(context, messageData.getId()); final long smsId = messageData.getId(); String sender = messageData.getSender(); @@ -224,7 +225,7 @@ private void restoreSms(long smsId) { if (context == null) return; // We've obviously seen the message, so remove the notification - NotificationHelper.removeNotification(context, smsId); + NotificationHelper.cancelNotification(context, smsId); // Load message content (so we can undo) final SmsMessageData messageData = BlockedSmsLoader.get().query(context, smsId); @@ -272,7 +273,7 @@ private void deleteSms(long smsId) { if (context == null) return; // We've obviously seen the message, so remove the notification - NotificationHelper.removeNotification(context, smsId); + NotificationHelper.cancelNotification(context, smsId); // Load message content (for undo), then delete it final SmsMessageData messageData = BlockedSmsLoader.get().queryAndDelete(context, smsId); diff --git a/app/src/main/java/com/crossbowffs/nekosms/app/BlockedSmsReceiver.java b/app/src/main/java/com/crossbowffs/nekosms/app/BlockedSmsReceiver.java index 643b594..5cdded5 100644 --- a/app/src/main/java/com/crossbowffs/nekosms/app/BlockedSmsReceiver.java +++ b/app/src/main/java/com/crossbowffs/nekosms/app/BlockedSmsReceiver.java @@ -25,7 +25,7 @@ private void onReceiveSms(Context context, Intent intent) { private void onDeleteSms(Context context, Intent intent) { Uri messageUri = intent.getData(); - NotificationHelper.removeNotification(context, messageUri); + NotificationHelper.cancelNotification(context, messageUri); boolean deleted = BlockedSmsLoader.get().delete(context, messageUri); if (!deleted) { @@ -38,7 +38,7 @@ private void onDeleteSms(Context context, Intent intent) { private void onRestoreSms(Context context, Intent intent) { Uri messageUri = intent.getData(); - NotificationHelper.removeNotification(context, messageUri); + NotificationHelper.cancelNotification(context, messageUri); // Always mark message as seen, even though we're deleting it, // so even if we don't get to delete it, the seen flag still gets set. diff --git a/app/src/main/java/com/crossbowffs/nekosms/app/NotificationHelper.java b/app/src/main/java/com/crossbowffs/nekosms/app/NotificationHelper.java index b6b80ca..30d40ee 100644 --- a/app/src/main/java/com/crossbowffs/nekosms/app/NotificationHelper.java +++ b/app/src/main/java/com/crossbowffs/nekosms/app/NotificationHelper.java @@ -95,14 +95,18 @@ private static Notification buildNotificationSingle(Context context, SmsMessageD .build(); } - public static void removeNotification(Context context, Uri messageUri) { + public static void cancelNotification(Context context, long messageId) { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); - notificationManager.cancel(uriToNotificationId(messageUri)); + notificationManager.cancel((int)messageId); + } + + public static void cancelNotification(Context context, Uri messageUri) { + cancelNotification(context, uriToNotificationId(messageUri)); } - public static void removeNotification(Context context, long messageId) { + public static void cancelAllNotifications(Context context) { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); - notificationManager.cancel((int)messageId); + notificationManager.cancelAll(); } public static void displayNotification(Context context, Uri messageUri) {