完成段评编辑页面,修复了一些不统一的命名

pull/2250/head
Seidko 2 years ago
parent 24838b0676
commit 15bae4b00a
  1. 6
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  2. 6
      app/src/main/java/io/legado/app/data/entities/rule/ReviewRule.kt
  3. 18
      app/src/main/java/io/legado/app/help/SourceAnalyzer.kt
  4. 65
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  5. 7
      app/src/main/res/layout/activity_book_source_edit.xml
  6. 10
      app/src/main/res/values-es-rES/strings.xml
  7. 10
      app/src/main/res/values-ja-rJP/strings.xml
  8. 10
      app/src/main/res/values-pt-rBR/strings.xml
  9. 10
      app/src/main/res/values-zh-rHK/strings.xml
  10. 10
      app/src/main/res/values-zh-rTW/strings.xml
  11. 10
      app/src/main/res/values-zh/strings.xml
  12. 36
      app/src/main/res/values/non_translat.xml
  13. 10
      app/src/main/res/values/strings.xml

@ -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,
// 注释

@ -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
var postReviewUrl: String? = null, // 发送回复URL
var postQuoteUrl: String? = null, // 发送回复段评URL
var deleteUrl: String? = null, // 删除段评URL
): Parcelable

@ -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<ContentRule>(GSON.toJson(sourceAny.ruleContent))
.getOrNull()
}
source.ruleReview = if (sourceAny.ruleReview is String) {
GSON.fromJsonObject<ReviewRule>(sourceAny.ruleReview.toString())
.getOrNull()
} else {
GSON.fromJsonObject<ReviewRule>(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规则适配

@ -41,10 +41,11 @@ class BookSourceEditActivity :
private val adapter by lazy { BookSourceEditAdapter() }
private val sourceEntities: ArrayList<EditEntity> = ArrayList()
private val searchEntities: ArrayList<EditEntity> = ArrayList()
private val findEntities: ArrayList<EditEntity> = ArrayList()
private val exploreEntities: ArrayList<EditEntity> = ArrayList()
private val infoEntities: ArrayList<EditEntity> = ArrayList()
private val tocEntities: ArrayList<EditEntity> = ArrayList()
private val contentEntities: ArrayList<EditEntity> = ArrayList()
private val reviewEntities: ArrayList<EditEntity> = 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
}

@ -27,7 +27,7 @@
android:text="@string/is_enable" />
<io.legado.app.lib.theme.view.ThemeCheckBox
android:id="@+id/cb_is_enable_find"
android:id="@+id/cb_is_enable_explore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
@ -109,6 +109,11 @@
android:layout_height="wrap_content"
android:text="@string/source_tab_content" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/review" />
</com.google.android.material.tabs.TabLayout>
<androidx.recyclerview.widget.RecyclerView

@ -1011,4 +1011,14 @@
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">Review</string>
<string name="rule_review_url">段评URL(reviewUrl)</string>
<string name="rule_avatar">段评发布者头像(avatarRule)</string>
<string name="rule_review_content">段评内容(contentRule)</string>
<string name="rule_review_quote">段评回复URL(reviewQuoteUrl)</string>
<string name="rule_post_time">段评发布时间(postTimeRule)</string>
<string name="review_vote_down">点踩URL(voteUpUrl)</string>
<string name="review_vote_up">点赞URL(voteDownUrl)</string>
<string name="post_review_url">发送回复URL(postReviewUrl)</string>
<string name="post_quote_url">发送回复段评URL(postQuoteUrl)</string>
<string name="delete_review_url">删除段评URL(deleteUrl)</string>
</resources>

@ -1014,4 +1014,14 @@
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">Review</string>
<string name="rule_review_url">段评URL(reviewUrl)</string>
<string name="rule_avatar">段评发布者头像(avatarRule)</string>
<string name="rule_review_content">段评内容(contentRule)</string>
<string name="rule_post_time">段评发布时间(postTimeRule)</string>
<string name="rule_review_quote">段评回复URL(reviewQuoteUrl)</string>
<string name="review_vote_down">点踩URL(voteUpUrl)</string>
<string name="review_vote_up">点赞URL(voteDownUrl)</string>
<string name="post_review_url">发送回复URL(postReviewUrl)</string>
<string name="post_quote_url">发送回复段评URL(postQuoteUrl)</string>
<string name="delete_review_url">删除段评URL(deleteUrl)</string>
</resources>

@ -1014,4 +1014,14 @@
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">Review</string>
<string name="rule_review_url">段评URL(reviewUrl)</string>
<string name="rule_avatar">段评发布者头像(avatarRule)</string>
<string name="rule_review_content">段评内容(contentRule)</string>
<string name="rule_post_time">段评发布时间(postTimeRule)</string>
<string name="rule_review_quote">段评回复URL(reviewQuoteUrl)</string>
<string name="review_vote_down">点踩URL(voteUpUrl)</string>
<string name="review_vote_up">点赞URL(voteDownUrl)</string>
<string name="post_review_url">发送回复URL(postReviewUrl)</string>
<string name="post_quote_url">发送回复段评URL(postQuoteUrl)</string>
<string name="delete_review_url">删除段评URL(deleteUrl)</string>
</resources>

@ -1011,4 +1011,14 @@
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">段评</string>
<string name="rule_review_url">段评URL(reviewUrl)</string>
<string name="rule_avatar">段评发布者头像(avatarRule)</string>
<string name="rule_review_content">段评内容(contentRule)</string>
<string name="rule_post_time">段评发布时间(postTimeRule)</string>
<string name="rule_review_quote">段评回复URL(reviewQuoteUrl)</string>
<string name="review_vote_down">点踩URL(voteUpUrl)</string>
<string name="review_vote_up">点赞URL(voteDownUrl)</string>
<string name="post_review_url">发送回复URL(postReviewUrl)</string>
<string name="post_quote_url">发送回复段评URL(postQuoteUrl)</string>
<string name="delete_review_url">删除段评URL(deleteUrl)</string>
</resources>

@ -1013,4 +1013,14 @@
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">段评</string>
<string name="rule_review_url">段评URL(reviewUrl)</string>
<string name="rule_avatar">段评发布者头像(avatarRule)</string>
<string name="rule_review_content">段评内容(contentRule)</string>
<string name="rule_post_time">段评发布时间(postTimeRule)</string>
<string name="rule_review_quote">段评回复URL(reviewQuoteUrl)</string>
<string name="review_vote_down">点踩URL(voteUpUrl)</string>
<string name="review_vote_up">点赞URL(voteDownUrl)</string>
<string name="post_review_url">发送回复URL(postReviewUrl)</string>
<string name="post_quote_url">发送回复段评URL(postQuoteUrl)</string>
<string name="delete_review_url">删除段评URL(deleteUrl)</string>
</resources>

@ -1013,4 +1013,14 @@
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">段评</string>
<string name="rule_review_url">段评URL(reviewUrl)</string>
<string name="rule_avatar">段评发布者头像(avatarRule)</string>
<string name="rule_review_content">段评内容(contentRule)</string>
<string name="rule_post_time">段评发布时间(postTimeRule)</string>
<string name="rule_review_quote">段评回复URL(reviewQuoteUrl)</string>
<string name="review_vote_down">点踩URL(voteUpUrl)</string>
<string name="review_vote_up">点赞URL(voteDownUrl)</string>
<string name="post_review_url">发送回复URL(postReviewUrl)</string>
<string name="post_quote_url">发送回复段评URL(postQuoteUrl)</string>
<string name="delete_review_url">删除段评URL(deleteUrl)</string>
</resources>

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
<string name="pk_bookshelf_px">bookshelf_px</string>
<string name="legado_gzh">开源阅读</string>
<string name="email">kunfei.ge@gmail.com</string>
<string name="pk_bookshelf_px" translatable="false">bookshelf_px</string>
<string name="legado_gzh" translatable="false">开源阅读</string>
<string name="email" translatable="false">kunfei.ge@gmail.com</string>
<string name="source_rule_url">https://alanskycn.gitee.io/teachme/</string>
<string name="this_github_url">https://github.com/gedoor/legado</string>
<string name="contributors_url">https://github.com/gedoor/legado/graphs/contributors</string>
<string name="home_page_url">https://gedoor.github.io</string>
<string name="license_url">https://github.com/gedoor/legado/blob/master/LICENSE</string>
<string name="latest_release_url">https://github.com/gedoor/legado/releases/latest</string>
<string name="latest_release_api">https://api.github.com/repos/gedoor/legado/releases/latest</string>
<string name="tg_url">https://t.me/legado_channels</string>
<string name="discord_url">https://discord.gg/qDE52P5xGW</string>
<string name="source_rule_url" translatable="false">https://alanskycn.gitee.io/teachme/</string>
<string name="this_github_url" translatable="false">https://github.com/gedoor/legado</string>
<string name="contributors_url" translatable="false">https://github.com/gedoor/legado/graphs/contributors</string>
<string name="home_page_url" translatable="false">https://gedoor.github.io</string>
<string name="license_url" translatable="false">https://github.com/gedoor/legado/blob/master/LICENSE</string>
<string name="latest_release_url" translatable="false">https://github.com/gedoor/legado/releases/latest</string>
<string name="latest_release_api" translatable="false">https://api.github.com/repos/gedoor/legado/releases/latest</string>
<string name="tg_url" translatable="false">https://t.me/legado_channels</string>
<string name="discord_url" translatable="false">https://discord.gg/qDE52P5xGW</string>
<string name="http_ip">http://%1$s:%2$d</string>
<string name="git_hub">GitHub</string>
<string name="diy_edit_source_group_title">【%s】</string>
<string name="vip_title">🔒%s</string>
<string name="payed_title">🔓%s</string>
<string name="http_ip" translatable="false">http://%1$s:%2$d</string>
<string name="git_hub" translatable="false">GitHub</string>
<string name="diy_edit_source_group_title" translatable="false">【%s】</string>
<string name="vip_title" translatable="false">🔒%s</string>
<string name="payed_title" translatable="false">🔓%s</string>
<string name="separator"></string>
<string name="separator" translatable="false"></string>
</resources>

@ -1014,4 +1014,14 @@
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">Review</string>
<string name="rule_avatar">段评发布者头像(avatarRule)</string>
<string name="rule_review_url">段评URL(reviewUrl)</string>
<string name="rule_review_content">段评内容(contentRule)</string>
<string name="rule_post_time">段评发布时间(postTimeRule)</string>
<string name="rule_review_quote">段评回复URL(reviewQuoteUrl)</string>
<string name="review_vote_down">点踩URL(voteUpUrl)</string>
<string name="review_vote_up">点赞URL(voteDownUrl)</string>
<string name="post_review_url">发送回复URL(postReviewUrl)</string>
<string name="post_quote_url">发送回复段评URL(postQuoteUrl)</string>
<string name="delete_review_url">删除段评URL(deleteUrl)</string>
</resources>

Loading…
Cancel
Save