mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-19 23:22:26 -07:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user