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 3e50aab3a..f5d8d0927 100644 --- a/app/src/main/java/io/legado/app/data/AppDatabase.kt +++ b/app/src/main/java/io/legado/app/data/AppDatabase.kt @@ -18,8 +18,8 @@ import kotlinx.coroutines.launch 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], - version = 15, + RssStar::class, TxtTocRule::class, ReadRecord::class], + version = 17, exportSchema = true ) abstract class AppDatabase : RoomDatabase() { diff --git a/app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt b/app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt new file mode 100644 index 000000000..0e1d2672e --- /dev/null +++ b/app/src/main/java/io/legado/app/data/dao/ReadRecordDao.kt @@ -0,0 +1,19 @@ +package io.legado.app.data.dao + +import androidx.room.* +import io.legado.app.data.entities.ReadRecord + +@Dao +interface ReadRecordDao { + + @get:Query("select * from readRecord") + val all: List + + + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun insert(vararg readRecord: ReadRecord) + + @Update + fun update(vararg record: ReadRecord) + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt b/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt new file mode 100644 index 000000000..72e2bb0b2 --- /dev/null +++ b/app/src/main/java/io/legado/app/data/entities/ReadRecord.kt @@ -0,0 +1,11 @@ +package io.legado.app.data.entities + +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity(tableName = "readRecord") +data class ReadRecord( + @PrimaryKey + val bookName: String = "", + val readTime: Long = 0L +) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index feb8aff95..5a0721620 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -9,22 +9,25 @@ import io.legado.app.data.entities.ReplaceRule import io.legado.app.help.coroutine.Coroutine import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.model.localBook.LocalBook -import io.legado.app.ui.book.read.page.provider.ChapterProvider.srcPattern import io.legado.app.utils.FileUtils import io.legado.app.utils.MD5Utils import io.legado.app.utils.externalFilesDir import io.legado.app.utils.postEvent +import io.legado.app.utils.NetworkUtils import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.withContext import org.apache.commons.text.similarity.JaccardSimilarity import org.jetbrains.anko.toast import java.io.File +import java.util.regex.Pattern import kotlin.math.min object BookHelp { private const val cacheFolderName = "book_cache" private val downloadDir: File = App.INSTANCE.externalFilesDir + private val srcPattern = + Pattern.compile("", Pattern.CASE_INSENSITIVE) private fun bookFolderName(book: Book): String { return formatFolderName(book.name) + MD5Utils.md5Encode16(book.bookUrl) @@ -72,8 +75,8 @@ object BookHelp { subDirs = *arrayOf(cacheFolderName, bookFolderName(book)) ).writeText(content) //保存图片 - content.forEachIndexed { index, text -> - val matcher = srcPattern.matcher(text) + content.split("\n").forEach { + val matcher = srcPattern.matcher(it) if (matcher.find()) { var src = matcher.group(1) src = NetworkUtils.getAbsoluteURL(bookChapter.url, src) diff --git a/build.gradle b/build.gradle index f2d22610f..b9930dac3 100644 --- a/build.gradle +++ b/build.gradle @@ -5,8 +5,8 @@ buildscript { repositories { google() jcenter() - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } - maven { url 'http://s3.amazonaws.com/fabric-artifacts/public' } + maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } + maven { url 'https://s3.amazonaws.com/fabric-artifacts/public' } maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } maven { url 'https://maven.fabric.io/public' } maven { url 'https://plugins.gradle.org/m2/' } @@ -24,7 +24,7 @@ allprojects { repositories { google() jcenter() - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } maven { url "https://jitpack.io" } maven { url 'https://maven.google.com/' } maven { url 'https://github.com/psiegman/mvn-repo/raw/master/releases' }