|
|
@ -18,6 +18,10 @@ object ReadBookConfig { |
|
|
|
private val configFilePath = |
|
|
|
private val configFilePath = |
|
|
|
App.INSTANCE.filesDir.absolutePath + File.separator + readConfigFileName |
|
|
|
App.INSTANCE.filesDir.absolutePath + File.separator + readConfigFileName |
|
|
|
val configList: ArrayList<Config> = arrayListOf() |
|
|
|
val configList: ArrayList<Config> = arrayListOf() |
|
|
|
|
|
|
|
private val defaultConfigs by lazy { |
|
|
|
|
|
|
|
val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes()) |
|
|
|
|
|
|
|
GSON.fromJsonArray<Config>(json)!! |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var styleSelect |
|
|
|
var styleSelect |
|
|
|
get() = App.INSTANCE.getPrefInt("readStyleSelect") |
|
|
|
get() = App.INSTANCE.getPrefInt("readStyleSelect") |
|
|
@ -37,7 +41,7 @@ object ReadBookConfig { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun upConfig() { |
|
|
|
fun upConfig() { |
|
|
|
(getConfigs() ?: getDefaultConfigs()).let { |
|
|
|
(getConfigs() ?: defaultConfigs).let { |
|
|
|
configList.clear() |
|
|
|
configList.clear() |
|
|
|
configList.addAll(it) |
|
|
|
configList.addAll(it) |
|
|
|
} |
|
|
|
} |
|
|
@ -55,11 +59,6 @@ object ReadBookConfig { |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun getDefaultConfigs(): List<Config> { |
|
|
|
|
|
|
|
val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes()) |
|
|
|
|
|
|
|
return GSON.fromJsonArray(json)!! |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun upBg() { |
|
|
|
fun upBg() { |
|
|
|
val resources = App.INSTANCE.resources |
|
|
|
val resources = App.INSTANCE.resources |
|
|
|
val dm = resources.displayMetrics |
|
|
|
val dm = resources.displayMetrics |
|
|
@ -76,7 +75,7 @@ object ReadBookConfig { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun resetDur() { |
|
|
|
fun resetDur() { |
|
|
|
getDefaultConfigs()[styleSelect].let { |
|
|
|
defaultConfigs[styleSelect].let { |
|
|
|
getConfig().setBg(it.bgType(), it.bgStr()) |
|
|
|
getConfig().setBg(it.bgType(), it.bgStr()) |
|
|
|
getConfig().setTextColor(it.textColor()) |
|
|
|
getConfig().setTextColor(it.textColor()) |
|
|
|
upBg() |
|
|
|
upBg() |
|
|
@ -85,7 +84,7 @@ object ReadBookConfig { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun resetAll() { |
|
|
|
private fun resetAll() { |
|
|
|
getDefaultConfigs().let { |
|
|
|
defaultConfigs.let { |
|
|
|
configList.clear() |
|
|
|
configList.clear() |
|
|
|
configList.addAll(it) |
|
|
|
configList.addAll(it) |
|
|
|
save() |
|
|
|
save() |
|
|
|