mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 09:41:51 +01:00
Library update notification changes (#10175)
Don't round up notification percentage. Why show 100% when stuff is still updating. Show same notification when hide notification content is enabled. Just exclude manga titles.
This commit is contained in:
parent
a5c9469698
commit
ba10093ddc
@ -33,12 +33,14 @@ import tachiyomi.domain.chapter.model.Chapter
|
|||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import java.math.RoundingMode
|
||||||
import java.text.NumberFormat
|
import java.text.NumberFormat
|
||||||
|
|
||||||
class LibraryUpdateNotifier(private val context: Context) {
|
class LibraryUpdateNotifier(private val context: Context) {
|
||||||
|
|
||||||
private val preferences: SecurityPreferences by injectLazy()
|
private val preferences: SecurityPreferences by injectLazy()
|
||||||
private val percentFormatter = NumberFormat.getPercentInstance().apply {
|
private val percentFormatter = NumberFormat.getPercentInstance().apply {
|
||||||
|
roundingMode = RoundingMode.DOWN
|
||||||
maximumFractionDigits = 0
|
maximumFractionDigits = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,20 +80,17 @@ class LibraryUpdateNotifier(private val context: Context) {
|
|||||||
* @param total the total progress.
|
* @param total the total progress.
|
||||||
*/
|
*/
|
||||||
fun showProgressNotification(manga: List<Manga>, current: Int, total: Int) {
|
fun showProgressNotification(manga: List<Manga>, current: Int, total: Int) {
|
||||||
if (preferences.hideNotificationContent().get()) {
|
progressNotificationBuilder
|
||||||
progressNotificationBuilder
|
.setContentTitle(
|
||||||
.setContentTitle(context.stringResource(MR.strings.notification_check_updates))
|
context.stringResource(
|
||||||
.setContentText("($current/$total)")
|
MR.strings.notification_updating_progress,
|
||||||
} else {
|
percentFormatter.format(current.toFloat() / total),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!preferences.hideNotificationContent().get()) {
|
||||||
val updatingText = manga.joinToString("\n") { it.title.chop(40) }
|
val updatingText = manga.joinToString("\n") { it.title.chop(40) }
|
||||||
progressNotificationBuilder
|
progressNotificationBuilder.setStyle(NotificationCompat.BigTextStyle().bigText(updatingText))
|
||||||
.setContentTitle(
|
|
||||||
context.stringResource(
|
|
||||||
MR.strings.notification_updating_progress,
|
|
||||||
percentFormatter.format(current.toFloat() / total),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.setStyle(NotificationCompat.BigTextStyle().bigText(updatingText))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.notify(
|
context.notify(
|
||||||
|
@ -800,7 +800,6 @@
|
|||||||
<string name="download_queue_size_warning">Warning: large bulk downloads may lead to sources becoming slower and/or blocking Tachiyomi. Tap to learn more.</string>
|
<string name="download_queue_size_warning">Warning: large bulk downloads may lead to sources becoming slower and/or blocking Tachiyomi. Tap to learn more.</string>
|
||||||
|
|
||||||
<!-- Library update service notifications -->
|
<!-- Library update service notifications -->
|
||||||
<string name="notification_check_updates">Checking for new chapters</string>
|
|
||||||
<string name="notification_updating_progress">Updating library… (%s)</string>
|
<string name="notification_updating_progress">Updating library… (%s)</string>
|
||||||
<string name="notification_size_warning">Large updates harm sources and may lead to slower updates and also increased battery usage. Tap to learn more.</string>
|
<string name="notification_size_warning">Large updates harm sources and may lead to slower updates and also increased battery usage. Tap to learn more.</string>
|
||||||
<string name="notification_new_chapters">New chapters found</string>
|
<string name="notification_new_chapters">New chapters found</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user