From ba10093ddca8d409e43f26a80ea1f485b7767a6c Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sun, 26 Nov 2023 00:32:54 +0600 Subject: [PATCH] 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. --- .../data/library/LibraryUpdateNotifier.kt | 25 +++++++++---------- .../commonMain/resources/MR/base/strings.xml | 1 - 2 files changed, 12 insertions(+), 14 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 4a21b9bc0..d9e8dc54a 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 @@ -33,12 +33,14 @@ import tachiyomi.domain.chapter.model.Chapter import tachiyomi.domain.manga.model.Manga import tachiyomi.i18n.MR import uy.kohesive.injekt.injectLazy +import java.math.RoundingMode import java.text.NumberFormat class LibraryUpdateNotifier(private val context: Context) { private val preferences: SecurityPreferences by injectLazy() private val percentFormatter = NumberFormat.getPercentInstance().apply { + roundingMode = RoundingMode.DOWN maximumFractionDigits = 0 } @@ -78,20 +80,17 @@ class LibraryUpdateNotifier(private val context: Context) { * @param total the total progress. */ fun showProgressNotification(manga: List, current: Int, total: Int) { - if (preferences.hideNotificationContent().get()) { - progressNotificationBuilder - .setContentTitle(context.stringResource(MR.strings.notification_check_updates)) - .setContentText("($current/$total)") - } else { + progressNotificationBuilder + .setContentTitle( + context.stringResource( + MR.strings.notification_updating_progress, + percentFormatter.format(current.toFloat() / total), + ), + ) + + if (!preferences.hideNotificationContent().get()) { val updatingText = manga.joinToString("\n") { it.title.chop(40) } - progressNotificationBuilder - .setContentTitle( - context.stringResource( - MR.strings.notification_updating_progress, - percentFormatter.format(current.toFloat() / total), - ), - ) - .setStyle(NotificationCompat.BigTextStyle().bigText(updatingText)) + progressNotificationBuilder.setStyle(NotificationCompat.BigTextStyle().bigText(updatingText)) } context.notify( diff --git a/i18n/src/commonMain/resources/MR/base/strings.xml b/i18n/src/commonMain/resources/MR/base/strings.xml index 942894566..1d4febdd6 100644 --- a/i18n/src/commonMain/resources/MR/base/strings.xml +++ b/i18n/src/commonMain/resources/MR/base/strings.xml @@ -800,7 +800,6 @@ Warning: large bulk downloads may lead to sources becoming slower and/or blocking Tachiyomi. Tap to learn more. - Checking for new chapters Updating library… (%s) Large updates harm sources and may lead to slower updates and also increased battery usage. Tap to learn more. New chapters found