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 d0044ba01..9a1fe4963 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 @@ -58,6 +58,7 @@ class DownloadNotifier( */ fun dismissProgress() { context.cancelNotification(Notifications.ID_DOWNLOAD_CHAPTER_PROGRESS) + context.cancelNotification(Notifications.ID_DOWNLOAD_CHAPTER_PAUSED) } /** @@ -68,6 +69,7 @@ class DownloadNotifier( fun onProgressChange(download: Download) { with(progressNotificationBuilder) { if (!isDownloading) { + context.cancelNotification(Notifications.ID_DOWNLOAD_CHAPTER_PAUSED) setSmallIcon(android.R.drawable.stat_sys_download) clearActions() // Open download manager when clicked @@ -117,13 +119,17 @@ class DownloadNotifier( * Show notification when download is paused. */ fun onPaused() { - with(progressNotificationBuilder) { + // The progress id belongs to the download worker's foreground service, which takes the + // notification with it when the worker stops + context.notify( + Notifications.ID_DOWNLOAD_CHAPTER_PAUSED, + Notifications.CHANNEL_DOWNLOADER_PROGRESS, + ) { setContentTitle(context.stringResource(MR.strings.chapter_paused)) setContentText(context.stringResource(MR.strings.download_notifier_download_paused)) setSmallIcon(R.drawable.ic_pause_24dp) - setProgress(0, 0, false) - setOngoing(false) - clearActions() + setLargeIcon(BitmapFactory.decodeResource(context.resources, R.mipmap.ic_launcher)) + setOnlyAlertOnce(true) // Open download manager when clicked setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context)) // Resume action @@ -138,8 +144,6 @@ class DownloadNotifier( context.stringResource(MR.strings.action_cancel_all), NotificationReceiver.clearDownloadsPendingBroadcast(context), ) - - show(Notifications.ID_DOWNLOAD_CHAPTER_PROGRESS) } // Reset initial values diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt index 96a0d52b9..3bc4132f5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt @@ -37,6 +37,7 @@ object Notifications { private const val GROUP_DOWNLOADER = "group_downloader" const val CHANNEL_DOWNLOADER_PROGRESS = "downloader_progress_channel" const val ID_DOWNLOAD_CHAPTER_PROGRESS = -201 + const val ID_DOWNLOAD_CHAPTER_PAUSED = -203 const val CHANNEL_DOWNLOADER_ERROR = "downloader_error_channel" const val ID_DOWNLOAD_CHAPTER_ERROR = -202