From cf7ec6aa7628b23ddbb22938f1b587e7bd613d74 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 21 Jan 2021 18:21:21 -0500 Subject: [PATCH] Use proper method to clear notification actions --- .../kanade/tachiyomi/data/backup/BackupNotifier.kt | 12 +++--------- .../tachiyomi/data/download/DownloadNotifier.kt | 9 --------- .../kanade/tachiyomi/ui/reader/SaveImageNotifier.kt | 4 +--- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt index 252f3c798..8a0d06e61 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupNotifier.kt @@ -68,9 +68,7 @@ class BackupNotifier(private val context: Context) { setContentText(unifile.filePath ?: unifile.name) // Clear old actions if they exist - if (mActions.isNotEmpty()) { - mActions.clear() - } + clearActions() addAction( R.drawable.ic_share_24dp, @@ -94,9 +92,7 @@ class BackupNotifier(private val context: Context) { setOnlyAlertOnce(true) // Clear old actions if they exist - if (mActions.isNotEmpty()) { - mActions.clear() - } + clearActions() addAction( R.drawable.ic_close_24dp, @@ -137,9 +133,7 @@ class BackupNotifier(private val context: Context) { setContentText(context.resources.getQuantityString(R.plurals.restore_completed_message, errorCount, timeString, errorCount)) // Clear old actions if they exist - if (mActions.isNotEmpty()) { - mActions.clear() - } + clearActions() if (errorCount > 0 && !path.isNullOrEmpty() && !file.isNullOrEmpty()) { val destFile = File(path, file) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt index c4570846c..c2887a2e0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadNotifier.kt @@ -66,15 +66,6 @@ internal class DownloadNotifier(private val context: Context) { context.notificationManager.notify(id, build()) } - /** - * Clear old actions if they exist. - */ - private fun NotificationCompat.Builder.clearActions() { - if (mActions.isNotEmpty()) { - mActions.clear() - } - } - /** * Dismiss the downloader's notification. Downloader error notifications use a different id, so * those can only be dismissed by the user. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt index 2b9fe851d..2814b412d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt @@ -60,9 +60,7 @@ class SaveImageNotifier(private val context: Context) { setAutoCancel(true) // Clear old actions if they exist - if (mActions.isNotEmpty()) { - mActions.clear() - } + clearActions() setContentIntent(NotificationHandler.openImagePendingActivity(context, file)) // Share action