From 7aacaa349019ff42b8b05403d8beebe94c8f6dfc Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sun, 4 Oct 2026 13:36:43 +0600 Subject: [PATCH] Keep the paused download notification after the worker stops The paused notification reused the download worker's foreground notification id, so it was removed together with the foreground service when the worker finished. Closes #2791 --- .../tachiyomi/data/download/DownloadNotifier.kt | 16 ++++++++++------ .../tachiyomi/data/notification/Notifications.kt | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) 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