mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
More fixes to shifter
Fixed when page 3 is maeked as an end page and it shifts, but page 2 is *definitely* an end page so it should shift back. Gonna started adding the source for these fixes: fix was applied for imaizumin's chap 12
This commit is contained in:
parent
63e372e092
commit
ddf97d0e9b
2 changed files with 20 additions and 18 deletions
|
@ -618,9 +618,6 @@ class ReaderActivity : BaseActivity<ReaderActivityBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
fun isFirstPageFull(): Boolean = viewModel.getCurrentChapter()?.pages?.get(0)?.fullPage == true
|
||||
fun getFirstPage(): ReaderPage? = viewModel.getCurrentChapter()?.pages?.get(0)
|
||||
|
||||
private fun popToMain() {
|
||||
if (fromUrl) {
|
||||
val intent = Intent(this, MainActivity::class.java).apply {
|
||||
|
|
|
@ -732,30 +732,32 @@ class PagerPageHolder(
|
|||
}
|
||||
return supportHingeIfThere(imageBytes.inputStream())
|
||||
}
|
||||
val isNotEndPage: ReaderPage.() -> Boolean =
|
||||
{ isEndPage != true || page.paddedPageConfidence > paddedPageConfidence }
|
||||
val pages = page.chapter.pages
|
||||
var earlyImageBitmap2: Bitmap? = null
|
||||
val isFirstPageNotEnd by lazy { pages?.get(0)?.let { it.isNotEndPage() } != false }
|
||||
val isThirdPageNotEnd by lazy { pages?.getOrNull(2)?.let { it.isNotEndPage() } == true }
|
||||
val shouldShiftAnyway = !viewer.activity.manuallyShiftedPages && page.isEndPage == true &&
|
||||
page.paddedPageConfidence == 3
|
||||
if (page.index <= 2 && page.isEndPage == null && page.fullPage == null) {
|
||||
page.paddedPageConfidence = imageBitmap.isPagePadded(rightSide = !isLTR)
|
||||
page.isEndPage = page.paddedPageConfidence > 0
|
||||
if (extraPage?.index == 1 && extraPage?.isEndPage == null) {
|
||||
earlyImageBitmap2 = setExtraPageBitmap(imageBytes2, isLTR)
|
||||
}
|
||||
val isFirstPageEndPage by lazy {
|
||||
viewer.activity.getFirstPage()?.let {
|
||||
it.isEndPage != true || page.paddedPageConfidence > it.paddedPageConfidence
|
||||
} != false
|
||||
}
|
||||
if (page.index == 1 && page.isEndPage == true && viewer.config.shiftDoublePage &&
|
||||
isFirstPageEndPage
|
||||
(isFirstPageNotEnd || isThirdPageNotEnd)
|
||||
) {
|
||||
shiftDoublePages(false)
|
||||
return supportHingeIfThere(imageBytes.inputStream())
|
||||
} else if (page.isEndPage == true &&
|
||||
when (page.index) {
|
||||
// 3rd page shouldn't shift if page 1 is a spread
|
||||
2 -> !viewer.activity.isFirstPageFull()
|
||||
// 2nd page shouldn't shift if page 1 is more likely an end page
|
||||
1 -> isFirstPageEndPage
|
||||
// first page shouldn't shift if page 2 is definitely an end page
|
||||
// 3rd page shouldn't shift if the 1st page is a spread
|
||||
2 -> pages?.get(0)?.fullPage != true
|
||||
// 2nd page shouldn't shift if the 1st page is more likely an end page
|
||||
1 -> isFirstPageNotEnd
|
||||
// 1st page shouldn't shift if the 2nd page is definitely an end page
|
||||
0 -> extraPage?.run { isEndPage == true && paddedPageConfidence == 3 } != true ||
|
||||
page.paddedPageConfidence == 3
|
||||
else -> false
|
||||
|
@ -765,13 +767,16 @@ class PagerPageHolder(
|
|||
extraPage = null
|
||||
return supportHingeIfThere(imageBytes.inputStream())
|
||||
}
|
||||
} else if (!viewer.activity.manuallyShiftedPages && (page.index == 0 || page.index == 2) &&
|
||||
page.isEndPage == true && page.paddedPageConfidence == 3
|
||||
) {
|
||||
} else if (shouldShiftAnyway && (page.index == 0 || page.index == 2)) {
|
||||
// if for some reason the first page should be by itself but its not, fix that
|
||||
shiftDoublePages(true)
|
||||
extraPage = null
|
||||
return supportHingeIfThere(imageBytes.inputStream())
|
||||
} else if (shouldShiftAnyway && page.index == 1 &&
|
||||
viewer.config.shiftDoublePage && (isFirstPageNotEnd || isThirdPageNotEnd)
|
||||
) {
|
||||
shiftDoublePages(false)
|
||||
return supportHingeIfThere(imageBytes.inputStream())
|
||||
}
|
||||
|
||||
val imageBitmap2 = earlyImageBitmap2 ?: try {
|
||||
|
@ -809,7 +814,7 @@ class PagerPageHolder(
|
|||
extraPage.paddedPageConfidence = imageBitmap2.isPagePadded(rightSide = isLTR)
|
||||
extraPage.isStartPage = extraPage.paddedPageConfidence > 0
|
||||
if (extraPage.isStartPage == true) {
|
||||
shiftDoublePages(page.index == 0 || viewer.activity.isFirstPageFull())
|
||||
shiftDoublePages(page.index == 0 || pages?.get(0)?.fullPage == true)
|
||||
this.extraPage = null
|
||||
return supportHingeIfThere(imageBytes.inputStream())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue