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 aba5aa977..5093c05c1 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
@@ -146,6 +146,14 @@ data class Book(
config().pageAnim = pageAnim
}
+ fun getImageStyle(): String? {
+ return config().imageStyle
+ }
+
+ fun setImageStyle(imageStyle: String?) {
+ config().imageStyle = imageStyle
+ }
+
fun getDelParagraph(): Int {
return config().delParagraph
}
@@ -228,15 +236,19 @@ data class Book(
const val hTag = 2L
const val rubyTag = 4L
const val imgTag = 8L
+ const val imgStyleDefault = "DEFAULT"
+ const val imgStyleFull = "FULL"
+ const val imgStyleText = "TEXT"
}
@Parcelize
data class ReadConfig(
var pageAnim: Int = -1,
var reSegment: Boolean = false,
- var useReplaceRule: Boolean = AppConfig.replaceEnableDefault, // 正文使用净化替换规则
+ var imageStyle: String? = null,
+ var useReplaceRule: Boolean = AppConfig.replaceEnableDefault,// 正文使用净化替换规则
var delParagraph: Int = 0,//去除段首
- var delTag: Long = 0L//去除标签
+ var delTag: Long = 0L,//去除标签
) : Parcelable
class Converters {
diff --git a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt
index 1fe21c3f8..4b03eb4a4 100644
--- a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt
+++ b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt
@@ -47,15 +47,8 @@ object BookChapterList {
}
var chapterData =
analyzeChapterList(
- scope,
- book,
- baseUrl,
- redirectUrl,
- body,
- tocRule,
- listRule,
- bookSource,
- log = true
+ scope, book, baseUrl, redirectUrl, body,
+ tocRule, listRule, bookSource, log = true
)
chapterData.chapterList?.let {
chapterList.addAll(it)
@@ -75,14 +68,8 @@ object BookChapterList {
headerMapF = bookSource.getHeaderMap()
).getStrResponse(bookSource.bookSourceUrl).body?.let { nextBody ->
chapterData = analyzeChapterList(
- this,
- book,
- nextUrl,
- nextUrl,
- nextBody,
- tocRule,
- listRule,
- bookSource
+ this, book, nextUrl, nextUrl,
+ nextBody, tocRule, listRule, bookSource
)
nextUrl = chapterData.nextUrl.firstOrNull() ?: ""
chapterData.chapterList?.let {
@@ -144,15 +131,8 @@ object BookChapterList {
).getStrResponse(bookSource.bookSourceUrl).body
?: throw Exception("${chapterData.nextUrl}, 下载失败")
val nextChapterData = analyzeChapterList(
- this,
- book,
- chapterData.nextUrl,
- chapterData.nextUrl,
- nextBody,
- tocRule,
- listRule,
- bookSource,
- false
+ this, book, chapterData.nextUrl, chapterData.nextUrl,
+ nextBody, tocRule, listRule, bookSource, false
)
synchronized(chapterDataList) {
val isFinished = addChapterListIsFinish(
diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt
index ab07ec9f2..63d892374 100644
--- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt
+++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt
@@ -71,6 +71,9 @@ object ReadBook {
appDb.bookSourceDao.getBookSource(book.origin)?.let {
bookSource = it
webBook = WebBook(it)
+ if (book.getImageStyle().isNullOrBlank()) {
+ book.setImageStyle(it.getContentRule().imageStyle)
+ }
} ?: let {
bookSource = null
webBook = null
@@ -413,7 +416,7 @@ object ReadBook {
durChapterIndex -> {
curTextChapter =
ChapterProvider.getTextChapter(
- book, chapter, contents, chapterSize, imageStyle
+ book, chapter, contents, chapterSize
)
if (upContent) callBack?.upContent(resetPageOffset = resetPageOffset)
callBack?.upView()
@@ -423,14 +426,14 @@ object ReadBook {
durChapterIndex - 1 -> {
prevTextChapter =
ChapterProvider.getTextChapter(
- book, chapter, contents, chapterSize, imageStyle
+ book, chapter, contents, chapterSize
)
if (upContent) callBack?.upContent(-1, resetPageOffset)
}
durChapterIndex + 1 -> {
nextTextChapter =
ChapterProvider.getTextChapter(
- book, chapter, contents, chapterSize, imageStyle
+ book, chapter, contents, chapterSize
)
if (upContent) callBack?.upContent(1, resetPageOffset)
}
@@ -444,8 +447,6 @@ object ReadBook {
}
}
- private val imageStyle get() = webBook?.bookSource?.ruleContent?.imageStyle
-
fun pageAnim(): Int {
book?.let {
return if (it.getPageAnim() < 0)
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 d51321812..6e24e5838 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
@@ -27,6 +27,7 @@ import io.legado.app.help.ReadBookConfig
import io.legado.app.help.ReadTipConfig
import io.legado.app.help.storage.Backup
import io.legado.app.lib.dialogs.alert
+import io.legado.app.lib.dialogs.selector
import io.legado.app.lib.theme.accentColor
import io.legado.app.receiver.TimeBatteryReceiver
import io.legado.app.service.BaseReadAloudService
@@ -253,6 +254,16 @@ class ReadBookActivity : ReadBookBaseActivity(),
viewModel.reverseContent(it)
}
R.id.menu_set_charset -> showCharsetConfig()
+ R.id.menu_image_style -> {
+ val imgStyles =
+ arrayListOf(Book.imgStyleDefault, Book.imgStyleFull, Book.imgStyleText)
+ selector(
+ R.string.image_style,
+ imgStyles
+ ) { _, index ->
+ ReadBook.book?.setImageStyle(imgStyles[index])
+ }
+ }
R.id.menu_get_progress -> ReadBook.book?.let {
viewModel.syncBookProgress(it) { progress ->
sureSyncProgress(progress)
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 a31833111..4f8ccbe21 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
@@ -81,7 +81,6 @@ object ChapterProvider {
bookChapter: BookChapter,
contents: List,
chapterSize: Int,
- imageStyle: String?,
): TextChapter {
val textPages = arrayListOf()
val stringBuilder = StringBuilder()
@@ -94,7 +93,7 @@ object ChapterProvider {
if (!book.isEpub()) {
val src = NetworkUtils.getAbsoluteURL(bookChapter.url, it)
durY = setTypeImage(
- book, bookChapter, src, durY, textPages, imageStyle
+ book, bookChapter, src, durY, textPages, book.getImageStyle()
)
}
}
@@ -142,9 +141,12 @@ object ChapterProvider {
var height = it.height
var width = it.width
when (imageStyle?.toUpperCase(Locale.ROOT)) {
- "FULL" -> {
+ Book.imgStyleFull -> {
width = visibleWidth
height = it.height * visibleWidth / it.width
+ }
+ Book.imgStyleText -> {
+
}
else -> {
if (it.width > visibleWidth) {
diff --git a/app/src/main/res/menu/book_read.xml b/app/src/main/res/menu/book_read.xml
index e2cdb3f45..bb713e388 100644
--- a/app/src/main/res/menu/book_read.xml
+++ b/app/src/main/res/menu/book_read.xml
@@ -92,6 +92,11 @@
android:checked="false"
app:showAsAction="never" />
+
+
- 调试
崩溃日志
使用自定义中文分行
+ 图片样式
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index 18a974a42..ab10dc901 100644
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -810,5 +810,6 @@
匯出到WebDav
反转内容
调试
+ 图片样式
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 9365bc626..f6bb78f34 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -812,5 +812,6 @@
调试
崩溃日志
使用自定义中文分行
+ 图片样式
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2c820a9a4..0e54cdc00 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -815,5 +815,6 @@
调试
崩溃日志
使用自定义中文分行
+ 图片样式