mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 05:27:28 +01:00
Show notification to disable Incognito Mode when it's enabled (#4976)
* Show notification to disable Incognito Mode when it's enabled * Finish ReaderActivity and BrowseSourceController when incognito is disabled * CLeanup strings * Only register DisableIncognitoReceiver when needed
This commit is contained in:
@@ -41,6 +41,7 @@ import eu.kanade.tachiyomi.ui.base.controller.TabbedController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.ToolbarLiftOnScrollController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
|
||||
import eu.kanade.tachiyomi.ui.browse.BrowseController
|
||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController
|
||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController
|
||||
import eu.kanade.tachiyomi.ui.download.DownloadController
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryController
|
||||
@@ -224,7 +225,17 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
preferences.incognitoMode()
|
||||
.asImmediateFlow { binding.incognitoMode.isVisible = it }
|
||||
.asImmediateFlow {
|
||||
binding.incognitoMode.isVisible = it
|
||||
|
||||
// Close BrowseSourceController and its MangaController child when incognito mode is disabled
|
||||
if (!it) {
|
||||
val fg = router.backstack.last().controller()
|
||||
if (fg is BrowseSourceController || fg is MangaController && fg.fromSource) {
|
||||
router.popToRoot()
|
||||
}
|
||||
}
|
||||
}
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ class MangaController :
|
||||
var source: Source? = null
|
||||
private set
|
||||
|
||||
private val fromSource = args.getBoolean(FROM_SOURCE_EXTRA, false)
|
||||
val fromSource = args.getBoolean(FROM_SOURCE_EXTRA, false)
|
||||
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
private val coverCache: CoverCache by injectLazy()
|
||||
|
||||
@@ -167,6 +167,12 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
window.decorView.setOnSystemUiVisibilityChangeListener {
|
||||
setMenuVisibility(menuVisible, animate = false)
|
||||
}
|
||||
|
||||
// Finish when incognito mode is disabled
|
||||
preferences.incognitoMode().asFlow()
|
||||
.drop(1)
|
||||
.onEach { if (!it) finish() }
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -144,6 +144,8 @@ class ReaderPresenter(
|
||||
hasTrackers = tracks.size > 0
|
||||
}
|
||||
|
||||
private val incognitoMode = preferences.incognitoMode().get()
|
||||
|
||||
/**
|
||||
* Called when the presenter is created. It retrieves the saved active chapter if the process
|
||||
* was restored.
|
||||
@@ -375,7 +377,7 @@ class ReaderPresenter(
|
||||
|
||||
// Save last page read and mark as read if needed
|
||||
selectedChapter.chapter.last_page_read = page.index
|
||||
val shouldTrack = !preferences.incognitoMode().get() || hasTrackers
|
||||
val shouldTrack = !incognitoMode || hasTrackers
|
||||
if (selectedChapter.pages?.lastIndex == page.index && shouldTrack) {
|
||||
selectedChapter.chapter.read = true
|
||||
updateTrackChapterRead(selectedChapter)
|
||||
@@ -430,7 +432,7 @@ class ReaderPresenter(
|
||||
* If incognito mode isn't on or has at least 1 tracker
|
||||
*/
|
||||
private fun saveChapterProgress(chapter: ReaderChapter) {
|
||||
if (!preferences.incognitoMode().get() || hasTrackers) {
|
||||
if (!incognitoMode || hasTrackers) {
|
||||
db.updateChapterProgress(chapter.chapter).asRxCompletable()
|
||||
.onErrorComplete()
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -442,7 +444,7 @@ class ReaderPresenter(
|
||||
* Saves this [chapter] last read history if incognito mode isn't on.
|
||||
*/
|
||||
private fun saveChapterHistory(chapter: ReaderChapter) {
|
||||
if (!preferences.incognitoMode().get()) {
|
||||
if (!incognitoMode) {
|
||||
val history = History.create(chapter.chapter).apply { last_read = Date().time }
|
||||
db.updateHistoryLastRead(history).asRxCompletable()
|
||||
.onErrorComplete()
|
||||
|
||||
Reference in New Issue
Block a user