From 259946cf0ab05cec0175ea27e982e1ae607c7e69 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 23 May 2020 10:37:46 -0400 Subject: [PATCH] Make metadata updating optional --- .../data/library/LibraryUpdateService.kt | 22 ++++++++++--------- .../data/preference/PreferenceKeys.kt | 2 ++ .../data/preference/PreferencesHelper.kt | 2 ++ .../ui/setting/SettingsLibraryController.kt | 6 +++++ app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 24 insertions(+), 10 deletions(-) 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 7d42511889..855a98d390 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 @@ -334,16 +334,18 @@ class LibraryUpdateService( val source = sourceManager.get(manga.source) ?: return Observable.empty() // Update manga details metadata in the background - source.fetchMangaDetails(manga) - .map { networkManga -> - manga.prepUpdateCover(coverCache, networkManga, false) - manga.copyFrom(networkManga) - db.insertManga(manga).executeAsBlocking() - manga - } - .onErrorResumeNext { Observable.just(manga) } - .subscribeOn(Schedulers.io()) - .subscribe() + if (preferences.autoUpdateMetadata()) { + source.fetchMangaDetails(manga) + .map { networkManga -> + manga.prepUpdateCover(coverCache, networkManga, false) + manga.copyFrom(networkManga) + db.insertManga(manga).executeAsBlocking() + manga + } + .onErrorResumeNext { Observable.just(manga) } + .subscribeOn(Schedulers.io()) + .subscribe() + } return source.fetchChapterList(manga) .map { syncChaptersWithSource(db, it, manga, source) } 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 839763b1b5..6e27b07bd1 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 @@ -123,6 +123,8 @@ object PreferenceKeys { const val hideNotificationContent = "hide_notification_content" + const val autoUpdateMetadata = "auto_update_metadata" + const val showLibraryUpdateErrors = "show_library_update_errors" const val downloadNew = "download_new" 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 44cab6f387..de566015a2 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 @@ -67,6 +67,8 @@ class PreferencesHelper(val context: Context) { fun hideNotificationContent() = prefs.getBoolean(Keys.hideNotificationContent, false) + fun autoUpdateMetadata() = prefs.getBoolean(Keys.autoUpdateMetadata, false) + fun showLibraryUpdateErrors() = prefs.getBoolean(Keys.showLibraryUpdateErrors, false) fun clear() = prefs.edit().clear().apply() 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 ef306ec969..70137dce2b 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() { true } } + switchPreference { + key = Keys.autoUpdateMetadata + titleRes = R.string.pref_library_update_refresh_metadata + summaryRes = R.string.pref_library_update_refresh_metadata_summary + defaultValue = false + } switchPreference { key = Keys.showLibraryUpdateErrors titleRes = R.string.pref_library_update_error_notification diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f6f5c036a2..5fcbe11220 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -184,6 +184,8 @@ Wi-Fi Charging Only update ongoing manga + Automatically refresh metadata + Check for new cover and details when updating library Show update errors notifications Categories