优化 #5584
This commit is contained in:
@@ -13,7 +13,6 @@ import io.legado.app.constant.PreferKey
|
||||
import io.legado.app.help.DefaultData
|
||||
import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.utils.BitmapUtils
|
||||
import io.legado.app.utils.FileDoc
|
||||
import io.legado.app.utils.FileUtils
|
||||
import io.legado.app.utils.GSON
|
||||
import io.legado.app.utils.compress.ZipUtils
|
||||
@@ -469,14 +468,18 @@ object ReadBookConfig {
|
||||
val configFile = configDir.getFile(configFileName)
|
||||
val config: Config = GSON.fromJsonObject<Config>(configFile.readText()).getOrThrow()
|
||||
if (config.textFont.isNotEmpty()) {
|
||||
val fontDoc = FileDoc.fromFile(config.textFont)
|
||||
val fontName = fontDoc.name
|
||||
val fontName = config.textFont
|
||||
val fontPath =
|
||||
FileUtils.getPath(appCtx.externalFiles, "font", fontName)
|
||||
if (!FileUtils.exist(fontPath)) {
|
||||
configDir.getFile(fontName).copyTo(File(fontPath))
|
||||
val fontFile = configDir.getFile(fontName)
|
||||
if (fontFile.exists()) {
|
||||
if (!FileUtils.exist(fontPath)) {
|
||||
fontFile.copyTo(File(fontPath))
|
||||
}
|
||||
config.textFont = fontPath
|
||||
} else {
|
||||
config.textFont = ""
|
||||
}
|
||||
config.textFont = fontPath
|
||||
}
|
||||
if (config.bgType == 2) {
|
||||
val bgName = FileUtils.getName(config.bgStr)
|
||||
|
||||
@@ -274,8 +274,7 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
|
||||
configDir.createFolderReplace()
|
||||
val configFile = configDir.getFile("readConfig.json")
|
||||
configFile.createFileReplace()
|
||||
configFile.writeText(GSON.toJson(ReadBookConfig.getExportConfig()))
|
||||
exportFiles.add(configFile)
|
||||
val config = ReadBookConfig.getExportConfig()
|
||||
val fontPath = ReadBookConfig.textFont
|
||||
if (fontPath.isNotEmpty()) {
|
||||
val fontDoc = FileDoc.fromFile(fontPath)
|
||||
@@ -286,9 +285,12 @@ class BgTextConfigDialog : BaseDialogFragment(R.layout.dialog_read_bg_text) {
|
||||
fontExportFile.outputStream().use { out ->
|
||||
it.copyTo(out)
|
||||
}
|
||||
config.textFont = fontName
|
||||
exportFiles.add(fontExportFile)
|
||||
}
|
||||
}
|
||||
configFile.writeText(GSON.toJson(config))
|
||||
exportFiles.add(configFile)
|
||||
repeat(3) {
|
||||
val path = ReadBookConfig.durConfig.getBgPath(it) ?: return@repeat
|
||||
val bgExportFile = copyBgImage(path, configDir) ?: return@repeat
|
||||
|
||||
Reference in New Issue
Block a user