From 09b7cabd99b5e17acbf3086aa519cad9e9baf580 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 2 Feb 2024 13:01:43 -0300 Subject: [PATCH] Use own notification ID for success notification and cancel observer notification when backup is finished. This is because when the success channel is disabled by the user, the observer notification could stick around and would never get removed. --- .../ui/notification/BackupNotificationManager.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt index 7466e9bd..8308fc2a 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt @@ -33,10 +33,11 @@ private const val CHANNEL_ID_SUCCESS = "NotificationBackupSuccess" private const val CHANNEL_ID_ERROR = "NotificationError" private const val CHANNEL_ID_RESTORE_ERROR = "NotificationRestoreError" private const val NOTIFICATION_ID_OBSERVER = 1 -private const val NOTIFICATION_ID_ERROR = 2 -private const val NOTIFICATION_ID_RESTORE_ERROR = 3 -private const val NOTIFICATION_ID_BACKGROUND = 4 -private const val NOTIFICATION_ID_NO_MAIN_KEY_ERROR = 5 +private const val NOTIFICATION_ID_SUCCESS = 2 +private const val NOTIFICATION_ID_ERROR = 3 +private const val NOTIFICATION_ID_RESTORE_ERROR = 4 +private const val NOTIFICATION_ID_BACKGROUND = 5 +private const val NOTIFICATION_ID_NO_MAIN_KEY_ERROR = 6 private val TAG = BackupNotificationManager::class.java.simpleName @@ -200,7 +201,8 @@ internal class BackupNotificationManager(private val context: Context) { setProgress(0, 0, false) priority = PRIORITY_LOW }.build() - nm.notify(NOTIFICATION_ID_OBSERVER, notification) + nm.cancel(NOTIFICATION_ID_OBSERVER) + nm.notify(NOTIFICATION_ID_SUCCESS, notification) // reset number of expected apps expectedOptOutApps = null expectedApps = null