Pārlūkot izejas kodu

Make metadata updating optional

arkon 4 gadi atpakaļ
vecāks
revīzija
259946cf0a

+ 12 - 10
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) }

+ 2 - 0
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"

+ 2 - 0
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()

+ 6 - 0
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

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -184,6 +184,8 @@
     <string name="wifi">Wi-Fi</string>
     <string name="charging">Charging</string>
     <string name="pref_update_only_non_completed">Only update ongoing manga</string>
+    <string name="pref_library_update_refresh_metadata">Automatically refresh metadata</string>
+    <string name="pref_library_update_refresh_metadata_summary">Check for new cover and details when updating library</string>
     <string name="pref_library_update_error_notification">Show update errors notifications</string>
 
     <string name="pref_category_library_categories">Categories</string>