From e65f59b3dfdaf776cd101b0e80d049a1ae4cdac8 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 8 Jul 2021 23:03:22 -0400 Subject: [PATCH] Show all currently updating manga in library update notification --- .../data/library/LibraryUpdateNotifier.kt | 17 +++++++------ .../data/library/LibraryUpdateService.kt | 24 ++++++++++++++----- app/src/main/res/values/strings.xml | 1 + 3 files changed, 29 insertions(+), 13 deletions(-) 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 9cc135cb9..e2f2eef87 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 @@ -64,22 +64,25 @@ class LibraryUpdateNotifier(private val context: Context) { /** * Shows the notification containing the currently updating manga and the progress. * - * @param manga the manga that's being updated. + * @param manga the manga that are being updated. * @param current the current progress. * @param total the total progress. */ - fun showProgressNotification(manga: Manga, current: Int, total: Int) { - val title = if (preferences.hideNotificationContent()) { - context.getString(R.string.notification_check_updates) + fun showProgressNotification(manga: List, current: Int, total: Int) { + if (preferences.hideNotificationContent()) { + progressNotificationBuilder + .setContentTitle(context.getString(R.string.notification_check_updates)) + .setContentText("($current/$total)") } else { - manga.title + val updatingText = manga.joinToString("\n") { it.title } + progressNotificationBuilder + .setContentTitle(context.getString(R.string.notification_updating, current, total)) + .setStyle(NotificationCompat.BigTextStyle().bigText(updatingText)) } context.notificationManager.notify( Notifications.ID_LIBRARY_PROGRESS, progressNotificationBuilder - .setContentTitle(title.chop(40)) - .setContentText("($current/$total)") .setProgress(total, current, false) .build() ) 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 c61ed351a..ac6ea0731 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 @@ -54,7 +54,6 @@ import timber.log.Timber import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.io.File -import java.util.concurrent.atomic.AtomicInteger /** * This class will take care of updating the chapters of the manga from the library. It can be @@ -274,7 +273,8 @@ class LibraryUpdateService( */ suspend fun updateChapterList() { val semaphore = Semaphore(5) - val progressCount = AtomicInteger(0) + var progressCount = 0 + val currentlyUpdatingManga = mutableListOf() val newUpdates = mutableListOf>>() val failedUpdates = mutableListOf>() var hasDownloads = false @@ -291,7 +291,13 @@ class LibraryUpdateService( return@async } - notifier.showProgressNotification(manga, progressCount.andIncrement, mangaToUpdate.size) + currentlyUpdatingManga.add(manga) + progressCount++ + notifier.showProgressNotification( + currentlyUpdatingManga, + progressCount, + mangaToUpdate.size + ) try { val (newChapters, _) = updateManga(manga) @@ -317,6 +323,13 @@ class LibraryUpdateService( if (preferences.autoUpdateTrackers()) { updateTrackings(manga, loggedServices) } + + currentlyUpdatingManga.remove(manga) + notifier.showProgressNotification( + currentlyUpdatingManga, + progressCount, + mangaToUpdate.size + ) } } } @@ -391,7 +404,7 @@ class LibraryUpdateService( return } - notifier.showProgressNotification(manga, progressCount++, mangaToUpdate.size) + notifier.showProgressNotification(listOf(manga), progressCount++, mangaToUpdate.size) sourceManager.get(manga.source)?.let { source -> try { @@ -426,8 +439,7 @@ class LibraryUpdateService( return } - // Notify manga that will update. - notifier.showProgressNotification(manga, progressCount++, mangaToUpdate.size) + notifier.showProgressNotification(listOf(manga), progressCount++, mangaToUpdate.size) // Update the tracking details. updateTrackings(manga, loggedServices) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index abe2d0b6f..af063bfc4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -672,6 +672,7 @@ Checking for new chapters + Updating library… (%1$d/%2$d) New chapters found For 1 title