diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index f1302d091..0184b8688 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -37,7 +37,9 @@ data class BookSource( // 是否启用 var enabled: Boolean = true, // 启用发现 - var enabledExplore: Boolean = true, + var enabledExplore: Boolean = false, + // 启用段评 + var enabledReview: Boolean? = false, // 启用okhttp CookieJAr 自动保存每次请求的cookie @ColumnInfo(defaultValue = "0") override var enabledCookieJar: Boolean? = false, @@ -49,8 +51,6 @@ data class BookSource( override var loginUrl: String? = null, // 登录UI override var loginUi: String? = null, - // 启用段评 - var enabledReview: Boolean? = false, // 登录检测js var loginCheckJs: String? = null, // 注释 diff --git a/app/src/main/java/io/legado/app/data/entities/rule/ReviewRule.kt b/app/src/main/java/io/legado/app/data/entities/rule/ReviewRule.kt index 80bed45eb..2d2dc249c 100644 --- a/app/src/main/java/io/legado/app/data/entities/rule/ReviewRule.kt +++ b/app/src/main/java/io/legado/app/data/entities/rule/ReviewRule.kt @@ -9,10 +9,12 @@ data class ReviewRule( var avatarRule: String? = null, // 段评发布者头像 var contentRule: String? = null, // 段评内容 var postTimeRule: String? = null, // 段评发布时间 - var reviewReplyUrl: String? = null, // 获取段评回复URL + var reviewQuoteUrl: String? = null, // 获取段评回复URL // 这些功能将在以上功能完成以后实现 var voteUpUrl: String? = null, // 点赞URL var voteDownUrl: String? = null, // 点踩URL - var replyUrl: String? = null // 回复URL -): Parcelable \ No newline at end of file + var postReviewUrl: String? = null, // 发送回复URL + var postQuoteUrl: String? = null, // 发送回复段评URL + var deleteUrl: String? = null, // 删除段评URL +): Parcelable diff --git a/app/src/main/java/io/legado/app/help/SourceAnalyzer.kt b/app/src/main/java/io/legado/app/help/SourceAnalyzer.kt index 5fb5e8437..1efc4e86e 100644 --- a/app/src/main/java/io/legado/app/help/SourceAnalyzer.kt +++ b/app/src/main/java/io/legado/app/help/SourceAnalyzer.kt @@ -151,6 +151,7 @@ object SourceAnalyzer { source.enabled = sourceAny.enabled source.enabledExplore = sourceAny.enabledExplore source.enabledCookieJar = sourceAny.enabledCookieJar + source.enabledReview = sourceAny.enabledReview source.concurrentRate = sourceAny.concurrentRate source.header = sourceAny.header source.loginUrl = when (sourceAny.loginUrl) { @@ -205,6 +206,13 @@ object SourceAnalyzer { GSON.fromJsonObject(GSON.toJson(sourceAny.ruleContent)) .getOrNull() } + source.ruleReview = if (sourceAny.ruleReview is String) { + GSON.fromJsonObject(sourceAny.ruleReview.toString()) + .getOrNull() + } else { + GSON.fromJsonObject(GSON.toJson(sourceAny.ruleReview)) + .getOrNull() + } } source } @@ -220,13 +228,14 @@ object SourceAnalyzer { var customOrder: Int = 0, // 手动排序编号 var enabled: Boolean = true, // 是否启用 var enabledExplore: Boolean = true, // 启用发现 - var enabledCookieJar: Boolean = false, // 启用CookieJar + var enabledReview: Boolean = false, // 启用段评 + var enabledCookieJar: Boolean = false, // 启用CookieJar var concurrentRate: String? = null, // 并发率 var header: String? = null, // 请求头 var loginUrl: Any? = null, // 登录规则 var loginUi: Any? = null, // 登录UI - var loginCheckJs: String? = null, //登录检测js - var bookSourceComment: String? = "", //书源注释 + var loginCheckJs: String? = null, // 登录检测js + var bookSourceComment: String? = "", // 书源注释 var lastUpdateTime: Long = 0, // 最后更新时间,用于排序 var respondTime: Long = 180000L, // 响应时间,用于排序 var weight: Int = 0, // 智能排序的权重 @@ -236,7 +245,8 @@ object SourceAnalyzer { var ruleSearch: Any? = null, // 搜索规则 var ruleBookInfo: Any? = null, // 书籍信息页规则 var ruleToc: Any? = null, // 目录页规则 - var ruleContent: Any? = null // 正文页规则 + var ruleContent: Any? = null, // 正文页规则 + var ruleReview: Any? = null // 段评规则 ) // default规则适配 diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index da0d39aac..d733ca71e 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -41,10 +41,11 @@ class BookSourceEditActivity : private val adapter by lazy { BookSourceEditAdapter() } private val sourceEntities: ArrayList = ArrayList() private val searchEntities: ArrayList = ArrayList() - private val findEntities: ArrayList = ArrayList() + private val exploreEntities: ArrayList = ArrayList() private val infoEntities: ArrayList = ArrayList() private val tocEntities: ArrayList = ArrayList() private val contentEntities: ArrayList = ArrayList() + private val reviewEntities: ArrayList = ArrayList() private val qrCodeResult = registerForActivityResult(QrCodeResult()) { it ?: return@registerForActivityResult viewModel.importSource(it) { source -> @@ -180,10 +181,11 @@ class BookSourceEditActivity : private fun setEditEntities(tabPosition: Int?) { when (tabPosition) { 1 -> adapter.editEntities = searchEntities - 2 -> adapter.editEntities = findEntities + 2 -> adapter.editEntities = exploreEntities 3 -> adapter.editEntities = infoEntities 4 -> adapter.editEntities = tocEntities 5 -> adapter.editEntities = contentEntities + 6 -> adapter.editEntities = reviewEntities else -> adapter.editEntities = sourceEntities } binding.recyclerView.scrollToPosition(0) @@ -192,8 +194,9 @@ class BookSourceEditActivity : private fun upSourceView(source: BookSource? = viewModel.bookSource) { source?.let { binding.cbIsEnable.isChecked = it.enabled - binding.cbIsEnableFind.isChecked = it.enabledExplore + binding.cbIsEnableExplore.isChecked = it.enabledExplore binding.cbIsEnableCookie.isChecked = it.enabledCookieJar ?: false + binding.cbIsEnableReview.isChecked = it.enabledReview ?: false binding.spType.setSelection( when (it.bookSourceType) { BookType.file -> 3 @@ -203,7 +206,7 @@ class BookSourceEditActivity : } ) } - //基本信息 + // 基本信息 sourceEntities.clear() sourceEntities.apply { add(EditEntity("bookSourceUrl", source?.bookSourceUrl, R.string.source_url)) @@ -218,7 +221,7 @@ class BookSourceEditActivity : add(EditEntity("variableComment", source?.variableComment, R.string.variable_comment)) add(EditEntity("concurrentRate", source?.concurrentRate, R.string.concurrent_rate)) } - //搜索 + // 搜索 val sr = source?.getSearchRule() searchEntities.clear() searchEntities.apply { @@ -234,10 +237,10 @@ class BookSourceEditActivity : add(EditEntity("coverUrl", sr?.coverUrl, R.string.rule_cover_url)) add(EditEntity("bookUrl", sr?.bookUrl, R.string.r_book_url)) } - //发现 + // 发现 val er = source?.getExploreRule() - findEntities.clear() - findEntities.apply { + exploreEntities.clear() + exploreEntities.apply { add(EditEntity("exploreUrl", source?.exploreUrl, R.string.r_find_url)) add(EditEntity("bookList", er?.bookList, R.string.r_book_list)) add(EditEntity("name", er?.name, R.string.r_book_name)) @@ -249,7 +252,7 @@ class BookSourceEditActivity : add(EditEntity("coverUrl", er?.coverUrl, R.string.rule_cover_url)) add(EditEntity("bookUrl", er?.bookUrl, R.string.r_book_url)) } - //详情页 + // 详情页 val ir = source?.getBookInfoRule() infoEntities.clear() infoEntities.apply { @@ -265,7 +268,7 @@ class BookSourceEditActivity : add(EditEntity("canReName", ir?.canReName, R.string.rule_can_re_name)) add(EditEntity("downloadUrls", ir?.downloadUrls, R.string.download_url_rule)) } - //目录页 + // 目录页 val tr = source?.getTocRule() tocEntities.clear() tocEntities.apply { @@ -279,7 +282,7 @@ class BookSourceEditActivity : add(EditEntity("isPay", tr?.isPay, R.string.rule_is_pay)) add(EditEntity("nextTocUrl", tr?.nextTocUrl, R.string.rule_next_toc_url)) } - //正文页 + // 正文页 val cr = source?.getContentRule() contentEntities.clear() contentEntities.apply { @@ -291,6 +294,21 @@ class BookSourceEditActivity : add(EditEntity("imageStyle", cr?.imageStyle, R.string.rule_image_style)) add(EditEntity("payAction", cr?.payAction, R.string.rule_pay_action)) } + // 段评 + val rr = source?.getReviewRule() + reviewEntities.clear() + reviewEntities.apply { + add(EditEntity("reviewUrl", rr?.reviewUrl, R.string.rule_review_url)) + add(EditEntity("avatarRule", rr?.reviewUrl, R.string.rule_avatar)) + add(EditEntity("contentRule", rr?.contentRule, R.string.rule_review_content)) + add(EditEntity("postTimeRule", rr?.postTimeRule, R.string.rule_post_time)) + add(EditEntity("reviewQuoteUrl", rr?.reviewQuoteUrl, R.string.rule_review_quote)) + add(EditEntity("voteUpUrl", rr?.voteUpUrl, R.string.review_vote_up)) + add(EditEntity("voteDownUrl", rr?.voteDownUrl, R.string.review_vote_down)) + add(EditEntity("postReviewUrl", rr?.postReviewUrl, R.string.post_review_url)) + add(EditEntity("postQuoteUrl", rr?.postQuoteUrl, R.string.post_quote_url)) + add(EditEntity("deleteUrl", rr?.deleteUrl, R.string.delete_review_url)) + } binding.tabLayout.selectTab(binding.tabLayout.getTabAt(0)) setEditEntities(0) } @@ -298,8 +316,9 @@ class BookSourceEditActivity : private fun getSource(): BookSource { val source = viewModel.bookSource?.copy() ?: BookSource() source.enabled = binding.cbIsEnable.isChecked - source.enabledExplore = binding.cbIsEnableFind.isChecked + source.enabledExplore = binding.cbIsEnableExplore.isChecked source.enabledCookieJar = binding.cbIsEnableCookie.isChecked + source.enabledReview = binding.cbIsEnableReview.isChecked source.bookSourceType = when (binding.spType.selectedItemPosition) { 3 -> BookType.file 2 -> BookType.image @@ -311,6 +330,7 @@ class BookSourceEditActivity : val bookInfoRule = BookInfoRule() val tocRule = TocRule() val contentRule = ContentRule() + val reviewRule = ReviewRule() sourceEntities.forEach { when (it.key) { "bookSourceUrl" -> source.bookSourceUrl = it.value ?: "" @@ -351,7 +371,7 @@ class BookSourceEditActivity : viewModel.ruleComplete(it.value, searchRule.bookList, 2) } } - findEntities.forEach { + exploreEntities.forEach { when (it.key) { "exploreUrl" -> source.exploreUrl = it.value "bookList" -> exploreRule.bookList = it.value @@ -429,11 +449,30 @@ class BookSourceEditActivity : "payAction" -> contentRule.payAction = it.value } } + reviewEntities.forEach { + when (it.key) { + "reviewUrl" -> reviewRule.reviewUrl = it.value + "avatarRule" -> reviewRule.avatarRule = + viewModel.ruleComplete(it.value, reviewRule.reviewUrl, 3) + "contentRule" -> reviewRule.contentRule = + viewModel.ruleComplete(it.value, reviewRule.reviewUrl) + "postTimeRule" -> reviewRule.postTimeRule = + viewModel.ruleComplete(it.value, reviewRule.reviewUrl) + "reviewQuoteUrl" -> reviewRule.reviewQuoteUrl = + viewModel.ruleComplete(it.value, reviewRule.reviewUrl, 2) + "voteUpUrl" -> reviewRule.voteUpUrl = it.value + "voteDownUrl" -> reviewRule.voteDownUrl = it.value + "postReviewUrl" -> reviewRule.postReviewUrl = it.value + "postQuoteUrl" -> reviewRule.postQuoteUrl = it.value + "deleteUrl" -> reviewRule.deleteUrl =it.value + } + } source.ruleSearch = searchRule source.ruleExplore = exploreRule source.ruleBookInfo = bookInfoRule source.ruleToc = tocRule source.ruleContent = contentRule + source.ruleReview = reviewRule return source } diff --git a/app/src/main/res/layout/activity_book_source_edit.xml b/app/src/main/res/layout/activity_book_source_edit.xml index 4b6366974..bed6d5a36 100644 --- a/app/src/main/res/layout/activity_book_source_edit.xml +++ b/app/src/main/res/layout/activity_book_source_edit.xml @@ -27,7 +27,7 @@ android:text="@string/is_enable" /> + + 返回时提示放入书架 阅读未放入书架的书籍在返回时提示放入书架 Review + 段评URL(reviewUrl) + 段评发布者头像(avatarRule) + 段评内容(contentRule) + 段评回复URL(reviewQuoteUrl) + 段评发布时间(postTimeRule) + 点踩URL(voteUpUrl) + 点赞URL(voteDownUrl) + 发送回复URL(postReviewUrl) + 发送回复段评URL(postQuoteUrl) + 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index fad7b4f6d..dac88a90e 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1014,4 +1014,14 @@ 返回时提示放入书架 阅读未放入书架的书籍在返回时提示放入书架 Review + 段评URL(reviewUrl) + 段评发布者头像(avatarRule) + 段评内容(contentRule) + 段评发布时间(postTimeRule) + 段评回复URL(reviewQuoteUrl) + 点踩URL(voteUpUrl) + 点赞URL(voteDownUrl) + 发送回复URL(postReviewUrl) + 发送回复段评URL(postQuoteUrl) + 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 2f95b824a..dadd131f9 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1014,4 +1014,14 @@ 返回时提示放入书架 阅读未放入书架的书籍在返回时提示放入书架 Review + 段评URL(reviewUrl) + 段评发布者头像(avatarRule) + 段评内容(contentRule) + 段评发布时间(postTimeRule) + 段评回复URL(reviewQuoteUrl) + 点踩URL(voteUpUrl) + 点赞URL(voteDownUrl) + 发送回复URL(postReviewUrl) + 发送回复段评URL(postQuoteUrl) + 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index e44b8780d..21ab5348f 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1011,4 +1011,14 @@ 返回时提示放入书架 阅读未放入书架的书籍在返回时提示放入书架 段评 + 段评URL(reviewUrl) + 段评发布者头像(avatarRule) + 段评内容(contentRule) + 段评发布时间(postTimeRule) + 段评回复URL(reviewQuoteUrl) + 点踩URL(voteUpUrl) + 点赞URL(voteDownUrl) + 发送回复URL(postReviewUrl) + 发送回复段评URL(postQuoteUrl) + 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 811ef3d55..8d77a5605 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1013,4 +1013,14 @@ 返回时提示放入书架 阅读未放入书架的书籍在返回时提示放入书架 段评 + 段评URL(reviewUrl) + 段评发布者头像(avatarRule) + 段评内容(contentRule) + 段评发布时间(postTimeRule) + 段评回复URL(reviewQuoteUrl) + 点踩URL(voteUpUrl) + 点赞URL(voteDownUrl) + 发送回复URL(postReviewUrl) + 发送回复段评URL(postQuoteUrl) + 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 8fddc6150..02a44245a 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1013,4 +1013,14 @@ 返回时提示放入书架 阅读未放入书架的书籍在返回时提示放入书架 段评 + 段评URL(reviewUrl) + 段评发布者头像(avatarRule) + 段评内容(contentRule) + 段评发布时间(postTimeRule) + 段评回复URL(reviewQuoteUrl) + 点踩URL(voteUpUrl) + 点赞URL(voteDownUrl) + 发送回复URL(postReviewUrl) + 发送回复段评URL(postQuoteUrl) + 删除段评URL(deleteUrl) diff --git a/app/src/main/res/values/non_translat.xml b/app/src/main/res/values/non_translat.xml index 14d5c13bd..2b6917391 100644 --- a/app/src/main/res/values/non_translat.xml +++ b/app/src/main/res/values/non_translat.xml @@ -1,25 +1,25 @@ - bookshelf_px - 开源阅读 - kunfei.ge@gmail.com + bookshelf_px + 开源阅读 + kunfei.ge@gmail.com - https://alanskycn.gitee.io/teachme/ - https://github.com/gedoor/legado - https://github.com/gedoor/legado/graphs/contributors - https://gedoor.github.io - https://github.com/gedoor/legado/blob/master/LICENSE - https://github.com/gedoor/legado/releases/latest - https://api.github.com/repos/gedoor/legado/releases/latest - https://t.me/legado_channels - https://discord.gg/qDE52P5xGW + https://alanskycn.gitee.io/teachme/ + https://github.com/gedoor/legado + https://github.com/gedoor/legado/graphs/contributors + https://gedoor.github.io + https://github.com/gedoor/legado/blob/master/LICENSE + https://github.com/gedoor/legado/releases/latest + https://api.github.com/repos/gedoor/legado/releases/latest + https://t.me/legado_channels + https://discord.gg/qDE52P5xGW - http://%1$s:%2$d - GitHub - 【%s】 - 🔒%s - 🔓%s + http://%1$s:%2$d + GitHub + 【%s】 + 🔒%s + 🔓%s - + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a5e5b0889..60b8bb72c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1014,4 +1014,14 @@ 返回时提示放入书架 阅读未放入书架的书籍在返回时提示放入书架 Review + 段评发布者头像(avatarRule) + 段评URL(reviewUrl) + 段评内容(contentRule) + 段评发布时间(postTimeRule) + 段评回复URL(reviewQuoteUrl) + 点踩URL(voteUpUrl) + 点赞URL(voteDownUrl) + 发送回复URL(postReviewUrl) + 发送回复段评URL(postQuoteUrl) + 删除段评URL(deleteUrl)