This commit is contained in:
kunfei
2022-03-09 21:41:52 +08:00
parent edf577a40c
commit 20ca357884
11 changed files with 3383 additions and 35 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -17,14 +17,18 @@ val appDb by lazy {
} }
@Database( @Database(
version = 44, version = 46,
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,
RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class, RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class,
RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class, Cache::class, RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class, Cache::class,
RuleSub::class], RuleSub::class, KeyboardAssist::class],
autoMigrations = [AutoMigration(from = 43, to = 44)] autoMigrations = [
AutoMigration(from = 43, to = 44),
AutoMigration(from = 44, to = 45),
AutoMigration(from = 45, to = 46)
]
) )
abstract class AppDatabase : RoomDatabase() { abstract class AppDatabase : RoomDatabase() {
@@ -45,6 +49,7 @@ abstract class AppDatabase : RoomDatabase() {
abstract val httpTTSDao: HttpTTSDao abstract val httpTTSDao: HttpTTSDao
abstract val cacheDao: CacheDao abstract val cacheDao: CacheDao
abstract val ruleSubDao: RuleSubDao abstract val ruleSubDao: RuleSubDao
abstract val keyboardAssistsDao: KeyboardAssistsDao
companion object { companion object {
@@ -0,0 +1,23 @@
package io.legado.app.data.dao
import androidx.room.*
import io.legado.app.data.entities.KeyboardAssist
@Dao
interface KeyboardAssistsDao {
@get:Query("select * from keyboardAssists")
val all: List<KeyboardAssist>
@Query("select * from keyboardAssists where type = :type")
fun getByType(type: Int): List<KeyboardAssist>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg keyboardAssist: KeyboardAssist)
@Update
fun update(vararg keyboardAssist: KeyboardAssist)
@Delete
fun delete(vararg keyboardAssist: KeyboardAssist)
}
@@ -2,6 +2,7 @@ package io.legado.app.data.entities
import android.os.Parcelable import android.os.Parcelable
import androidx.room.* import androidx.room.*
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern import io.legado.app.constant.AppPattern
import io.legado.app.constant.BookType import io.legado.app.constant.BookType
import io.legado.app.data.appDb import io.legado.app.data.appDb
@@ -24,36 +25,82 @@ import kotlin.math.min
indices = [Index(value = ["name", "author"], unique = true)] indices = [Index(value = ["name", "author"], unique = true)]
) )
data class Book( data class Book(
// 详情页Url(本地书源存储完整文件路径)
@PrimaryKey @PrimaryKey
override var bookUrl: String = "", // 详情页Url(本地书源存储完整文件路径) @ColumnInfo(defaultValue = "")
var tocUrl: String = "", // 目录页Url (toc=table of Contents) override var bookUrl: String = "",
var origin: String = BookType.local, // 书源URL(默认BookType.local) // 目录页Url (toc=table of Contents)
var originName: String = "", //书源名称 or 本地书籍文件名 @ColumnInfo(defaultValue = "")
override var name: String = "", // 书籍名称(书源获取) var tocUrl: String = "",
override var author: String = "", // 作者名称(书源获取) // 书源URL(默认BookType.local)
override var kind: String? = null, // 分类信息(书源获取) @ColumnInfo(defaultValue = "")
var customTag: String? = null, // 分类信息(用户修改) var origin: String = BookType.local,
var coverUrl: String? = null, // 封面Url(书源获取) //书源名称 or 本地书籍文件名
var customCoverUrl: String? = null, // 封面Url(用户修改) @ColumnInfo(defaultValue = "")
var intro: String? = null, // 简介内容(书源获取) var originName: String = "",
var customIntro: String? = null, // 简介内容(用户修改) // 书籍名称(书源获取)
var charset: String? = null, // 自定义字符集名称(仅适用于本地书籍) @ColumnInfo(defaultValue = "")
var type: Int = 0, // 0:text 1:audio override var name: String = "",
var group: Long = 0, // 自定义分组索引号 // 作者名称(书源获取)
var latestChapterTitle: String? = null, // 最新章节标题 @ColumnInfo(defaultValue = "")
var latestChapterTime: Long = System.currentTimeMillis(), // 最新章节标题更新时间 override var author: String = "",
var lastCheckTime: Long = System.currentTimeMillis(), // 最近一次更新书籍信息的时间 // 分类信息(书源获取)
var lastCheckCount: Int = 0, // 最近一次发现新章节的数量 override var kind: String? = null,
var totalChapterNum: Int = 0, // 书籍目录总数 // 分类信息(用户修改)
var durChapterTitle: String? = null, // 当前章节名称 var customTag: String? = null,
var durChapterIndex: Int = 0, // 当前章节索引 // 封面Url(书源获取)
var durChapterPos: Int = 0, // 当前阅读的进度(首行字符的索引位置) var coverUrl: String? = null,
var durChapterTime: Long = System.currentTimeMillis(), // 最近一次阅读书籍的时间(打开正文的时间) // 封面Url(用户修改)
var customCoverUrl: String? = null,
// 简介内容(书源获取)
var intro: String? = null,
// 简介内容(用户修改)
var customIntro: String? = null,
// 自定义字符集名称(仅适用于本地书籍)
var charset: String? = null,
// 0:text 1:audio 3:image
@ColumnInfo(defaultValue = "0")
var type: Int = 0,
// 自定义分组索引号
@ColumnInfo(defaultValue = "0")
var group: Long = 0,
// 最新章节标题
var latestChapterTitle: String? = null,
// 最新章节标题更新时间
@ColumnInfo(defaultValue = "0")
var latestChapterTime: Long = System.currentTimeMillis(),
// 最近一次更新书籍信息的时间
@ColumnInfo(defaultValue = "0")
var lastCheckTime: Long = System.currentTimeMillis(),
// 最近一次发现新章节的数量
@ColumnInfo(defaultValue = "0")
var lastCheckCount: Int = 0,
// 书籍目录总数
@ColumnInfo(defaultValue = "0")
var totalChapterNum: Int = 0,
// 当前章节名称
var durChapterTitle: String? = null,
// 当前章节索引
@ColumnInfo(defaultValue = "0")
var durChapterIndex: Int = 0,
// 当前阅读的进度(首行字符的索引位置)
@ColumnInfo(defaultValue = "0")
var durChapterPos: Int = 0,
// 最近一次阅读书籍的时间(打开正文的时间)
@ColumnInfo(defaultValue = "0")
var durChapterTime: Long = System.currentTimeMillis(),
override var wordCount: String? = null, override var wordCount: String? = null,
var canUpdate: Boolean = true, // 刷新书架时更新书籍信息 // 刷新书架时更新书籍信息
var order: Int = 0, // 手动排序 @ColumnInfo(defaultValue = "1")
var originOrder: Int = 0, //书源排序 var canUpdate: Boolean = true,
var variable: String? = null, // 自定义书籍变量信息(用于书源规则检索书籍信息) // 手动排序
@ColumnInfo(defaultValue = "0")
var order: Int = 0,
//书源排序
@ColumnInfo(defaultValue = "0")
var originOrder: Int = 0,
// 自定义书籍变量信息(用于书源规则检索书籍信息)
var variable: String? = null,
var readConfig: ReadConfig? = null var readConfig: ReadConfig? = null
) : Parcelable, BaseBook { ) : Parcelable, BaseBook {
@@ -98,6 +145,10 @@ data class Book(
override fun putVariable(key: String, value: String?) { override fun putVariable(key: String, value: String?) {
if (value != null) { if (value != null) {
if (value.length > 1000) {
AppLog.put("${name}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value variableMap[key] = value
} else { } else {
variableMap.remove(key) variableMap.remove(key)
@@ -7,6 +7,7 @@ import androidx.room.Ignore
import androidx.room.Index import androidx.room.Index
import com.github.liuyueyi.quick.transfer.ChineseUtils import com.github.liuyueyi.quick.transfer.ChineseUtils
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern import io.legado.app.constant.AppPattern
import io.legado.app.help.config.AppConfig import io.legado.app.help.config.AppConfig
import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.analyzeRule.AnalyzeUrl
@@ -56,6 +57,10 @@ data class BookChapter(
override fun putVariable(key: String, value: String?) { override fun putVariable(key: String, value: String?) {
if (value != null) { if (value != null) {
if (value.length > 1000) {
AppLog.put("${title}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value variableMap[key] = value
} else { } else {
variableMap.remove(key) variableMap.remove(key)
@@ -0,0 +1,16 @@
package io.legado.app.data.entities
import androidx.room.ColumnInfo
import androidx.room.Entity
@Entity(tableName = "keyboardAssists", primaryKeys = ["type", "key"])
data class KeyboardAssist(
@ColumnInfo(defaultValue = "0")
val type: Int = 0,
@ColumnInfo(defaultValue = "")
val key: String,
@ColumnInfo(defaultValue = "")
val value: String,
@ColumnInfo(defaultValue = "0")
val serialNo: Int
)
@@ -1,4 +0,0 @@
package io.legado.app.data.entities
class KeyboardHelp {
}
@@ -2,6 +2,7 @@ package io.legado.app.data.entities
import androidx.room.Entity import androidx.room.Entity
import androidx.room.Ignore import androidx.room.Ignore
import io.legado.app.constant.AppLog
import io.legado.app.model.analyzeRule.RuleDataInterface import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonObject import io.legado.app.utils.fromJsonObject
@@ -42,6 +43,10 @@ data class RssArticle(
override fun putVariable(key: String, value: String?) { override fun putVariable(key: String, value: String?) {
if (value != null) { if (value != null) {
if (value.length > 1000) {
AppLog.put("${title}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value variableMap[key] = value
} else { } else {
variableMap.remove(key) variableMap.remove(key)
@@ -2,6 +2,7 @@ package io.legado.app.data.entities
import androidx.room.Entity import androidx.room.Entity
import androidx.room.Ignore import androidx.room.Ignore
import io.legado.app.constant.AppLog
import io.legado.app.model.analyzeRule.RuleDataInterface import io.legado.app.model.analyzeRule.RuleDataInterface
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonObject import io.legado.app.utils.fromJsonObject
@@ -34,6 +35,10 @@ data class RssStar(
override fun putVariable(key: String, value: String?) { override fun putVariable(key: String, value: String?) {
if (value != null) { if (value != null) {
if (value.length > 1000) {
AppLog.put("${title}设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value variableMap[key] = value
} else { } else {
variableMap.remove(key) variableMap.remove(key)
@@ -1,5 +1,7 @@
package io.legado.app.model.analyzeRule package io.legado.app.model.analyzeRule
import io.legado.app.constant.AppLog
class RuleData : RuleDataInterface { class RuleData : RuleDataInterface {
override val variableMap by lazy { override val variableMap by lazy {
@@ -8,6 +10,10 @@ class RuleData : RuleDataInterface {
override fun putVariable(key: String, value: String?) { override fun putVariable(key: String, value: String?) {
if (value != null) { if (value != null) {
if (value.length > 1000) {
AppLog.put("设置变量长度超过1000,设置失败")
return
}
variableMap[key] = value variableMap[key] = value
} else { } else {
variableMap.remove(key) variableMap.remove(key)