From 15c3eb8dd27f94496032fe27dd1dbceca489a273 Mon Sep 17 00:00:00 2001 From: atbest Date: Wed, 22 May 2019 22:42:50 -0400 Subject: [PATCH] Added database entities --- .../java/io/legado/app/data/AppDatabase.kt | 5 +++- .../java/io/legado/app/data/entities/Book.kt | 5 ++-- .../io/legado/app/data/entities/Chapter.kt | 23 +++++++++++++++++++ .../legado/app/data/entities/ReplaceRule.kt | 23 +++++++++++++++++++ .../java/io/legado/app/data/entities/Rule.kt | 5 ++++ .../io/legado/app/data/entities/Source.kt | 2 ++ app/src/main/res/values/strings.xml | 1 + 7 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/io/legado/app/data/entities/Chapter.kt create mode 100644 app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt create mode 100644 app/src/main/java/io/legado/app/data/entities/Rule.kt create mode 100644 app/src/main/java/io/legado/app/data/entities/Source.kt diff --git a/app/src/main/java/io/legado/app/data/AppDatabase.kt b/app/src/main/java/io/legado/app/data/AppDatabase.kt index 71cb9dbb1..5fb47987f 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -8,9 +8,12 @@ import androidx.room.migration.Migration import androidx.sqlite.db.SupportSQLiteDatabase import io.legado.app.data.dao.BookDao import io.legado.app.data.entities.Book +import io.legado.app.data.entities.Chapter +import io.legado.app.data.entities.ReplaceRule +import javax.xml.transform.Source -@Database(entities = [Book::class], version = 1, exportSchema = true) +@Database(entities = [Book::class, Chapter::class, ReplaceRule::class, Source::class], version = 1, exportSchema = true) // @TypeConverters(Converters::class) abstract class AppDatabase : RoomDatabase() { diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 800ea42d9..f51e80159 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -1,6 +1,5 @@ package io.legado.app.data.entities -import android.annotation.SuppressLint import android.os.Parcelable import androidx.room.* import kotlinx.android.parcel.Parcelize @@ -14,7 +13,7 @@ data class Book(@PrimaryKey var tag: String = "", var author: String? = null, var coverUrl: String? = null, - var customCoverUrl: String? = null, + var userCoverUrl: String? = null, var introduction: String? = null, var charset: String? = null, var type: Int = 0, // 0: text, 1: audio @@ -26,7 +25,7 @@ data class Book(@PrimaryKey var durChapterPage: Int = 0, var totalChapterNum: Int = 0, var hasNewChapter: Boolean = false, - var allowUpdate: Boolean = true + var canUpdate: Boolean = true ) : Parcelable { fun getUnreadChapterNum() = Math.max(totalChapterNum - durChapterIndex - 1, 0) diff --git a/app/src/main/java/io/legado/app/data/entities/Chapter.kt b/app/src/main/java/io/legado/app/data/entities/Chapter.kt new file mode 100644 index 000000000..c34838a1f --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/Chapter.kt @@ -0,0 +1,23 @@ +package io.legado.app.data.entities + +import android.os.Parcelable +import androidx.room.Entity +import androidx.room.Index +import androidx.room.PrimaryKey +import kotlinx.android.parcel.Parcelize + + +@Parcelize +@Entity(tableName = "chapters", + indices = [(Index(value = ["url"]))]) +data class Chapter(@PrimaryKey + var url: String = "", + var name: String = "", + var bookUrl: String = "", + var index: Int = 0, + var ResourceUrl: String? = null, + var tag: String? = null, + var start: Long? = null, + var end: Long? = null +) : Parcelable + diff --git a/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt b/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt new file mode 100644 index 000000000..9c6d6b5b6 --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/ReplaceRule.kt @@ -0,0 +1,23 @@ +package io.legado.app.data.entities + +import android.os.Parcelable +import androidx.room.Entity +import androidx.room.Index +import androidx.room.PrimaryKey +import kotlinx.android.parcel.Parcelize + +@Parcelize +@Entity(tableName = "replace_rules", + indices = [(Index(value = ["id"]))]) +data class ReplaceRule(@PrimaryKey + val id: Int = 0, + val summary: String? = null, + val pattern: String? = null, + val replacement: String? = null, + val scope: String? = null, + val isEnabled: Boolean? = null, + val isRegex: Boolean? = null, + val order: Int = 0 +) : Parcelable + + diff --git a/app/src/main/java/io/legado/app/data/entities/Rule.kt b/app/src/main/java/io/legado/app/data/entities/Rule.kt new file mode 100644 index 000000000..e83807c87 --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/Rule.kt @@ -0,0 +1,5 @@ +package io.legado.app.data.entities + +class Rule { + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/Source.kt b/app/src/main/java/io/legado/app/data/entities/Source.kt new file mode 100644 index 000000000..feecd7295 --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/Source.kt @@ -0,0 +1,2 @@ +package io.legado.app.data.entities + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6f0dca604..e2bf2033a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -13,4 +13,5 @@ Tools Share Send + Replace with your own action