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 ae9d1be7d..c5af10a41 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 @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 99e777a4b..e1bf84772 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -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) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt index 5caf8ba77..ac9a7618e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt @@ -88,6 +88,20 @@ class LibraryUpdateNotifier(private val context: Context) { ) } + fun showQueueSizeWarningNotification() { + val notification = context.notificationBuilder(Notifications.CHANNEL_LIBRARY_PROGRESS) { + setContentTitle(context.getString(R.string.label_warning)) + setSmallIcon(R.drawable.ic_warning_white_24dp) + setStyle(NotificationCompat.BigTextStyle().bigText(context.getString(R.string.notification_size_warning))) + } + .build() + + context.notificationManager.notify( + Notifications.ID_LIBRARY_SIZE_WARNING, + notification, + ) + } + /** * Shows notification containing update entries that failed with action to open full log. * diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 00faa0478..ebdef98e5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -264,6 +264,10 @@ class LibraryUpdateService( mangaToUpdate = listToUpdate .distinctBy { it.id } .sortedWith(rankingScheme[selectedScheme]) + + if (mangaToUpdate.size > QUEUE_SIZE_WARNING_THRESHOLD) { + notifier.showQueueSizeWarningNotification() + } } /** @@ -567,3 +571,5 @@ class LibraryUpdateService( return File("") } } + +const val QUEUE_SIZE_WARNING_THRESHOLD = 100 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt index c6403a25c..753701a7b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/Notifications.kt @@ -27,6 +27,7 @@ object Notifications { private const val GROUP_LIBRARY = "group_library" const val CHANNEL_LIBRARY_PROGRESS = "library_progress_channel" const val ID_LIBRARY_PROGRESS = -101 + const val ID_LIBRARY_SIZE_WARNING = -103 const val CHANNEL_LIBRARY_ERROR = "library_errors_channel" const val ID_LIBRARY_ERROR = -102 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterNotifier.kt index 6dc4bec8c..cf8735b7b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterNotifier.kt @@ -117,7 +117,7 @@ internal class UpdaterNotifier(private val context: Context) { fun onDownloadError(url: String) { with(notificationBuilder) { setContentText(context.getString(R.string.update_check_notification_download_error)) - setSmallIcon(android.R.drawable.stat_sys_warning) + setSmallIcon(R.drawable.ic_warning_white_24dp) setOnlyAlertOnce(false) setProgress(0, 0, false) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f7a8ba2f9..e260ecbf8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,6 +24,7 @@ Extension info Help Default + Warning Unlock Tachiyomi Authenticate to confirm change @@ -706,6 +707,7 @@ Checking for new chapters Updating library… (%1$d/%2$d) + Large updates may lead to increased battery usage and sources becoming slower New chapters found For 1 title