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 6f15036b0..cda999353 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -8,7 +8,6 @@ import java.io.BufferedWriter import java.io.File import java.io.FileWriter import java.io.IOException -import java.nio.charset.StandardCharsets object BookHelp { @@ -52,7 +51,7 @@ object BookHelp { runCatching { val file = File(filePath) if (file.exists()) { - return String(file.readBytes(), StandardCharsets.UTF_8) + return String(file.readBytes()) } } return null diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 34183fe63..ed80686a6 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -1,6 +1,10 @@ package io.legado.app.help import android.graphics.drawable.Drawable +import com.jayway.jsonpath.JsonPath +import io.legado.app.App +import io.legado.app.utils.readInt +import java.io.File object ReadBookConfig { private val configList = arrayListOf() @@ -8,7 +12,17 @@ object ReadBookConfig { var bg: Drawable? = null init { - + val configFile = File(App.INSTANCE.filesDir.absolutePath + File.separator + "config") + val json = if (configFile.exists()) { + String(configFile.readBytes()) + } else { + String(App.INSTANCE.assets.open("defaultConfig.json").readBytes()) + } + JsonPath.parse(json).let { + styleSelect = it.readInt("$.readBookSelect") ?: 0 + configList.clear() + configList.addAll(it.read>("$.readBook")) + } } fun getConfig(): Config {