diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index d1ede0c91..de0f53915 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -414,6 +414,7 @@ data class Book( const val imgStyleDefault = "DEFAULT" const val imgStyleFull = "FULL" const val imgStyleText = "TEXT" + const val imgStyleSingle = "SINGLE" } @Parcelize diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index c33f7482a..df43ae71a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -563,7 +563,7 @@ class ReadBookActivity : BaseReadBookActivity(), R.id.menu_set_charset -> showCharsetConfig() R.id.menu_image_style -> { val imgStyles = - arrayListOf(Book.imgStyleDefault, Book.imgStyleFull, Book.imgStyleText) + arrayListOf(Book.imgStyleDefault, Book.imgStyleFull, Book.imgStyleText, Book.imgStyleSingle) selector( R.string.image_style, imgStyles diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index a5f2b6719..b00556694 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -365,6 +365,36 @@ object ChapterProvider { height = size.height * visibleWidth / size.width } + Book.imgStyleSingle -> { + width = visibleWidth + height = size.height * visibleWidth / size.width + if (height > visibleHeight) { + width = width * visibleHeight / height + height = visibleHeight + } + if (durY > 0f) { + val textPage = textPages.last() + if (doublePage && absStartX < viewWidth / 2) { + //当前页面左列结束 + textPage.leftLineSize = textPage.lineSize + absStartX = viewWidth / 2 + paddingLeft + } else { + //当前页面结束 + if (textPage.leftLineSize == 0) { + textPage.leftLineSize = textPage.lineSize + } + textPage.text = stringBuilder.toString().ifEmpty { "本页无文字内容" } + stringBuilder.clear() + textPages.add(TextPage()) + } + // 双页的 durY 不正确,可能会小于实际高度 + if (textPage.height < durY) { + textPage.height = durY + } + durY = 0f + } + } + else -> { if (size.width > visibleWidth) { height = size.height * visibleWidth / size.width diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt index 6c1e26ded..0766c83de 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/TextChapterLayout.kt @@ -341,6 +341,39 @@ class TextChapterLayout( height = size.height * visibleWidth / size.width } + Book.imgStyleSingle -> { + width = ChapterProvider.visibleWidth + height = size.height * ChapterProvider.visibleWidth / size.width + if (height > ChapterProvider.visibleHeight) { + width = width * ChapterProvider.visibleHeight / height + height = ChapterProvider.visibleHeight + } + if (durY > 0f) { + val textPage = pendingTextPage + // 双页的 durY 不正确,可能会小于实际高度 + if (textPage.height < durY) { + textPage.height = durY + } + if (doublePage && absStartX < viewWidth / 2) { + //当前页面左列结束 + textPage.leftLineSize = textPage.lineSize + absStartX = viewWidth / 2 + paddingLeft + } else { + //当前页面结束 + if (textPage.leftLineSize == 0) { + textPage.leftLineSize = textPage.lineSize + } + textPage.text = stringBuilder.toString().ifEmpty { "本页无文字内容" } + stringBuilder.clear() + textPages.add(textPage) + coroutineContext.ensureActive() + onPageCompleted() + pendingTextPage = TextPage() + } + durY = 0f + } + } + else -> { if (size.width > visibleWidth) { height = size.height * visibleWidth / size.width