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