gedoor пре 4 година
родитељ
комит
57d773bfab

+ 0 - 8
app/src/main/java/io/legado/app/data/entities/Book.kt

@@ -115,8 +115,6 @@ data class Book(
 
     fun getUnreadChapterNum() = max(totalChapterNum - durChapterIndex - 1, 0)
 
-    fun getDisplayTag() = if (customTag.isNullOrBlank()) kind else customTag
-
     fun getDisplayCover() = if (customCoverUrl.isNullOrEmpty()) coverUrl else customCoverUrl
 
     fun getDisplayIntro() = if (customIntro.isNullOrEmpty()) intro else customIntro
@@ -178,11 +176,6 @@ data class Book(
         config().imageStyle = imageStyle
     }
 
-    fun setDelTag(tag: Long) {
-        config().delTag =
-            if ((config().delTag and tag) == tag) config().delTag and tag.inv() else config().delTag or tag
-    }
-
     fun getDelTag(tag: Long): Boolean {
         return config().delTag and tag == tag
     }
@@ -259,7 +252,6 @@ data class Book(
     companion object {
         const val hTag = 2L
         const val rubyTag = 4L
-        const val imgTag = 8L
         const val imgStyleDefault = "DEFAULT"
         const val imgStyleFull = "FULL"
         const val imgStyleText = "TEXT"

+ 8 - 1
app/src/main/java/io/legado/app/model/localBook/TextFile.kt

@@ -8,6 +8,7 @@ import io.legado.app.help.DefaultData
 import io.legado.app.utils.EncodingDetect
 import io.legado.app.utils.MD5Utils
 import io.legado.app.utils.StringUtils
+import io.legado.app.utils.Utf8BomUtils
 import java.io.FileNotFoundException
 import java.nio.charset.Charset
 import java.util.regex.Matcher
@@ -64,7 +65,12 @@ class TextFile(private val book: Book) {
             //读取的长度
             var length: Int
             val buffer = ByteArray(bufferSize)
-            var bufferStart = 0
+            var bufferStart = 3
+            bis.read(buffer, 0, 3)
+            if (Utf8BomUtils.hasBom(buffer)) {
+                bufferStart = 0
+                curOffset = 3
+            }
             //获取文件中的数据到buffer,直到没有数据为止
             while (bis.read(buffer, bufferStart, bufferSize - bufferStart)
                     .also { length = it } > 0
@@ -159,6 +165,7 @@ class TextFile(private val book: Book) {
                         return analyze(tocRules.firstOrNull()?.rule?.toPattern(Pattern.MULTILINE))
                     }
                 } else { //进行本地虚拟分章
+                    bufferStart = 0
                     //章节在buffer的偏移量
                     var chapterOffset = 0
                     //当前剩余可分配的长度