阅读配置导入

pull/363/head
gedoor 4 years ago
parent acf0db017f
commit 19788b6a32
  1. 10
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 16
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  3. 1
      app/src/main/java/io/legado/app/ui/filechooser/FilePicker.kt

@ -25,7 +25,15 @@ object ReadBookConfig {
val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes())
GSON.fromJsonArray<Config>(json)!!
}
val durConfig get() = getConfig(styleSelect)
var durConfig
get() = getConfig(styleSelect)
set(value) {
configList[styleSelect] = value
if (shareLayout) {
configList[5] = value
}
upBg()
}
var bg: Drawable? = null
var bgMeanColor: Int = 0

@ -235,7 +235,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
?.writeBytes(requireContext(), File(configZipPath).readBytes())
}
} else {
val exportPath = FileUtils.getPath(File(uri.toString()), configFileName)
val exportPath = FileUtils.getPath(File(uri.path!!), configFileName)
FileUtils.deleteFile(exportPath)
FileUtils.createFileIfNotExist(exportPath)
.writeBytes(File(configZipPath).readBytes())
@ -274,8 +274,15 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
}
if (config.bgType() == 2) {
val bgName = FileUtils.getName(config.bgStr())
val file = FileUtils.createFileIfNotExist(
requireContext().externalFilesDir,
"bg",
bgName
)
FileUtils.getFile(configDir, bgName).compareTo(file)
}
ReadBookConfig.durConfig = config
postEvent(EventBus.UP_CONFIG, true)
}.onSuccess {
toast("导入成功")
}.onError {
@ -316,9 +323,8 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
if (uri.toString().isContentPath()) {
val doc = DocumentFile.fromSingleUri(requireContext(), uri)
doc?.name?.let {
var file = requireContext().getExternalFilesDir(null)
?: requireContext().filesDir
file = FileUtils.createFileIfNotExist(file, "bg", it)
val file =
FileUtils.createFileIfNotExist(requireContext().externalFilesDir, "bg", it)
kotlin.runCatching {
DocumentUtils.readBytes(requireContext(), doc.uri)
}.getOrNull()?.let { byteArray ->

@ -212,7 +212,6 @@ object FilePicker {
allowExtensions.forEach {
when (it) {
"txt", "xml" -> types.add("text/*")
"zip" -> types.add("application/x-zip-compressed")
else -> types.add("application/$it")
}
}

Loading…
Cancel
Save