minor tweaks to automatic double shifting

Making sure the 2nd page doesn't undo a shift when the first page needs it + fixes to the page landed on when switching between single and double page via settings
This commit is contained in:
Jays2Kings 2023-02-26 20:43:47 -05:00
parent a925f72a0a
commit 87fe634b1c
3 changed files with 10 additions and 4 deletions

View file

@ -612,6 +612,7 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
}
fun isFirstPageFull(): Boolean = viewModel.getCurrentChapter()?.pages?.get(0)?.fullPage == true
fun isFirstPageEnd(): Boolean = viewModel.getCurrentChapter()?.pages?.get(0)?.isEndPage == true
private fun popToMain() {
if (fromUrl) {
@ -1259,6 +1260,8 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
if (doublePages) {
// If we're moving from single to double, we want the current page to be the first page
val currentIndex = binding.readerNav.pageSeekbar.value.roundToInt()
viewModel.getCurrentChapter()?.requestedPage = currentIndex
pViewer.hasMoved = false
pViewer.config.shiftDoublePage = shouldShiftDoublePages(currentIndex)
}
viewModel.state.value.viewerChapters?.let {
@ -1270,10 +1273,11 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
private fun shouldShiftDoublePages(currentIndex: Int): Boolean {
val currentChapter = viewModel.getCurrentChapter()
val currentPage = currentChapter?.pages?.get(currentIndex)
return (currentIndex +
return (
currentIndex +
(currentPage?.isEndPage == true && currentPage.fullPage != true).toInt() +
(currentChapter?.pages?.take(currentIndex)?.count { it.alonePage } ?: 0)
) % 2 != 0
) % 2 != 0
}
/**

View file

@ -817,7 +817,9 @@ class PagerPageHolder(
val isLTR = (viewer !is R2LPagerViewer).xor(viewer.config.invertDoublePages)
if (page.index <= 2 && page.isEndPage == null && page.fullPage == null) {
page.isEndPage = ImageUtil.isPagePadded(imageBitmap, rightSide = !isLTR)
if (page.index == 1 && page.isEndPage == true && viewer.config.shiftDoublePage) {
if (page.index == 1 && page.isEndPage == true && viewer.config.shiftDoublePage &&
!viewer.activity.isFirstPageEnd()
) {
shiftDoublePages(false)
return supportHingeIfThere(imageBytes.inputStream())
} else if ((page.isEndPage == true) &&

View file

@ -81,7 +81,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
}
}
private var hasMoved = false
var hasMoved = false
/**
* Variable used to hold the forward pos for reader activity shared transitions