From 79ccfcd55397f3df7ce91d88e93a7c879a3360ab Mon Sep 17 00:00:00 2001 From: Platiplus Date: Sat, 3 Oct 2020 11:43:01 -0300 Subject: [PATCH] [Feature Request] Option to turn off History - #3772 (#3855) * Implementing do not save chapter history preference * Refactor of labels * Changing incognito mode from Readers section to More * Fixing imports and removing unused strings --- .../tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../tachiyomi/data/preference/PreferencesHelper.kt | 2 ++ .../eu/kanade/tachiyomi/ui/more/MoreController.kt | 10 ++++++++++ .../eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 12 +++++++----- app/src/main/res/values/strings.xml | 2 ++ 5 files changed, 23 insertions(+), 5 deletions(-) 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 73c3dad48a..3cc5bb837e 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 @@ -179,6 +179,8 @@ object PreferenceKeys { const val defaultChapterDisplayByNameOrNumber = "default_chapter_display_by_name_or_number" + const val incognitoMode = "incognito_mode" + fun trackUsername(syncId: Int) = "pref_mangasync_username_$syncId" fun trackPassword(syncId: Int) = "pref_mangasync_password_$syncId" 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 0daa433d7a..4c22f44f46 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 @@ -269,6 +269,8 @@ class PreferencesHelper(val context: Context) { fun sortChapterByAscendingOrDescending() = prefs.getInt(Keys.defaultChapterSortByAscendingOrDescending, Manga.SORT_DESC) + fun incognitoMode() = prefs.getBoolean(Keys.incognitoMode, false) + fun setChapterSettingsDefault(manga: Manga) { prefs.edit { putInt(Keys.defaultChapterFilterByRead, manga.readFilter) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt index aa839a9ec1..3dbcca6b52 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt @@ -23,6 +23,7 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.summaryRes import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes +import eu.kanade.tachiyomi.util.preference.defaultValue import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.openInBrowser import rx.android.schedulers.AndroidSchedulers @@ -53,6 +54,15 @@ class MoreController : iconTint = tintColor } + switchPreference { + key = Keys.incognitoMode + summaryRes = R.string.pref_incognito_mode_summary + titleRes = R.string.pref_incognito_mode + iconRes = R.drawable.ic_glasses_black_24dp + iconTint = tintColor + defaultValue = false + } + preferenceCategory { preference { titleRes = R.string.label_download_queue diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 85b2ee797a..703eb308d5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -409,11 +409,13 @@ class ReaderPresenter( * Saves this [chapter] last read history. */ private fun saveChapterHistory(chapter: ReaderChapter) { - val history = History.create(chapter.chapter).apply { last_read = Date().time } - db.updateHistoryLastRead(history).asRxCompletable() - .onErrorComplete() - .subscribeOn(Schedulers.io()) - .subscribe() + if (!preferences.incognitoMode()) { + val history = History.create(chapter.chapter).apply { last_read = Date().time } + db.updateHistoryLastRead(history).asRxCompletable() + .onErrorComplete() + .subscribeOn(Schedulers.io()) + .subscribe() + } } /** diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 948dac4015..4f8086bbd9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -318,6 +318,8 @@ 15% 20% 25% + Incognito mode + Disables recording history in History tab Download location