From 6fddad7a77fca781582b9d98de66c29848df2a17 Mon Sep 17 00:00:00 2001 From: Riztard Lanthorn Date: Fri, 17 Dec 2021 21:40:54 +0700 Subject: [PATCH] Add option for library update only update completely read manga (#6323) * Add option for library update only update completely read manga only check manga for updates if there is no unread chapter * sum --- .../kanade/tachiyomi/data/library/LibraryUpdateService.kt | 4 ++++ .../eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../kanade/tachiyomi/data/preference/PreferencesHelper.kt | 2 ++ .../tachiyomi/ui/setting/SettingsLibraryController.kt | 6 ++++++ app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 16 insertions(+) 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 f9370b1b74..1a176584a6 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 @@ -262,6 +262,10 @@ class LibraryUpdateService( listToUpdate = listToUpdate.filterNot { it.status == SManga.COMPLETED } } + if (target == Target.CHAPTERS && preferences.updateOnlyCompletelyRead()) { + listToUpdate = listToUpdate.filter { it.unread == 0 } + } + val selectedScheme = preferences.libraryUpdatePrioritization().get() mangaToUpdate = listToUpdate .distinctBy { it.id } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 7440d3b5cd..678522bc84 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -101,6 +101,8 @@ object PreferenceKeys { const val updateOnlyNonCompleted = "pref_update_only_non_completed_key" + const val updateOnlyCompletelyRead = "pref_update_only_completely_read" + const val autoUpdateTrack = "pref_auto_update_manga_sync_key" const val lastUsedSource = "last_catalogue_source" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 2d60d4b60d..50e4476f2f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -179,6 +179,8 @@ class PreferencesHelper(val context: Context) { fun updateOnlyNonCompleted() = prefs.getBoolean(Keys.updateOnlyNonCompleted, true) + fun updateOnlyCompletelyRead() = prefs.getBoolean(Keys.updateOnlyCompletelyRead, true) + fun autoUpdateTrack() = prefs.getBoolean(Keys.autoUpdateTrack, true) fun lastUsedSource() = flowPrefs.getLong(Keys.lastUsedSource, -1) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt index 91b664c9df..01bcf58b5a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsLibraryController.kt @@ -199,6 +199,12 @@ class SettingsLibraryController : SettingsController() { titleRes = R.string.pref_update_only_non_completed defaultValue = true } + switchPreference { + key = Keys.updateOnlyCompletelyRead + titleRes = R.string.pref_update_only_completely_read + summaryRes = R.string.pref_update_only_completely_read_summary + defaultValue = false + } preference { key = Keys.libraryUpdateCategories titleRes = R.string.categories diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9c0d360837..6072de7520 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -222,6 +222,8 @@ Charging Restrictions: %s Only update ongoing manga + Only update completely read manga + Only update manga if there is no unread chapter(completely read) Show unread count on Updates icon Automatically refresh metadata Check for new cover and details when updating library