From 647391ef73ab0b89b1ba1f59e6e80d7605ba51e4 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 20 May 2020 17:39:01 -0400 Subject: [PATCH] Make library update error notification optional (closes #3200) --- .../eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt | 2 +- .../eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt | 2 ++ .../kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt | 2 +- .../kanade/tachiyomi/ui/setting/SettingsLibraryController.kt | 5 +++++ app/src/main/res/values/strings.xml | 1 + 6 files changed, 12 insertions(+), 2 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 b32265593..7d4251188 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 @@ -307,7 +307,7 @@ class LibraryUpdateService( } } - if (failedUpdates.isNotEmpty()) { + if (preferences.showLibraryUpdateErrors() && failedUpdates.isNotEmpty()) { val errorFile = writeErrorFile(failedUpdates) notifier.showUpdateErrorNotification( failedUpdates.map { it.first.title }, 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 2eadd175c..839763b1b 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 showLibraryUpdateErrors = "show_library_update_errors" + const val downloadNew = "download_new" const val downloadNewCategories = "download_new_categories" 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 dc1bb2da8..44cab6f38 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 showLibraryUpdateErrors() = prefs.getBoolean(Keys.showLibraryUpdateErrors, false) + fun clear() = prefs.edit().clear().apply() fun themeMode() = flowPrefs.getString(Keys.themeMode, Values.THEME_MODE_SYSTEM) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt index 984c3c6a2..b8b5506a1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt @@ -120,7 +120,7 @@ class HistoryPresenter : BasePresenter() { } Manga.SORTING_UPLOAD_DATE -> { chapters.drop(currChapterIndex + 1) - .firstOrNull { it.date_upload >= chapter.date_upload} + .firstOrNull { it.date_upload >= chapter.date_upload } } else -> throw NotImplementedError("Unknown sorting method") } 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 c5e8d4ce6..3044355e9 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 @@ -164,6 +164,11 @@ class SettingsLibraryController : SettingsController() { true } } + switchPreference { + key = Keys.showLibraryUpdateErrors + titleRes = R.string.pref_library_update_error_notification + defaultValue = false + } } preferenceCategory { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3e25f9f95..f6f5c036a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -184,6 +184,7 @@ Wi-Fi Charging Only update ongoing manga + Show update errors notifications Categories Default category