diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt index f7eef51db..73d6929c6 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt @@ -45,10 +45,18 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener viewModel.importLocal(it) } } - private val exportDirResult = registerForActivityResult(HandleFileContract()) { - it?.let { - viewModel.export(it) - } + private val exportDirResult = registerForActivityResult(HandleFileContract()) { uri -> + uri ?: return@registerForActivityResult + alert(R.string.export_success) { + val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { + editView.hint = getString(R.string.path) + editView.setText(uri.toString()) + } + customView { alertBinding.root } + okButton { + requireContext().sendToClip(uri.toString()) + } + }.show() } override fun onStart() { @@ -118,7 +126,11 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener allowExtensions = arrayOf("txt", "json") } R.id.menu_import_onLine -> importAlert() - R.id.menu_export -> exportDirResult.launch(null) + R.id.menu_export -> exportDirResult.launch { + mode = HandleFileContract.EXPORT + fileName = "httpTts.json" + file = GSON.toJson(adapter.getItems()).toByteArray() + } } return true } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt index db11b0383..9ad6d4690 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineViewModel.kt @@ -63,10 +63,4 @@ class SpeakEngineViewModel(application: Application) : BaseViewModel(application } } - fun export(uri: Uri) { - execute { - val httpTTS = appDb.httpTTSDao.all - uri.writeBytes(context, "httpTts.json", GSON.toJson(httpTTS).toByteArray()) - } - } } \ No newline at end of file