pull/32/head
kunfei 5 years ago
parent 359683804f
commit 863568f309
  1. 3
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 16
      app/src/main/java/io/legado/app/help/ReadBookConfig.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

@ -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<Config>()
@ -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<Array<Config>>("$.readBook"))
}
}
fun getConfig(): Config {

Loading…
Cancel
Save