fix(notifications): paused notifications not showing (#1468)
* fix(notifications): paused notifications not showing * docs(notifications): clarify notification dismissal and add comment for paused notifications * refactor --------- Co-authored-by: Cuong-Tran <16017808+cuong-tran@users.noreply.github.com>
This commit is contained in:
parent
b68444f3cb
commit
dd3b19fa89
3 changed files with 22 additions and 3 deletions
|
|
@ -61,11 +61,21 @@ internal class DownloadNotifier(private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dismiss the downloader's notification. Downloader error notifications use a different id, so
|
* Dismiss the downloader's progress and paused notifications. Error notifications use a
|
||||||
* those can only be dismissed by the user.
|
* different id, so those can only be dismissed by the user.
|
||||||
*/
|
*/
|
||||||
fun dismissProgress() {
|
fun dismissProgress() {
|
||||||
context.cancelNotification(Notifications.ID_DOWNLOAD_CHAPTER_PROGRESS)
|
context.cancelNotification(Notifications.ID_DOWNLOAD_CHAPTER_PROGRESS)
|
||||||
|
// KMK -->
|
||||||
|
context.cancelNotification(Notifications.ID_DOWNLOAD_CHAPTER_PAUSED)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dismiss the pause notification. Called when resuming downloads.
|
||||||
|
*/
|
||||||
|
fun dismissPaused() {
|
||||||
|
context.cancelNotification(Notifications.ID_DOWNLOAD_CHAPTER_PAUSED)
|
||||||
|
// KMK <--
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -147,7 +157,9 @@ internal class DownloadNotifier(private val context: Context) {
|
||||||
NotificationReceiver.clearDownloadsPendingBroadcast(context),
|
NotificationReceiver.clearDownloadsPendingBroadcast(context),
|
||||||
)
|
)
|
||||||
|
|
||||||
show(Notifications.ID_DOWNLOAD_CHAPTER_PROGRESS)
|
// KMK -->
|
||||||
|
show(Notifications.ID_DOWNLOAD_CHAPTER_PAUSED)
|
||||||
|
// KMK <--
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset initial values
|
// Reset initial values
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,10 @@ class Downloader(
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KMK -->
|
||||||
|
notifier.dismissPaused()
|
||||||
|
// KMK <--
|
||||||
|
|
||||||
val pending = queueState.value.filter { it.status != Download.State.DOWNLOADED }
|
val pending = queueState.value.filter { it.status != Download.State.DOWNLOADED }
|
||||||
pending.forEach { if (it.status != Download.State.QUEUE) it.status = Download.State.QUEUE }
|
pending.forEach { if (it.status != Download.State.QUEUE) it.status = Download.State.QUEUE }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ object Notifications {
|
||||||
private const val GROUP_DOWNLOADER = "group_downloader"
|
private const val GROUP_DOWNLOADER = "group_downloader"
|
||||||
const val CHANNEL_DOWNLOADER_PROGRESS = "downloader_progress_channel"
|
const val CHANNEL_DOWNLOADER_PROGRESS = "downloader_progress_channel"
|
||||||
const val ID_DOWNLOAD_CHAPTER_PROGRESS = -201
|
const val ID_DOWNLOAD_CHAPTER_PROGRESS = -201
|
||||||
|
// KMK -->
|
||||||
|
const val ID_DOWNLOAD_CHAPTER_PAUSED = -203
|
||||||
|
// KMK <--
|
||||||
const val CHANNEL_DOWNLOADER_ERROR = "downloader_error_channel"
|
const val CHANNEL_DOWNLOADER_ERROR = "downloader_error_channel"
|
||||||
const val ID_DOWNLOAD_CHAPTER_ERROR = -202
|
const val ID_DOWNLOAD_CHAPTER_ERROR = -202
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue