From cf39ae0000a39542ba867f894c095f96c71141ef Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 3 Oct 2020 10:53:26 -0400 Subject: [PATCH] Add banner for Incognito Mode --- .../data/preference/PreferencesHelper.kt | 2 +- .../kanade/tachiyomi/ui/main/MainActivity.kt | 4 ++++ .../tachiyomi/ui/reader/ReaderPresenter.kt | 2 +- app/src/main/res/layout/main_activity.xml | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) 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 4c22f44f4..a84b447dc 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,7 +269,7 @@ class PreferencesHelper(val context: Context) { fun sortChapterByAscendingOrDescending() = prefs.getInt(Keys.defaultChapterSortByAscendingOrDescending, Manga.SORT_DESC) - fun incognitoMode() = prefs.getBoolean(Keys.incognitoMode, false) + fun incognitoMode() = flowPrefs.getBoolean(Keys.incognitoMode, false) fun setChapterSettingsDefault(manga: Manga) { prefs.edit { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 0ced7540e..95f7f7fb3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -169,6 +169,10 @@ class MainActivity : BaseActivity() { preferences.downloadedOnly() .asImmediateFlow { binding.downloadedOnly.isVisible = it } .launchIn(scope) + + preferences.incognitoMode() + .asImmediateFlow { binding.incognitoMode.isVisible = it } + .launchIn(scope) } override fun onNewIntent(intent: Intent) { 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 703eb308d..1ec3cd1af 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,7 +409,7 @@ class ReaderPresenter( * Saves this [chapter] last read history. */ private fun saveChapterHistory(chapter: ReaderChapter) { - if (!preferences.incognitoMode()) { + if (!preferences.incognitoMode().get()) { val history = History.create(chapter.chapter).apply { last_read = Date().time } db.updateHistoryLastRead(history).asRxCompletable() .onErrorComplete() diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index 5fcd84bb5..9d3b0ec39 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -44,6 +44,24 @@ + + + + + +