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

View File

@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 52,
"identityHash": "0221c385ed7393f47afe9579d3106541",
"identityHash": "c55dac79aa9cc3dcdb72e91da4282005",
"entities": [
{
"tableName": "books",
@ -208,10 +208,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"bookUrl"
]
],
"autoGenerate": false
},
"indices": [
{
@ -263,17 +263,17 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"groupId"
]
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "book_sources",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`bookSourceUrl` TEXT NOT NULL, `bookSourceName` TEXT NOT NULL, `bookSourceGroup` TEXT, `bookSourceType` INTEGER NOT NULL, `bookUrlPattern` TEXT, `customOrder` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, `enabledExplore` INTEGER NOT NULL, `enabledCookieJar` INTEGER DEFAULT 0, `concurrentRate` TEXT, `header` TEXT, `loginUrl` TEXT, `loginUi` TEXT, `loginCheckJs` TEXT, `bookSourceComment` TEXT, `variableComment` TEXT, `lastUpdateTime` INTEGER NOT NULL, `respondTime` INTEGER NOT NULL, `weight` INTEGER NOT NULL, `exploreUrl` TEXT, `ruleExplore` TEXT, `searchUrl` TEXT, `ruleSearch` TEXT, `ruleBookInfo` TEXT, `ruleToc` TEXT, `ruleContent` TEXT, PRIMARY KEY(`bookSourceUrl`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`bookSourceUrl` TEXT NOT NULL, `bookSourceName` TEXT NOT NULL, `bookSourceGroup` TEXT, `bookSourceType` INTEGER NOT NULL, `bookUrlPattern` TEXT, `customOrder` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, `enabledExplore` INTEGER NOT NULL, `enabledCookieJar` INTEGER DEFAULT 0, `concurrentRate` TEXT, `header` TEXT, `loginUrl` TEXT, `loginUi` TEXT, `enabledReview` INTEGER, `loginCheckJs` TEXT, `bookSourceComment` TEXT, `variableComment` TEXT, `lastUpdateTime` INTEGER NOT NULL, `respondTime` INTEGER NOT NULL, `weight` INTEGER NOT NULL, `exploreUrl` TEXT, `ruleExplore` TEXT, `searchUrl` TEXT, `ruleSearch` TEXT, `ruleBookInfo` TEXT, `ruleToc` TEXT, `ruleContent` TEXT, `ruleReview` TEXT, PRIMARY KEY(`bookSourceUrl`))",
"fields": [
{
"fieldPath": "bookSourceUrl",
@ -354,6 +354,12 @@
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "enabledReview",
"columnName": "enabledReview",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "loginCheckJs",
"columnName": "loginCheckJs",
@ -431,13 +437,19 @@
"columnName": "ruleContent",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "ruleReview",
"columnName": "ruleReview",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"bookSourceUrl"
]
],
"autoGenerate": false
},
"indices": [
{
@ -548,11 +560,11 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"url",
"bookUrl"
]
],
"autoGenerate": false
},
"indices": [
{
@ -676,10 +688,10 @@
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
],
"autoGenerate": true
},
"indices": [
{
@ -790,10 +802,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"bookUrl"
]
],
"autoGenerate": false
},
"indices": [
{
@ -853,10 +865,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"word"
]
],
"autoGenerate": false
},
"indices": [
{
@ -889,10 +901,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"url"
]
],
"autoGenerate": false
},
"indices": [
{
@ -1082,10 +1094,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"sourceUrl"
]
],
"autoGenerate": false
},
"indices": [
{
@ -1154,10 +1166,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"time"
]
],
"autoGenerate": false
},
"indices": [
{
@ -1245,11 +1257,11 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"origin",
"link"
]
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
@ -1272,10 +1284,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"record"
]
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
@ -1346,11 +1358,11 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"origin",
"link"
]
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
@ -1397,10 +1409,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"id"
]
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
@ -1437,11 +1449,11 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"deviceId",
"bookName"
]
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
@ -1521,10 +1533,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"id"
]
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
@ -1553,10 +1565,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"key"
]
],
"autoGenerate": false
},
"indices": [
{
@ -1619,10 +1631,10 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"id"
]
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
@ -1661,11 +1673,11 @@
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"type",
"key"
]
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
@ -1674,7 +1686,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '0221c385ed7393f47afe9579d3106541')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'c55dac79aa9cc3dcdb72e91da4282005')"
]
}
}

View File

@ -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>>

View File

@ -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)
}
}

View File

@ -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

View File

@ -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" />

View File

@ -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>

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>

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>

View File

@ -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>

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>

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>

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>