Add: Add ReviewRule and related codes

This commit is contained in:
Seidko
2022-08-21 23:09:26 +08:00
parent cd13ef7d9f
commit 6b22ab046e
12 changed files with 119 additions and 45 deletions
@@ -50,6 +50,9 @@ interface BookSourceDao {
@Query("select * from book_sources where enabledExplore = 1 and trim(exploreUrl) <> '' order by customOrder asc")
fun flowExplore(): Flow<List<BookSource>>
// @Query("select * from book_sources where enabledReview = 1 order by customOrder asc")
// fun flowReview(): Flow<List<BookSource>>
@Query("select * from book_sources where loginUrl is not null and loginUrl != ''")
fun flowLogin(): Flow<List<BookSource>>
@@ -49,6 +49,8 @@ data class BookSource(
override var loginUrl: String? = null,
// 登录UI
override var loginUi: String? = null,
// 启用段评
var enabledReview: Boolean? = false,
// 登录检测js
var loginCheckJs: String? = null,
// 注释
@@ -74,7 +76,9 @@ data class BookSource(
// 目录页规则
var ruleToc: TocRule? = null,
// 正文页规则
var ruleContent: ContentRule? = null
var ruleContent: ContentRule? = null,
// 段评规则
var ruleReview: ReviewRule? = null
) : Parcelable, BaseSource {
override fun getTag(): String {
@@ -170,6 +174,13 @@ data class BookSource(
return rule
}
fun getReviewRule(): ReviewRule {
ruleReview?.let { return it }
val rule = ReviewRule()
ruleReview = rule
return rule
}
fun getDisPlayNameGroup(): String {
return if (bookSourceGroup.isNullOrBlank()) {
bookSourceName
@@ -303,5 +314,13 @@ data class BookSource(
fun stringToContentRule(json: String?) =
GSON.fromJsonObject<ContentRule>(json).getOrNull()
@TypeConverter
fun stringToReviewRule(json: String?) =
GSON.fromJsonObject<ReviewRule>(json).getOrNull()
@TypeConverter
fun reviewRuleToString(reviewRule: ReviewRule?): String =
GSON.toJson(reviewRule)
}
}
@@ -0,0 +1,18 @@
package io.legado.app.data.entities.rule
import android.os.Parcelable
import kotlinx.parcelize.Parcelize
@Parcelize
data class ReviewRule(
var reviewUrl: String? = null, // 段评URL
var avatarRule: String? = null, // 段评发布者头像
var contentRule: String? = null, // 段评内容
var postTimeRule: String? = null, // 段评发布时间
var reviewReplyUrl: String? = null, // 获取段评回复URL
// 这些功能将在以上功能完成以后实现
var voteUpUrl: String? = null, // 点赞URL
var voteDownUrl: String? = null, // 点踩URL
var replyUrl: String? = null // 回复URL
): Parcelable
@@ -40,18 +40,33 @@
android:checked="true"
android:text="@string/auto_save_cookie" />
<TextView
<io.legado.app.lib.theme.view.ThemeCheckBox
android:id="@+id/cb_is_enable_review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="@string/review" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:height="30dp"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/book_type"
android:layout_marginLeft="12dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="3dp"
tools:ignore="RtlHardcoded" />
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/sp_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:entries="@array/book_type"
app:theme="@style/Spinner" />
@@ -1010,4 +1010,5 @@
<string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">Review</string>
</resources>
@@ -1013,4 +1013,5 @@
<string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">Review</string>
</resources>
@@ -1013,4 +1013,5 @@
<string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">Review</string>
</resources>
@@ -1010,4 +1010,5 @@
<string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">段评</string>
</resources>
@@ -1012,4 +1012,5 @@
<string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">段评</string>
</resources>
+1
View File
@@ -1012,4 +1012,5 @@
<string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">段评</string>
</resources>
+1
View File
@@ -1013,4 +1013,5 @@
<string name="check_selected_interval">选中所选区间</string>
<string name="show_add_to_shelf_alert_title">返回时提示放入书架</string>
<string name="show_add_to_shelf_alert_summary">阅读未放入书架的书籍在返回时提示放入书架</string>
<string name="review">Review</string>
</resources>