Enhance incognito mode (#4073)
* When in Incognito Mode don't set lastUsedSource * When in Incognito Mode don't save chapter progress Still allows tracking and mark as read when reaching last page * When in Incognito Mode don't mark as read (overwritten if hasTrackers) (cherry picked from commit c9c0f3d01431a1008669d2a04bb6a5c87ccca645)
This commit is contained in:
parent
4a1e832bf5
commit
6a1a7275c8
@ -317,7 +317,9 @@ class SourceController(bundle: Bundle? = null) :
|
|||||||
* Opens a catalogue with the given controller.
|
* Opens a catalogue with the given controller.
|
||||||
*/
|
*/
|
||||||
private fun openSource(source: CatalogueSource, controller: BrowseSourceController) {
|
private fun openSource(source: CatalogueSource, controller: BrowseSourceController) {
|
||||||
preferences.lastUsedSource().set(source.id)
|
if (!preferences.incognitoMode().get()) {
|
||||||
|
preferences.lastUsedSource().set(source.id)
|
||||||
|
}
|
||||||
parentController!!.router.pushController(controller.withFadeTransaction())
|
parentController!!.router.pushController(controller.withFadeTransaction())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +167,13 @@ class ReaderPresenter(
|
|||||||
}.map(::ReaderChapter)
|
}.map(::ReaderChapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var hasTrackers: Boolean = false
|
||||||
|
private val checkTrackers: (Manga) -> Unit = { manga ->
|
||||||
|
val tracks = db.getTracks(manga).executeAsBlocking()
|
||||||
|
|
||||||
|
hasTrackers = tracks.size > 0
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the presenter is created. It retrieves the saved active chapter if the process
|
* Called when the presenter is created. It retrieves the saved active chapter if the process
|
||||||
* was restored.
|
* was restored.
|
||||||
@ -273,6 +280,8 @@ class ReaderPresenter(
|
|||||||
// SY <--
|
// SY <--
|
||||||
if (chapterId == -1L) chapterId = initialChapterId
|
if (chapterId == -1L) chapterId = initialChapterId
|
||||||
|
|
||||||
|
checkTrackers(manga)
|
||||||
|
|
||||||
val context = Injekt.get<Application>()
|
val context = Injekt.get<Application>()
|
||||||
val source = sourceManager.getOrStub(manga.source)
|
val source = sourceManager.getOrStub(manga.source)
|
||||||
val mergedReferences = if (source is MergedSource) db.getMergedMangaReferences(manga.id!!).executeAsBlocking() else emptyList()
|
val mergedReferences = if (source is MergedSource) db.getMergedMangaReferences(manga.id!!).executeAsBlocking() else emptyList()
|
||||||
@ -437,7 +446,8 @@ class ReaderPresenter(
|
|||||||
|
|
||||||
// Save last page read and mark as read if needed
|
// Save last page read and mark as read if needed
|
||||||
selectedChapter.chapter.last_page_read = page.index
|
selectedChapter.chapter.last_page_read = page.index
|
||||||
if (selectedChapter.pages?.lastIndex == page.index) {
|
val shouldTrack = !preferences.incognitoMode().get() || hasTrackers
|
||||||
|
if (selectedChapter.pages?.lastIndex == page.index && shouldTrack) {
|
||||||
selectedChapter.chapter.read = true
|
selectedChapter.chapter.read = true
|
||||||
// SY -->
|
// SY -->
|
||||||
if (manga?.source == EH_SOURCE_ID || manga?.source == EXH_SOURCE_ID) {
|
if (manga?.source == EH_SOURCE_ID || manga?.source == EXH_SOURCE_ID) {
|
||||||
@ -506,16 +516,19 @@ class ReaderPresenter(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves this [chapter] progress (last read page and whether it's read).
|
* Saves this [chapter] progress (last read page and whether it's read).
|
||||||
|
* If incognito mode isn't on or has at least 1 tracker
|
||||||
*/
|
*/
|
||||||
private fun saveChapterProgress(chapter: ReaderChapter) {
|
private fun saveChapterProgress(chapter: ReaderChapter) {
|
||||||
db.updateChapterProgress(chapter.chapter).asRxCompletable()
|
if (!preferences.incognitoMode().get() || hasTrackers) {
|
||||||
.onErrorComplete()
|
db.updateChapterProgress(chapter.chapter).asRxCompletable()
|
||||||
.subscribeOn(Schedulers.io())
|
.onErrorComplete()
|
||||||
.subscribe()
|
.subscribeOn(Schedulers.io())
|
||||||
|
.subscribe()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves this [chapter] last read history.
|
* Saves this [chapter] last read history if incognito mode isn't on.
|
||||||
*/
|
*/
|
||||||
private fun saveChapterHistory(chapter: ReaderChapter) {
|
private fun saveChapterHistory(chapter: ReaderChapter) {
|
||||||
if (!preferences.incognitoMode().get()) {
|
if (!preferences.incognitoMode().get()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user