优化
This commit is contained in:
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(
|
||||
version = 44,
|
||||
version = 46,
|
||||
exportSchema = true,
|
||||
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
|
||||
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
|
||||
RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class,
|
||||
RssStar::class, TxtTocRule::class, ReadRecord::class, HttpTTS::class, Cache::class,
|
||||
RuleSub::class],
|
||||
autoMigrations = [AutoMigration(from = 43, to = 44)]
|
||||
RuleSub::class, KeyboardAssist::class],
|
||||
autoMigrations = [
|
||||
AutoMigration(from = 43, to = 44),
|
||||
AutoMigration(from = 44, to = 45),
|
||||
AutoMigration(from = 45, to = 46)
|
||||
]
|
||||
)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
@@ -45,6 +49,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
abstract val httpTTSDao: HttpTTSDao
|
||||
abstract val cacheDao: CacheDao
|
||||
abstract val ruleSubDao: RuleSubDao
|
||||
abstract val keyboardAssistsDao: KeyboardAssistsDao
|
||||
|
||||
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 androidx.room.*
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.constant.AppPattern
|
||||
import io.legado.app.constant.BookType
|
||||
import io.legado.app.data.appDb
|
||||
@@ -24,36 +25,82 @@ import kotlin.math.min
|
||||
indices = [Index(value = ["name", "author"], unique = true)]
|
||||
)
|
||||
data class Book(
|
||||
// 详情页Url(本地书源存储完整文件路径)
|
||||
@PrimaryKey
|
||||
override var bookUrl: String = "", // 详情页Url(本地书源存储完整文件路径)
|
||||
var tocUrl: String = "", // 目录页Url (toc=table of Contents)
|
||||
var origin: String = BookType.local, // 书源URL(默认BookType.local)
|
||||
var originName: String = "", //书源名称 or 本地书籍文件名
|
||||
override var name: String = "", // 书籍名称(书源获取)
|
||||
override var author: String = "", // 作者名称(书源获取)
|
||||
override var kind: String? = null, // 分类信息(书源获取)
|
||||
var customTag: String? = null, // 分类信息(用户修改)
|
||||
var coverUrl: String? = null, // 封面Url(书源获取)
|
||||
var customCoverUrl: String? = null, // 封面Url(用户修改)
|
||||
var intro: String? = null, // 简介内容(书源获取)
|
||||
var customIntro: String? = null, // 简介内容(用户修改)
|
||||
var charset: String? = null, // 自定义字符集名称(仅适用于本地书籍)
|
||||
var type: Int = 0, // 0:text 1:audio
|
||||
var group: Long = 0, // 自定义分组索引号
|
||||
var latestChapterTitle: String? = null, // 最新章节标题
|
||||
var latestChapterTime: Long = System.currentTimeMillis(), // 最新章节标题更新时间
|
||||
var lastCheckTime: Long = System.currentTimeMillis(), // 最近一次更新书籍信息的时间
|
||||
var lastCheckCount: Int = 0, // 最近一次发现新章节的数量
|
||||
var totalChapterNum: Int = 0, // 书籍目录总数
|
||||
var durChapterTitle: String? = null, // 当前章节名称
|
||||
var durChapterIndex: Int = 0, // 当前章节索引
|
||||
var durChapterPos: Int = 0, // 当前阅读的进度(首行字符的索引位置)
|
||||
var durChapterTime: Long = System.currentTimeMillis(), // 最近一次阅读书籍的时间(打开正文的时间)
|
||||
@ColumnInfo(defaultValue = "")
|
||||
override var bookUrl: String = "",
|
||||
// 目录页Url (toc=table of Contents)
|
||||
@ColumnInfo(defaultValue = "")
|
||||
var tocUrl: String = "",
|
||||
// 书源URL(默认BookType.local)
|
||||
@ColumnInfo(defaultValue = "")
|
||||
var origin: String = BookType.local,
|
||||
//书源名称 or 本地书籍文件名
|
||||
@ColumnInfo(defaultValue = "")
|
||||
var originName: String = "",
|
||||
// 书籍名称(书源获取)
|
||||
@ColumnInfo(defaultValue = "")
|
||||
override var name: String = "",
|
||||
// 作者名称(书源获取)
|
||||
@ColumnInfo(defaultValue = "")
|
||||
override var author: String = "",
|
||||
// 分类信息(书源获取)
|
||||
override var kind: String? = null,
|
||||
// 分类信息(用户修改)
|
||||
var customTag: String? = null,
|
||||
// 封面Url(书源获取)
|
||||
var coverUrl: String? = null,
|
||||
// 封面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,
|
||||
var canUpdate: Boolean = true, // 刷新书架时更新书籍信息
|
||||
var order: Int = 0, // 手动排序
|
||||
var originOrder: Int = 0, //书源排序
|
||||
var variable: String? = null, // 自定义书籍变量信息(用于书源规则检索书籍信息)
|
||||
// 刷新书架时更新书籍信息
|
||||
@ColumnInfo(defaultValue = "1")
|
||||
var canUpdate: Boolean = true,
|
||||
// 手动排序
|
||||
@ColumnInfo(defaultValue = "0")
|
||||
var order: Int = 0,
|
||||
//书源排序
|
||||
@ColumnInfo(defaultValue = "0")
|
||||
var originOrder: Int = 0,
|
||||
// 自定义书籍变量信息(用于书源规则检索书籍信息)
|
||||
var variable: String? = null,
|
||||
var readConfig: ReadConfig? = null
|
||||
) : Parcelable, BaseBook {
|
||||
|
||||
@@ -98,6 +145,10 @@ data class Book(
|
||||
|
||||
override fun putVariable(key: String, value: String?) {
|
||||
if (value != null) {
|
||||
if (value.length > 1000) {
|
||||
AppLog.put("${name}设置变量长度超过1000,设置失败")
|
||||
return
|
||||
}
|
||||
variableMap[key] = value
|
||||
} else {
|
||||
variableMap.remove(key)
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.room.Ignore
|
||||
import androidx.room.Index
|
||||
import com.github.liuyueyi.quick.transfer.ChineseUtils
|
||||
import io.legado.app.R
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.constant.AppPattern
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
||||
@@ -56,6 +57,10 @@ data class BookChapter(
|
||||
|
||||
override fun putVariable(key: String, value: String?) {
|
||||
if (value != null) {
|
||||
if (value.length > 1000) {
|
||||
AppLog.put("${title}设置变量长度超过1000,设置失败")
|
||||
return
|
||||
}
|
||||
variableMap[key] = value
|
||||
} else {
|
||||
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.Ignore
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.model.analyzeRule.RuleDataInterface
|
||||
import io.legado.app.utils.GSON
|
||||
import io.legado.app.utils.fromJsonObject
|
||||
@@ -42,6 +43,10 @@ data class RssArticle(
|
||||
|
||||
override fun putVariable(key: String, value: String?) {
|
||||
if (value != null) {
|
||||
if (value.length > 1000) {
|
||||
AppLog.put("${title}设置变量长度超过1000,设置失败")
|
||||
return
|
||||
}
|
||||
variableMap[key] = value
|
||||
} else {
|
||||
variableMap.remove(key)
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.legado.app.data.entities
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Ignore
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.model.analyzeRule.RuleDataInterface
|
||||
import io.legado.app.utils.GSON
|
||||
import io.legado.app.utils.fromJsonObject
|
||||
@@ -34,6 +35,10 @@ data class RssStar(
|
||||
|
||||
override fun putVariable(key: String, value: String?) {
|
||||
if (value != null) {
|
||||
if (value.length > 1000) {
|
||||
AppLog.put("${title}设置变量长度超过1000,设置失败")
|
||||
return
|
||||
}
|
||||
variableMap[key] = value
|
||||
} else {
|
||||
variableMap.remove(key)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.legado.app.model.analyzeRule
|
||||
|
||||
import io.legado.app.constant.AppLog
|
||||
|
||||
class RuleData : RuleDataInterface {
|
||||
|
||||
override val variableMap by lazy {
|
||||
@@ -8,6 +10,10 @@ class RuleData : RuleDataInterface {
|
||||
|
||||
override fun putVariable(key: String, value: String?) {
|
||||
if (value != null) {
|
||||
if (value.length > 1000) {
|
||||
AppLog.put("设置变量长度超过1000,设置失败")
|
||||
return
|
||||
}
|
||||
variableMap[key] = value
|
||||
} else {
|
||||
variableMap.remove(key)
|
||||
|
||||
Reference in New Issue
Block a user