mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
afe41b4c99
@ -250,6 +250,11 @@
|
|||||||
<textarea rows="1" id="ruleToc_chapterUrl" class="ruleToc" title="chapterUrl"
|
<textarea rows="1" id="ruleToc_chapterUrl" class="ruleToc" title="chapterUrl"
|
||||||
placeholder="选择章节链接 (规则结果为String类型的Url)"></textarea>
|
placeholder="选择章节链接 (规则结果为String类型的Url)"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<div>Volume标识:</div>
|
||||||
|
<textarea rows="1" id="ruleToc_isVolume" class="ruleToc" title="isVolume"
|
||||||
|
placeholder="章节名称是否是卷名 (规则结果为Bool)"></textarea>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div>收费标识:</div>
|
<div>收费标识:</div>
|
||||||
<textarea rows="1" id="ruleToc_isVip" class="ruleToc" title="isVip"
|
<textarea rows="1" id="ruleToc_isVip" class="ruleToc" title="isVip"
|
||||||
|
@ -16,7 +16,7 @@ val appDb by lazy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
version = 42,
|
version = 43,
|
||||||
exportSchema = true,
|
exportSchema = true,
|
||||||
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
|
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
|
||||||
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
|
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
|
||||||
|
@ -38,7 +38,8 @@ object DatabaseMigrations {
|
|||||||
migration_38_39,
|
migration_38_39,
|
||||||
migration_39_40,
|
migration_39_40,
|
||||||
migration_40_41,
|
migration_40_41,
|
||||||
migration_41_42
|
migration_41_42,
|
||||||
|
migration_42_43
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,4 +337,10 @@ object DatabaseMigrations {
|
|||||||
database.execSQL("ALTER TABLE 'httpTTS' ADD `contentType` TEXT")
|
database.execSQL("ALTER TABLE 'httpTTS' ADD `contentType` TEXT")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val migration_42_43 = object : Migration(42, 43) {
|
||||||
|
override fun migrate(database: SupportSQLiteDatabase) {
|
||||||
|
database.execSQL("ALTER TABLE `chapters` ADD `isVolume` INTEGER NOT NULL DEFAULT 0")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -33,6 +33,7 @@ import splitties.init.appCtx
|
|||||||
data class BookChapter(
|
data class BookChapter(
|
||||||
var url: String = "", // 章节地址
|
var url: String = "", // 章节地址
|
||||||
var title: String = "", // 章节标题
|
var title: String = "", // 章节标题
|
||||||
|
var isVolume: Boolean = false, // 是否是卷名
|
||||||
var baseUrl: String = "", // 用来拼接相对url
|
var baseUrl: String = "", // 用来拼接相对url
|
||||||
var bookUrl: String = "", // 书籍地址
|
var bookUrl: String = "", // 书籍地址
|
||||||
var index: Int = 0, // 章节序号
|
var index: Int = 0, // 章节序号
|
||||||
|
@ -8,6 +8,7 @@ data class TocRule(
|
|||||||
var chapterList: String? = null,
|
var chapterList: String? = null,
|
||||||
var chapterName: String? = null,
|
var chapterName: String? = null,
|
||||||
var chapterUrl: String? = null,
|
var chapterUrl: String? = null,
|
||||||
|
var isVolume: String? = null,
|
||||||
var isVip: String? = null,
|
var isVip: String? = null,
|
||||||
var isPay: String? = null,
|
var isPay: String? = null,
|
||||||
var updateTime: String? = null,
|
var updateTime: String? = null,
|
||||||
|
@ -2,6 +2,7 @@ package io.legado.app.lib.theme
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.annotation.AttrRes
|
import androidx.annotation.AttrRes
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Aidan Follestad (afollestad)
|
* @author Aidan Follestad (afollestad)
|
||||||
@ -31,4 +32,14 @@ object ThemeUtils {
|
|||||||
a.recycle()
|
a.recycle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmOverloads
|
||||||
|
fun resolveDrawable(context: Context, @AttrRes attr: Int): Drawable? {
|
||||||
|
val a = context.theme.obtainStyledAttributes(intArrayOf(attr))
|
||||||
|
return try {
|
||||||
|
a.getDrawable(0)
|
||||||
|
} finally {
|
||||||
|
a.recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -177,6 +177,7 @@ object BookChapterList {
|
|||||||
val vipRule = analyzeRule.splitSourceRule(tocRule.isVip)
|
val vipRule = analyzeRule.splitSourceRule(tocRule.isVip)
|
||||||
val payRule = analyzeRule.splitSourceRule(tocRule.isPay)
|
val payRule = analyzeRule.splitSourceRule(tocRule.isPay)
|
||||||
val upTimeRule = analyzeRule.splitSourceRule(tocRule.updateTime)
|
val upTimeRule = analyzeRule.splitSourceRule(tocRule.updateTime)
|
||||||
|
val isVolumeRule = analyzeRule.splitSourceRule(tocRule.isVolume)
|
||||||
elements.forEachIndexed { index, item ->
|
elements.forEachIndexed { index, item ->
|
||||||
scope.ensureActive()
|
scope.ensureActive()
|
||||||
analyzeRule.setContent(item)
|
analyzeRule.setContent(item)
|
||||||
@ -185,10 +186,20 @@ object BookChapterList {
|
|||||||
bookChapter.title = analyzeRule.getString(nameRule)
|
bookChapter.title = analyzeRule.getString(nameRule)
|
||||||
bookChapter.url = analyzeRule.getString(urlRule)
|
bookChapter.url = analyzeRule.getString(urlRule)
|
||||||
bookChapter.tag = analyzeRule.getString(upTimeRule)
|
bookChapter.tag = analyzeRule.getString(upTimeRule)
|
||||||
|
val isVolume = analyzeRule.getString(isVolumeRule)
|
||||||
|
bookChapter.isVolume = false
|
||||||
|
if (isVolume.isNotEmpty() && !isVolume.matches(falseRegex)) {
|
||||||
|
bookChapter.isVolume = true
|
||||||
|
}
|
||||||
if (bookChapter.url.isEmpty()) {
|
if (bookChapter.url.isEmpty()) {
|
||||||
|
if (bookChapter.isVolume) {
|
||||||
|
bookChapter.url = bookChapter.title
|
||||||
|
Debug.log(bookSource.bookSourceUrl, "目录${index}(Volume)未获取到url,使用章节标题替代")
|
||||||
|
} else {
|
||||||
bookChapter.url = baseUrl
|
bookChapter.url = baseUrl
|
||||||
Debug.log(bookSource.bookSourceUrl, "目录${index}未获取到url,使用baseUrl替代")
|
Debug.log(bookSource.bookSourceUrl, "目录${index}未获取到url,使用baseUrl替代")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (bookChapter.title.isNotEmpty()) {
|
if (bookChapter.title.isNotEmpty()) {
|
||||||
val isVip = analyzeRule.getString(vipRule)
|
val isVip = analyzeRule.getString(vipRule)
|
||||||
val isPay = analyzeRule.getString(payRule)
|
val isPay = analyzeRule.getString(payRule)
|
||||||
|
@ -261,6 +261,8 @@ object WebBook {
|
|||||||
Debug.log(bookSource.bookSourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}")
|
Debug.log(bookSource.bookSourceUrl, "⇒正文规则为空,使用章节链接:${bookChapter.url}")
|
||||||
return bookChapter.url
|
return bookChapter.url
|
||||||
}
|
}
|
||||||
|
//章节名为卷名时 且 章节url没获取到,返回空白
|
||||||
|
if(bookChapter.isVolume && bookChapter.url == bookChapter.title) return ""
|
||||||
return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) {
|
return if (bookChapter.url == book.bookUrl && !book.tocHtml.isNullOrEmpty()) {
|
||||||
BookContent.analyzeContent(
|
BookContent.analyzeContent(
|
||||||
scope = scope,
|
scope = scope,
|
||||||
|
@ -566,6 +566,7 @@ object ChapterProvider {
|
|||||||
tPaint.typeface = titleFont
|
tPaint.typeface = titleFont
|
||||||
tPaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat()
|
tPaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat()
|
||||||
tPaint.isAntiAlias = true
|
tPaint.isAntiAlias = true
|
||||||
|
//to do:卷名的标题排版
|
||||||
val cPaint = TextPaint()
|
val cPaint = TextPaint()
|
||||||
cPaint.color = ReadBookConfig.textColor
|
cPaint.color = ReadBookConfig.textColor
|
||||||
cPaint.letterSpacing = ReadBookConfig.letterSpacing
|
cPaint.letterSpacing = ReadBookConfig.letterSpacing
|
||||||
|
@ -265,6 +265,7 @@ class BookSourceEditActivity :
|
|||||||
add(EditEntity("chapterList", tr?.chapterList, R.string.rule_chapter_list))
|
add(EditEntity("chapterList", tr?.chapterList, R.string.rule_chapter_list))
|
||||||
add(EditEntity("chapterName", tr?.chapterName, R.string.rule_chapter_name))
|
add(EditEntity("chapterName", tr?.chapterName, R.string.rule_chapter_name))
|
||||||
add(EditEntity("chapterUrl", tr?.chapterUrl, R.string.rule_chapter_url))
|
add(EditEntity("chapterUrl", tr?.chapterUrl, R.string.rule_chapter_url))
|
||||||
|
add(EditEntity("isVolume", tr?.isVolume, R.string.rule_is_volume))
|
||||||
add(EditEntity("updateTime", tr?.updateTime, R.string.rule_update_time))
|
add(EditEntity("updateTime", tr?.updateTime, R.string.rule_update_time))
|
||||||
add(EditEntity("isVip", tr?.isVip, R.string.rule_is_vip))
|
add(EditEntity("isVip", tr?.isVip, R.string.rule_is_vip))
|
||||||
add(EditEntity("isPay", tr?.isPay, R.string.rule_is_pay))
|
add(EditEntity("isPay", tr?.isPay, R.string.rule_is_pay))
|
||||||
@ -360,6 +361,7 @@ class BookSourceEditActivity :
|
|||||||
"chapterList" -> tocRule.chapterList = it.value
|
"chapterList" -> tocRule.chapterList = it.value
|
||||||
"chapterName" -> tocRule.chapterName = it.value
|
"chapterName" -> tocRule.chapterName = it.value
|
||||||
"chapterUrl" -> tocRule.chapterUrl = it.value
|
"chapterUrl" -> tocRule.chapterUrl = it.value
|
||||||
|
"isVolume" -> tocRule.isVolume = it.value
|
||||||
"updateTime" -> tocRule.updateTime = it.value
|
"updateTime" -> tocRule.updateTime = it.value
|
||||||
"isVip" -> tocRule.isVip = it.value
|
"isVip" -> tocRule.isVip = it.value
|
||||||
"isPay" -> tocRule.isPay = it.value
|
"isPay" -> tocRule.isPay = it.value
|
||||||
|
@ -9,10 +9,12 @@ import io.legado.app.base.adapter.RecyclerAdapter
|
|||||||
import io.legado.app.data.entities.BookChapter
|
import io.legado.app.data.entities.BookChapter
|
||||||
import io.legado.app.databinding.ItemChapterListBinding
|
import io.legado.app.databinding.ItemChapterListBinding
|
||||||
import io.legado.app.lib.theme.accentColor
|
import io.legado.app.lib.theme.accentColor
|
||||||
|
import io.legado.app.lib.theme.backgroundColor
|
||||||
|
import io.legado.app.lib.theme.ThemeUtils
|
||||||
|
import io.legado.app.help.AppConfig
|
||||||
import io.legado.app.utils.getCompatColor
|
import io.legado.app.utils.getCompatColor
|
||||||
import io.legado.app.utils.visible
|
import io.legado.app.utils.visible
|
||||||
|
|
||||||
|
|
||||||
class ChapterListAdapter(context: Context, val callback: Callback) :
|
class ChapterListAdapter(context: Context, val callback: Callback) :
|
||||||
RecyclerAdapter<BookChapter, ItemChapterListBinding>(context) {
|
RecyclerAdapter<BookChapter, ItemChapterListBinding>(context) {
|
||||||
|
|
||||||
@ -30,6 +32,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
|
|||||||
&& oldItem.isPay == newItem.isPay
|
&& oldItem.isPay == newItem.isPay
|
||||||
&& oldItem.title == newItem.title
|
&& oldItem.title == newItem.title
|
||||||
&& oldItem.tag == newItem.tag
|
&& oldItem.tag == newItem.tag
|
||||||
|
&& oldItem.isVolume == newItem.isVolume
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -54,7 +57,15 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
|
|||||||
tvChapterName.setTextColor(context.getCompatColor(R.color.primaryText))
|
tvChapterName.setTextColor(context.getCompatColor(R.color.primaryText))
|
||||||
}
|
}
|
||||||
tvChapterName.text = item.getDisplayTitle()
|
tvChapterName.text = item.getDisplayTitle()
|
||||||
if (!item.tag.isNullOrEmpty()) {
|
if (item.isVolume) {
|
||||||
|
//卷名,如第一卷 突出显示
|
||||||
|
tvChapterItem.setBackgroundColor(context.getCompatColor(R.color.btn_bg_press))
|
||||||
|
} else {
|
||||||
|
//普通章节 保持不变
|
||||||
|
tvChapterItem.setBackground(ThemeUtils.resolveDrawable(context, android.R.attr.selectableItemBackground))
|
||||||
|
}
|
||||||
|
if (!item.tag.isNullOrEmpty() && !item.isVolume) {
|
||||||
|
//卷名不显示tag(更新时间规则)
|
||||||
tvTag.text = item.tag
|
tvTag.text = item.tag
|
||||||
tvTag.visible()
|
tvTag.visible()
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,7 @@ object NetworkUtils {
|
|||||||
fun getAbsoluteURL(baseURL: String?, relativePath: String): String {
|
fun getAbsoluteURL(baseURL: String?, relativePath: String): String {
|
||||||
if (baseURL.isNullOrEmpty()) return relativePath
|
if (baseURL.isNullOrEmpty()) return relativePath
|
||||||
if (relativePath.isAbsUrl()) return relativePath
|
if (relativePath.isAbsUrl()) return relativePath
|
||||||
|
if (relativePath.startsWith("javascript")) return ""
|
||||||
var relativeUrl = relativePath
|
var relativeUrl = relativePath
|
||||||
try {
|
try {
|
||||||
val absoluteUrl = URL(baseURL.substringBefore(","))
|
val absoluteUrl = URL(baseURL.substringBefore(","))
|
||||||
@ -126,6 +127,7 @@ object NetworkUtils {
|
|||||||
*/
|
*/
|
||||||
fun getAbsoluteURL(baseURL: URL?, relativePath: String): String {
|
fun getAbsoluteURL(baseURL: URL?, relativePath: String): String {
|
||||||
if (baseURL == null) return relativePath
|
if (baseURL == null) return relativePath
|
||||||
|
if (relativePath.startsWith("javascript")) return ""
|
||||||
var relativeUrl = relativePath
|
var relativeUrl = relativePath
|
||||||
try {
|
try {
|
||||||
val parseUrl = URL(baseURL, relativePath)
|
val parseUrl = URL(baseURL, relativePath)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/tv_chapter_item"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
@ -414,6 +414,7 @@
|
|||||||
<string name="rule_chapter_list">目录列表规则(chapterList)</string>
|
<string name="rule_chapter_list">目录列表规则(chapterList)</string>
|
||||||
<string name="rule_chapter_name">章节名称规则(ChapterName)</string>
|
<string name="rule_chapter_name">章节名称规则(ChapterName)</string>
|
||||||
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
|
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
|
||||||
|
<string name="rule_is_volume">Volume mark(isVolume)</string>
|
||||||
<string name="rule_is_vip">VIP标识(isVip)</string>
|
<string name="rule_is_vip">VIP标识(isVip)</string>
|
||||||
<string name="rule_update_time">更新时间(ChapterInfo)</string>
|
<string name="rule_update_time">更新时间(ChapterInfo)</string>
|
||||||
<string name="rule_book_content">正文规则(content)</string>
|
<string name="rule_book_content">正文规则(content)</string>
|
||||||
|
@ -418,6 +418,7 @@
|
|||||||
<string name="rule_chapter_list">目录列表规则(chapterList)</string>
|
<string name="rule_chapter_list">目录列表规则(chapterList)</string>
|
||||||
<string name="rule_chapter_name">章节名称规则(ChapterName)</string>
|
<string name="rule_chapter_name">章节名称规则(ChapterName)</string>
|
||||||
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
|
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
|
||||||
|
<string name="rule_is_volume">Volume mark(isVolume)</string>
|
||||||
<string name="rule_is_vip">VIP标识(isVip)</string>
|
<string name="rule_is_vip">VIP标识(isVip)</string>
|
||||||
<string name="rule_update_time">更新时间(ChapterInfo)</string>
|
<string name="rule_update_time">更新时间(ChapterInfo)</string>
|
||||||
<string name="rule_book_content">正文规则(content)</string>
|
<string name="rule_book_content">正文规则(content)</string>
|
||||||
|
@ -413,6 +413,7 @@
|
|||||||
<string name="rule_chapter_list">目錄列表規則 (chapterList)</string>
|
<string name="rule_chapter_list">目錄列表規則 (chapterList)</string>
|
||||||
<string name="rule_chapter_name">章節名稱規則 (ChapterName)</string>
|
<string name="rule_chapter_name">章節名稱規則 (ChapterName)</string>
|
||||||
<string name="rule_chapter_url">章節 URL 規則 (chapterUrl)</string>
|
<string name="rule_chapter_url">章節 URL 規則 (chapterUrl)</string>
|
||||||
|
<string name="rule_is_volume">Volume標識(isVolume)</string>
|
||||||
<string name="rule_is_vip">VIP 標識 (isVip)</string>
|
<string name="rule_is_vip">VIP 標識 (isVip)</string>
|
||||||
<string name="rule_update_time">更新時間 (ChapterInfo)</string>
|
<string name="rule_update_time">更新時間 (ChapterInfo)</string>
|
||||||
<string name="rule_book_content">正文規則 (content)</string>
|
<string name="rule_book_content">正文規則 (content)</string>
|
||||||
|
@ -417,6 +417,7 @@
|
|||||||
<string name="rule_chapter_list">目錄列表規則(chapterList)</string>
|
<string name="rule_chapter_list">目錄列表規則(chapterList)</string>
|
||||||
<string name="rule_chapter_name">章節名稱規則(ChapterName)</string>
|
<string name="rule_chapter_name">章節名稱規則(ChapterName)</string>
|
||||||
<string name="rule_chapter_url">章節URL規則(chapterUrl)</string>
|
<string name="rule_chapter_url">章節URL規則(chapterUrl)</string>
|
||||||
|
<string name="rule_is_volume">Volume標識(isVolume)</string>
|
||||||
<string name="rule_is_vip">VIP標識(isVip)</string>
|
<string name="rule_is_vip">VIP標識(isVip)</string>
|
||||||
<string name="rule_update_time">更新時間(ChapterInfo)</string>
|
<string name="rule_update_time">更新時間(ChapterInfo)</string>
|
||||||
<string name="rule_book_content">正文規則(content)</string>
|
<string name="rule_book_content">正文規則(content)</string>
|
||||||
|
@ -417,6 +417,7 @@
|
|||||||
<string name="rule_chapter_list">目录列表规则(chapterList)</string>
|
<string name="rule_chapter_list">目录列表规则(chapterList)</string>
|
||||||
<string name="rule_chapter_name">章节名称规则(ChapterName)</string>
|
<string name="rule_chapter_name">章节名称规则(ChapterName)</string>
|
||||||
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
|
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
|
||||||
|
<string name="rule_is_volume">Volume标识(isVolume)</string>
|
||||||
<string name="rule_is_vip">VIP标识(isVip)</string>
|
<string name="rule_is_vip">VIP标识(isVip)</string>
|
||||||
<string name="rule_update_time">更新时间(ChapterInfo)</string>
|
<string name="rule_update_time">更新时间(ChapterInfo)</string>
|
||||||
<string name="rule_book_content">正文规则(content)</string>
|
<string name="rule_book_content">正文规则(content)</string>
|
||||||
|
@ -418,6 +418,7 @@
|
|||||||
<string name="rule_chapter_list">目录列表规则(chapterList)</string>
|
<string name="rule_chapter_list">目录列表规则(chapterList)</string>
|
||||||
<string name="rule_chapter_name">章节名称规则(ChapterName)</string>
|
<string name="rule_chapter_name">章节名称规则(ChapterName)</string>
|
||||||
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
|
<string name="rule_chapter_url">章节URL规则(chapterUrl)</string>
|
||||||
|
<string name="rule_is_volume">Volume标识(isVolume)</string>
|
||||||
<string name="rule_is_vip">VIP标识(isVip)</string>
|
<string name="rule_is_vip">VIP标识(isVip)</string>
|
||||||
<string name="rule_update_time">更新时间(ChapterInfo)</string>
|
<string name="rule_update_time">更新时间(ChapterInfo)</string>
|
||||||
<string name="rule_book_content">正文规则(content)</string>
|
<string name="rule_book_content">正文规则(content)</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user