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