From d9a2f75cde53f0eb38a6e4232864c57284e7373b Mon Sep 17 00:00:00 2001 From: SunQAQ <274978887@qq.com> Date: Fri, 22 Nov 2024 17:00:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B0=86=E8=AF=B7=E6=B1=82=E7=AD=89?= =?UTF-8?q?=E5=BE=85=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E7=94=B115s?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=B060s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/http/HttpHelper.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt index 2a7e58c0c170..d3e7666c07ef 100644 --- a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt @@ -53,9 +53,9 @@ val okHttpClient: OkHttpClient by lazy { ) val builder = OkHttpClient.Builder() - .connectTimeout(15, TimeUnit.SECONDS) - .writeTimeout(15, TimeUnit.SECONDS) - .readTimeout(15, TimeUnit.SECONDS) + .connectTimeout(60, TimeUnit.SECONDS) //将请求等待超时时间由15s增加到60s + .writeTimeout(60, TimeUnit.SECONDS) + .readTimeout(60, TimeUnit.SECONDS) .callTimeout(60, TimeUnit.SECONDS) //.cookieJar(cookieJar = cookieJar) .sslSocketFactory(SSLHelper.unsafeSSLSocketFactory, SSLHelper.unsafeTrustManager) From ce8dbad370ae4dcd7abea5f381a8ad3a77fdf79c Mon Sep 17 00:00:00 2001 From: SunQAQ <274978887@qq.com> Date: Mon, 23 Dec 2024 17:31:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E6=96=B0=E5=A2=9Esingle=EF=BC=8C=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?=E3=80=90=E6=BB=91=E5=8A=A8/=E8=A6=86=E7=9B=96=20+=20single?= =?UTF-8?q?=E3=80=91=E5=8F=AF=E5=AE=9E=E7=8E=B0=E4=B8=80=E9=A1=B5=E4=B8=80?= =?UTF-8?q?=E5=9B=BE=EF=BC=8C=E4=B8=94=E5=9B=BE=E7=89=87=E4=B8=BA=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E9=A1=B5=E9=9D=A2=E8=83=BD=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/data/entities/Book.kt | 1 + .../app/ui/book/read/ReadBookActivity.kt | 2 +- .../read/page/provider/ChapterProvider.kt | 30 +++++++++++++++++ .../read/page/provider/TextChapterLayout.kt | 33 +++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) 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 d1ede0c91178..de0f5391511f 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 c33f7482a1ed..df43ae71a717 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 a5f2b6719c50..b00556694500 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 6c1e26dedae6..0766c83ded24 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