Add warnings when library and download queues are considered large (closes #5950)

Arbitrarily set at a size of 100 for now. We could adjust this in the future as appropriate if needed.
This commit is contained in:
arkon
2021-10-09 14:55:21 -04:00
parent 9106fc5b94
commit 082eef708f
7 changed files with 33 additions and 6 deletions
@@ -186,9 +186,9 @@ internal class DownloadNotifier(private val context: Context) {
*/
fun onWarning(reason: String) {
with(errorNotificationBuilder) {
setContentTitle(context.getString(R.string.download_notifier_downloader_title))
setContentText(reason)
setSmallIcon(android.R.drawable.stat_sys_warning)
setContentTitle(context.getString(R.string.label_warning))
setStyle(NotificationCompat.BigTextStyle().bigText(reason))
setSmallIcon(R.drawable.ic_warning_white_24dp)
setAutoCancel(true)
clearActions()
setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context))
@@ -216,7 +216,7 @@ internal class DownloadNotifier(private val context: Context) {
?: context.getString(R.string.download_notifier_downloader_title)
)
setContentText(error ?: context.getString(R.string.download_notifier_unknown_error))
setSmallIcon(android.R.drawable.stat_sys_warning)
setSmallIcon(R.drawable.ic_warning_white_24dp)
clearActions()
setContentIntent(NotificationHandler.openDownloadManagerPendingActivity(context))
setProgress(0, 0, false)
@@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.data.database.models.Chapter
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
import eu.kanade.tachiyomi.data.library.QUEUE_SIZE_WARNING_THRESHOLD
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.online.HttpSource
@@ -263,7 +264,10 @@ class Downloader(
// Start downloader if needed
if (autoStart && wasEmpty) {
DownloadService.start(this@Downloader.context)
if (queue.size > QUEUE_SIZE_WARNING_THRESHOLD) {
notifier.onWarning(context.getString(R.string.notification_size_warning))
}
DownloadService.start(context)
}
}
}