feat: progress for starting manga (#245)

The caveat is that the user must have disabled updating each title individually, along with the other standard checks. This will only apply when a chapter has not been completed.
This commit is contained in:
TwistedUmbrellaX 2024-03-17 00:00:58 -04:00 committed by GitHub
parent 8177dfdcef
commit c054e2f2ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 133 additions and 7 deletions

View file

@ -1854,17 +1854,23 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
private fun updateAniProgress() {
val incognito: Boolean = PrefManager.getVal(PrefName.Incognito)
if (!incognito && exoPlayer.currentPosition / episodeLength > PrefManager.getVal<Float>(
PrefName.WatchPercentage
) && Anilist.userid != null
val episodeEnd = exoPlayer.currentPosition / episodeLength > PrefManager.getVal<Float>(
PrefName.WatchPercentage
)
val episode0 = currentEpisodeIndex == 0 && PrefManager.getVal(PrefName.ChapterZeroPlayer)
if (!incognito && (episodeEnd || episode0) && Anilist.userid != null
)
if (PrefManager.getCustomVal(
"${media.id}_save_progress",
true
) && (if (media.isAdult) PrefManager.getVal(PrefName.UpdateForHPlayer) else true)
) {
media.anime!!.selectedEpisode?.apply {
updateProgress(media, this)
if (episode0) {
updateProgress(media, "0")
} else {
media.anime!!.selectedEpisode?.apply {
updateProgress(media, this)
}
}
}
}

View file

@ -151,7 +151,21 @@ class MangaReaderActivity : AppCompatActivity() {
defaultSettings = loadReaderSettings("reader_settings") ?: defaultSettings
onBackPressedDispatcher.addCallback(this) {
progress { finish() }
val chapter = (MangaNameAdapter.findChapterNumber(media.manga!!.selectedChapter!!)
?.minus(1L) ?: 0).toString()
if (chapter == "0.0" && PrefManager.getVal(PrefName.ChapterZeroReader)
// Not asking individually or incognito
&& !showProgressDialog && !PrefManager.getVal<Boolean>(PrefName.Incognito)
// Not ...opted out ...already? Somehow?
&& PrefManager.getCustomVal("${media.id}_save_progress", true)
// Allowing Doujin updates or not one
&& if (media.isAdult) PrefManager.getVal(PrefName.UpdateForHReader) else true
) {
updateProgress(media, chapter)
finish()
} else {
progress { finish() }
}
}
controllerDuration = (PrefManager.getVal<Float>(PrefName.AnimationSpeed) * 200).toLong()