Show all currently updating manga in library update notification
(cherry picked from commit e65f59b3dfdaf776cd101b0e80d049a1ae4cdac8) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateNotifier.kt
This commit is contained in:
parent
cec05194eb
commit
b5f4eb79d9
@ -65,22 +65,25 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||||||
/**
|
/**
|
||||||
* Shows the notification containing the currently updating manga and the progress.
|
* 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 current the current progress.
|
||||||
* @param total the total progress.
|
* @param total the total progress.
|
||||||
*/
|
*/
|
||||||
fun showProgressNotification(manga: /* SY --> */ SManga /* SY <-- */, current: Int, total: Int) {
|
fun showProgressNotification(manga: List</* SY --> */SManga/* SY <-- */>, current: Int, total: Int) {
|
||||||
val title = if (preferences.hideNotificationContent()) {
|
if (preferences.hideNotificationContent()) {
|
||||||
context.getString(R.string.notification_check_updates)
|
progressNotificationBuilder
|
||||||
|
.setContentTitle(context.getString(R.string.notification_check_updates))
|
||||||
|
.setContentText("($current/$total)")
|
||||||
} else {
|
} 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(
|
context.notificationManager.notify(
|
||||||
Notifications.ID_LIBRARY_PROGRESS,
|
Notifications.ID_LIBRARY_PROGRESS,
|
||||||
progressNotificationBuilder
|
progressNotificationBuilder
|
||||||
.setContentTitle(title.chop(40))
|
|
||||||
.setContentText("($current/$total)")
|
|
||||||
.setProgress(total, current, false)
|
.setProgress(total, current, false)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
|
@ -68,7 +68,6 @@ import timber.log.Timber
|
|||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.io.File
|
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
|
* This class will take care of updating the chapters of the manga from the library. It can be
|
||||||
@ -352,7 +351,8 @@ class LibraryUpdateService(
|
|||||||
*/
|
*/
|
||||||
suspend fun updateChapterList() {
|
suspend fun updateChapterList() {
|
||||||
val semaphore = Semaphore(5)
|
val semaphore = Semaphore(5)
|
||||||
val progressCount = AtomicInteger(0)
|
var progressCount = 0
|
||||||
|
val currentlyUpdatingManga = mutableListOf<LibraryManga>()
|
||||||
val newUpdates = mutableListOf<Pair<LibraryManga, Array<Chapter>>>()
|
val newUpdates = mutableListOf<Pair<LibraryManga, Array<Chapter>>>()
|
||||||
val failedUpdates = mutableListOf<Pair<Manga, String?>>()
|
val failedUpdates = mutableListOf<Pair<Manga, String?>>()
|
||||||
var hasDownloads = false
|
var hasDownloads = false
|
||||||
@ -370,7 +370,13 @@ class LibraryUpdateService(
|
|||||||
return@async
|
return@async
|
||||||
}
|
}
|
||||||
|
|
||||||
notifier.showProgressNotification(manga, progressCount.andIncrement, mangaToUpdate.size)
|
currentlyUpdatingManga.add(manga)
|
||||||
|
progressCount++
|
||||||
|
notifier.showProgressNotification(
|
||||||
|
currentlyUpdatingManga,
|
||||||
|
progressCount,
|
||||||
|
mangaToUpdate.size
|
||||||
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val (newChapters, _) = updateManga(manga)
|
val (newChapters, _) = updateManga(manga)
|
||||||
@ -399,6 +405,13 @@ class LibraryUpdateService(
|
|||||||
if (preferences.autoUpdateTrackers()) {
|
if (preferences.autoUpdateTrackers()) {
|
||||||
updateTrackings(manga, loggedServices)
|
updateTrackings(manga, loggedServices)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentlyUpdatingManga.remove(manga)
|
||||||
|
notifier.showProgressNotification(
|
||||||
|
currentlyUpdatingManga,
|
||||||
|
progressCount,
|
||||||
|
mangaToUpdate.size
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -497,7 +510,7 @@ class LibraryUpdateService(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
notifier.showProgressNotification(manga, progressCount++, mangaToUpdate.size)
|
notifier.showProgressNotification(listOf(manga), progressCount++, mangaToUpdate.size)
|
||||||
|
|
||||||
sourceManager.get(manga.source)?.let { source ->
|
sourceManager.get(manga.source)?.let { source ->
|
||||||
try {
|
try {
|
||||||
@ -532,8 +545,7 @@ class LibraryUpdateService(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify manga that will update.
|
notifier.showProgressNotification(listOf(manga), progressCount++, mangaToUpdate.size)
|
||||||
notifier.showProgressNotification(manga, progressCount++, mangaToUpdate.size)
|
|
||||||
|
|
||||||
// Update the tracking details.
|
// Update the tracking details.
|
||||||
updateTrackings(manga, loggedServices)
|
updateTrackings(manga, loggedServices)
|
||||||
@ -572,7 +584,7 @@ class LibraryUpdateService(
|
|||||||
* filter all follows from Mangadex and only add reading or rereading manga to library
|
* filter all follows from Mangadex and only add reading or rereading manga to library
|
||||||
*/
|
*/
|
||||||
private suspend fun syncFollows() {
|
private suspend fun syncFollows() {
|
||||||
val count = AtomicInteger(0)
|
var count = 0
|
||||||
val mangaDex = MdUtil.getEnabledMangaDex(preferences, sourceManager) ?: return
|
val mangaDex = MdUtil.getEnabledMangaDex(preferences, sourceManager) ?: return
|
||||||
val syncFollowStatusInts = preferences.mangadexSyncToLibraryIndexes().get().map { it.toInt() }
|
val syncFollowStatusInts = preferences.mangadexSyncToLibraryIndexes().get().map { it.toInt() }
|
||||||
|
|
||||||
@ -587,7 +599,8 @@ class LibraryUpdateService(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
notifier.showProgressNotification(networkManga, count.andIncrement, size)
|
count++
|
||||||
|
notifier.showProgressNotification(listOf(networkManga), count, size)
|
||||||
|
|
||||||
var dbManga = db.getManga(networkManga.url, mangaDex.id)
|
var dbManga = db.getManga(networkManga.url, mangaDex.id)
|
||||||
.executeOnIO()
|
.executeOnIO()
|
||||||
@ -616,7 +629,7 @@ class LibraryUpdateService(
|
|||||||
* Method that updates the all mangas which are not tracked as "reading" on mangadex
|
* Method that updates the all mangas which are not tracked as "reading" on mangadex
|
||||||
*/
|
*/
|
||||||
private suspend fun pushFavorites() {
|
private suspend fun pushFavorites() {
|
||||||
val count = AtomicInteger(0)
|
var count = 0
|
||||||
val listManga = db.getFavoriteMangas().executeAsBlocking().filter { it.source in mangaDexSourceIds }
|
val listManga = db.getFavoriteMangas().executeAsBlocking().filter { it.source in mangaDexSourceIds }
|
||||||
|
|
||||||
// filter all follows from Mangadex and only add reading or rereading manga to library
|
// filter all follows from Mangadex and only add reading or rereading manga to library
|
||||||
@ -626,7 +639,8 @@ class LibraryUpdateService(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
notifier.showProgressNotification(manga, count.andIncrement, listManga.size)
|
count++
|
||||||
|
notifier.showProgressNotification(listOf(manga), count, listManga.size)
|
||||||
|
|
||||||
// Get this manga's trackers from the database
|
// Get this manga's trackers from the database
|
||||||
val dbTracks = db.getTracks(manga).executeAsBlocking()
|
val dbTracks = db.getTracks(manga).executeAsBlocking()
|
||||||
|
@ -673,6 +673,7 @@
|
|||||||
|
|
||||||
<!-- Library update service notifications -->
|
<!-- Library update service notifications -->
|
||||||
<string name="notification_check_updates">Checking for new chapters</string>
|
<string name="notification_check_updates">Checking for new chapters</string>
|
||||||
|
<string name="notification_updating">Updating library… (%1$d/%2$d)</string>
|
||||||
<string name="notification_new_chapters">New chapters found</string>
|
<string name="notification_new_chapters">New chapters found</string>
|
||||||
<plurals name="notification_new_chapters_summary">
|
<plurals name="notification_new_chapters_summary">
|
||||||
<item quantity="one">For 1 title</item>
|
<item quantity="one">For 1 title</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user