修复导入阅读配置没有背景的bug

pull/1649/head
kunfei 3 years ago
parent 251e09e53f
commit 23a8428876
  1. 7
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt

@ -366,7 +366,7 @@ object ReadBookConfig {
suspend fun import(byteArray: ByteArray): Config { suspend fun import(byteArray: ByteArray): Config {
return withContext(IO) { return withContext(IO) {
val configZipPath = FileUtils.getPath(appCtx.externalCache, configFileName) val configZipPath = FileUtils.getPath(appCtx.externalCache, "readConfig.zip")
FileUtils.deleteFile(configZipPath) FileUtils.deleteFile(configZipPath)
val zipFile = FileUtils.createFileIfNotExist(configZipPath) val zipFile = FileUtils.createFileIfNotExist(configZipPath)
zipFile.writeBytes(byteArray) zipFile.writeBytes(byteArray)
@ -375,7 +375,7 @@ object ReadBookConfig {
@Suppress("BlockingMethodInNonBlockingContext") @Suppress("BlockingMethodInNonBlockingContext")
ZipUtils.unzipFile(zipFile, FileUtils.createFolderIfNotExist(configDirPath)) ZipUtils.unzipFile(zipFile, FileUtils.createFolderIfNotExist(configDirPath))
val configDir = FileUtils.createFolderIfNotExist(configDirPath) val configDir = FileUtils.createFolderIfNotExist(configDirPath)
val configFile = configDir.getFile("readConfig.json") val configFile = configDir.getFile(configFileName)
val config: Config = GSON.fromJsonObject(configFile.readText())!! val config: Config = GSON.fromJsonObject(configFile.readText())!!
if (config.textFont.isNotEmpty()) { if (config.textFont.isNotEmpty()) {
val fontName = FileUtils.getName(config.textFont) val fontName = FileUtils.getName(config.textFont)
@ -395,6 +395,7 @@ object ReadBookConfig {
bgFile.copyTo(File(bgPath)) bgFile.copyTo(File(bgPath))
} }
} }
config.bgStr = bgPath
} }
if (config.bgTypeNight == 2) { if (config.bgTypeNight == 2) {
val bgName = FileUtils.getName(config.bgStrNight) val bgName = FileUtils.getName(config.bgStrNight)
@ -405,6 +406,7 @@ object ReadBookConfig {
bgFile.copyTo(File(bgPath)) bgFile.copyTo(File(bgPath))
} }
} }
config.bgStrNight = bgPath
} }
if (config.bgTypeEInk == 2) { if (config.bgTypeEInk == 2) {
val bgName = FileUtils.getName(config.bgStrEInk) val bgName = FileUtils.getName(config.bgStrEInk)
@ -415,6 +417,7 @@ object ReadBookConfig {
bgFile.copyTo(File(bgPath)) bgFile.copyTo(File(bgPath))
} }
} }
config.bgStrEInk = bgPath
} }
return@withContext config return@withContext config
} }

Loading…
Cancel
Save