Horis пре 2 година
родитељ
комит
f1721adf3c

+ 10 - 9
app/src/main/java/io/legado/app/model/ReadBook.kt

@@ -155,13 +155,14 @@ object ReadBook : CoroutineScope by MainScope() {
     }
     }
 
 
     fun upReadTime() {
     fun upReadTime() {
+        if (!AppConfig.enableReadRecord) {
+            return
+        }
         Coroutine.async(executeContext = IO) {
         Coroutine.async(executeContext = IO) {
             readRecord.readTime = readRecord.readTime + System.currentTimeMillis() - readStartTime
             readRecord.readTime = readRecord.readTime + System.currentTimeMillis() - readStartTime
             readStartTime = System.currentTimeMillis()
             readStartTime = System.currentTimeMillis()
             readRecord.lastRead = System.currentTimeMillis()
             readRecord.lastRead = System.currentTimeMillis()
-            if (AppConfig.enableReadRecord) {
-                appDb.readRecordDao.insert(readRecord)
-            }
+            appDb.readRecordDao.insert(readRecord)
         }
         }
     }
     }
 
 
@@ -180,7 +181,7 @@ object ReadBook : CoroutineScope by MainScope() {
                 hasNextPage = true
                 hasNextPage = true
                 durChapterPos = nextPagePos
                 durChapterPos = nextPagePos
                 callBack?.upContent()
                 callBack?.upContent()
-                saveRead()
+                saveRead(true)
             }
             }
         }
         }
         return hasNextPage
         return hasNextPage
@@ -194,7 +195,7 @@ object ReadBook : CoroutineScope by MainScope() {
                 hasPrevPage = true
                 hasPrevPage = true
                 durChapterPos = prevPagePos
                 durChapterPos = prevPagePos
                 callBack?.upContent()
                 callBack?.upContent()
-                saveRead()
+                saveRead(true)
             }
             }
         }
         }
         return hasPrevPage
         return hasPrevPage
@@ -259,12 +260,12 @@ object ReadBook : CoroutineScope by MainScope() {
             success?.invoke()
             success?.invoke()
         }
         }
         curPageChanged()
         curPageChanged()
-        saveRead()
+        saveRead(true)
     }
     }
 
 
     fun setPageIndex(index: Int) {
     fun setPageIndex(index: Int) {
         durChapterPos = curTextChapter?.getReadLength(index) ?: index
         durChapterPos = curTextChapter?.getReadLength(index) ?: index
-        saveRead()
+        saveRead(true)
         curPageChanged(true)
         curPageChanged(true)
     }
     }
 
 
@@ -519,7 +520,7 @@ object ReadBook : CoroutineScope by MainScope() {
         saveRead()
         saveRead()
     }
     }
 
 
-    fun saveRead() {
+    fun saveRead(pageChanged: Boolean = false) {
         Coroutine.async(executeContext = IO) {
         Coroutine.async(executeContext = IO) {
             val book = book ?: return@async
             val book = book ?: return@async
             book.lastCheckCount = 0
             book.lastCheckCount = 0
@@ -527,7 +528,7 @@ object ReadBook : CoroutineScope by MainScope() {
             val chapterChanged = book.durChapterIndex != durChapterIndex
             val chapterChanged = book.durChapterIndex != durChapterIndex
             book.durChapterIndex = durChapterIndex
             book.durChapterIndex = durChapterIndex
             book.durChapterPos = durChapterPos
             book.durChapterPos = durChapterPos
-            if (chapterChanged) {
+            if (!pageChanged || chapterChanged) {
                 appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)?.let {
                 appDb.bookChapterDao.getChapter(book.bookUrl, durChapterIndex)?.let {
                     book.durChapterTitle = it.getDisplayTitle(
                     book.durChapterTitle = it.getDisplayTitle(
                         ContentProcessor.get(book.name, book.origin).getTitleReplaceRules(),
                         ContentProcessor.get(book.name, book.origin).getTitleReplaceRules(),

+ 18 - 6
app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt

@@ -21,7 +21,11 @@ import io.legado.app.data.entities.BookSource
 import io.legado.app.databinding.ActivityBookInfoBinding
 import io.legado.app.databinding.ActivityBookInfoBinding
 import io.legado.app.exception.NoStackTraceException
 import io.legado.app.exception.NoStackTraceException
 import io.legado.app.help.AppWebDav
 import io.legado.app.help.AppWebDav
-import io.legado.app.help.book.*
+import io.legado.app.help.book.getRemoteUrl
+import io.legado.app.help.book.isAudio
+import io.legado.app.help.book.isLocal
+import io.legado.app.help.book.isLocalTxt
+import io.legado.app.help.book.isWebFile
 import io.legado.app.help.config.AppConfig
 import io.legado.app.help.config.AppConfig
 import io.legado.app.help.config.LocalConfig
 import io.legado.app.help.config.LocalConfig
 import io.legado.app.lib.dialogs.alert
 import io.legado.app.lib.dialogs.alert
@@ -47,8 +51,20 @@ import io.legado.app.ui.login.SourceLoginActivity
 import io.legado.app.ui.widget.dialog.PhotoDialog
 import io.legado.app.ui.widget.dialog.PhotoDialog
 import io.legado.app.ui.widget.dialog.VariableDialog
 import io.legado.app.ui.widget.dialog.VariableDialog
 import io.legado.app.ui.widget.dialog.WaitDialog
 import io.legado.app.ui.widget.dialog.WaitDialog
-import io.legado.app.utils.*
+import io.legado.app.utils.ColorUtils
+import io.legado.app.utils.GSON
+import io.legado.app.utils.StartActivityContract
+import io.legado.app.utils.dpToPx
+import io.legado.app.utils.gone
+import io.legado.app.utils.longToastOnUi
+import io.legado.app.utils.openFileUri
+import io.legado.app.utils.sendToClip
+import io.legado.app.utils.shareWithQr
+import io.legado.app.utils.showDialogFragment
+import io.legado.app.utils.startActivity
+import io.legado.app.utils.toastOnUi
 import io.legado.app.utils.viewbindingdelegate.viewBinding
 import io.legado.app.utils.viewbindingdelegate.viewBinding
+import io.legado.app.utils.visible
 import kotlinx.coroutines.Dispatchers.IO
 import kotlinx.coroutines.Dispatchers.IO
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.launch
 import kotlinx.coroutines.withContext
 import kotlinx.coroutines.withContext
@@ -70,10 +86,6 @@ class BookInfoActivity :
                         chapterChanged = it.third
                         chapterChanged = it.third
                         appDb.bookDao.update(book)
                         appDb.bookDao.update(book)
                     }
                     }
-                    viewModel.chapterListData.value?.let { chapterList ->
-                        binding.tvToc.text =
-                            getString(R.string.toc_s, chapterList[book.durChapterIndex].title)
-                    }
                     startReadActivity(book)
                     startReadActivity(book)
                 }
                 }
             }
             }