From f82a7a68f42add8970e43916cf4d8e28e8847c33 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sun, 4 Oct 2026 13:04:24 +0600 Subject: [PATCH] Build download error notifications fresh each time The warning and error notifications shared one builder for the life of the app, so an error kept the first notification's timestamp and the previous warning's expanded text, auto cancel and timeout. Closes #3341 --- .../data/download/DownloadNotifier.kt | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 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 93a460dc9..d0044ba01 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 @@ -38,12 +38,6 @@ class DownloadNotifier( } } - private val errorNotificationBuilder by lazy { - context.notificationBuilder(Notifications.CHANNEL_DOWNLOADER_ERROR) { - setAutoCancel(false) - } - } - /** * Status of download. Used for correct notification icon. */ @@ -171,12 +165,14 @@ class DownloadNotifier( * Only works on Android 8+. */ fun onWarning(reason: String, timeout: Long? = null, contentIntent: PendingIntent? = null, mangaId: Long? = null) { - with(errorNotificationBuilder) { + context.notify( + Notifications.ID_DOWNLOAD_CHAPTER_ERROR, + Notifications.CHANNEL_DOWNLOADER_ERROR, + ) { setContentTitle(context.stringResource(MR.strings.download_notifier_downloader_title)) setStyle(NotificationCompat.BigTextStyle().bigText(reason)) setSmallIcon(R.drawable.ic_warning_white_24dp) setAutoCancel(true) - clearActions() setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context)) if (mangaId != null) { addAction( @@ -185,11 +181,8 @@ class DownloadNotifier( NotificationReceiver.openEntryPendingActivity(context, mangaId), ) } - setProgress(0, 0, false) timeout?.let { setTimeoutAfter(it) } contentIntent?.let { setContentIntent(it) } - - show(Notifications.ID_DOWNLOAD_CHAPTER_ERROR) } // Reset download information @@ -206,13 +199,15 @@ class DownloadNotifier( */ fun onError(error: String? = null, chapter: String? = null, mangaTitle: String? = null, mangaId: Long? = null) { // Create notification - with(errorNotificationBuilder) { + context.notify( + Notifications.ID_DOWNLOAD_CHAPTER_ERROR, + Notifications.CHANNEL_DOWNLOADER_ERROR, + ) { setContentTitle( mangaTitle?.plus(": $chapter") ?: context.stringResource(MR.strings.download_notifier_downloader_title), ) setContentText(error ?: context.stringResource(MR.strings.download_notifier_unknown_error)) setSmallIcon(R.drawable.ic_warning_white_24dp) - clearActions() setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context)) if (mangaId != null) { addAction( @@ -221,9 +216,6 @@ class DownloadNotifier( NotificationReceiver.openEntryPendingActivity(context, mangaId), ) } - setProgress(0, 0, false) - - show(Notifications.ID_DOWNLOAD_CHAPTER_ERROR) } // Reset download information