pull/1319/head
gedoor 3 years ago
parent bc0bca2a30
commit fa8d85e721
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  3. 10
      app/src/main/java/io/legado/app/ui/main/bookshelf/BaseBookshelfFragment.kt
  4. 10
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  5. 10
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt

@ -21,6 +21,7 @@ import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.databinding.DialogHttpTtsEditBinding import io.legado.app.databinding.DialogHttpTtsEditBinding
import io.legado.app.databinding.DialogRecyclerViewBinding import io.legado.app.databinding.DialogRecyclerViewBinding
import io.legado.app.databinding.ItemHttpTtsBinding import io.legado.app.databinding.ItemHttpTtsBinding
import io.legado.app.help.DirectLinkUpload
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
@ -49,6 +50,11 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
private val exportDirResult = registerForActivityResult(HandleFileContract()) { uri -> private val exportDirResult = registerForActivityResult(HandleFileContract()) { uri ->
uri ?: return@registerForActivityResult uri ?: return@registerForActivityResult
alert(R.string.export_success) { alert(R.string.export_success) {
if (uri.toString().isAbsUrl()) {
DirectLinkUpload.getSummary()?.let { summary ->
setMessage(summary)
}
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.hint = getString(R.string.path) editView.hint = getString(R.string.path)
editView.setText(uri.toString()) editView.setText(uri.toString())

@ -20,6 +20,7 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.databinding.ActivityBookSourceBinding import io.legado.app.databinding.ActivityBookSourceBinding
import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.DirectLinkUpload
import io.legado.app.help.LocalConfig import io.legado.app.help.LocalConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
@ -76,6 +77,11 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
private val exportDir = registerForActivityResult(HandleFileContract()) { uri -> private val exportDir = registerForActivityResult(HandleFileContract()) { uri ->
uri ?: return@registerForActivityResult uri ?: return@registerForActivityResult
alert(R.string.export_success) { alert(R.string.export_success) {
if (uri.toString().isAbsUrl()) {
DirectLinkUpload.getSummary()?.let { summary ->
setMessage(summary)
}
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.hint = getString(R.string.path) editView.hint = getString(R.string.path)
editView.setText(uri.toString()) editView.setText(uri.toString())

@ -13,6 +13,7 @@ import io.legado.app.data.entities.Book
import io.legado.app.databinding.DialogBookshelfConfigBinding import io.legado.app.databinding.DialogBookshelfConfigBinding
import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.help.DirectLinkUpload
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.ui.about.AppLogDialog import io.legado.app.ui.about.AppLogDialog
import io.legado.app.ui.book.arrange.ArrangeBookActivity import io.legado.app.ui.book.arrange.ArrangeBookActivity
@ -34,9 +35,14 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
viewModel.importBookshelf(text, groupId) viewModel.importBookshelf(text, groupId)
} }
} }
private val exportBookshelf = registerForActivityResult(HandleFileContract()) { private val exportResult = registerForActivityResult(HandleFileContract()) {
it?.let { uri -> it?.let { uri ->
alert(R.string.export_success) { alert(R.string.export_success) {
if (uri.toString().isAbsUrl()) {
DirectLinkUpload.getSummary()?.let { summary ->
setMessage(summary)
}
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.hint = getString(R.string.path) editView.hint = getString(R.string.path)
editView.setText(uri.toString()) editView.setText(uri.toString())
@ -74,7 +80,7 @@ abstract class BaseBookshelfFragment(layoutId: Int) : VMBaseFragment<BookshelfVi
putExtra("groupId", groupId) putExtra("groupId", groupId)
} }
R.id.menu_export_bookshelf -> viewModel.exportBookshelf(books) { R.id.menu_export_bookshelf -> viewModel.exportBookshelf(books) {
exportBookshelf.launch { exportResult.launch {
mode = HandleFileContract.EXPORT mode = HandleFileContract.EXPORT
fileData = Triple( fileData = Triple(
"bookshelf.json", "bookshelf.json",

@ -20,6 +20,7 @@ import io.legado.app.data.entities.ReplaceRule
import io.legado.app.databinding.ActivityReplaceRuleBinding import io.legado.app.databinding.ActivityReplaceRuleBinding
import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.ContentProcessor import io.legado.app.help.ContentProcessor
import io.legado.app.help.DirectLinkUpload
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
@ -77,9 +78,14 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
toastOnUi("readTextError:${it.localizedMessage}") toastOnUi("readTextError:${it.localizedMessage}")
} }
} }
private val exportDir = registerForActivityResult(HandleFileContract()) { uri -> private val exportResult = registerForActivityResult(HandleFileContract()) { uri ->
uri ?: return@registerForActivityResult uri ?: return@registerForActivityResult
alert(R.string.export_success) { alert(R.string.export_success) {
if (uri.toString().isAbsUrl()) {
DirectLinkUpload.getSummary()?.let { summary ->
setMessage(summary)
}
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.hint = getString(R.string.path) editView.hint = getString(R.string.path)
editView.setText(uri.toString()) editView.setText(uri.toString())
@ -230,7 +236,7 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selection) R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selection)
R.id.menu_top_sel -> viewModel.topSelect(adapter.selection) R.id.menu_top_sel -> viewModel.topSelect(adapter.selection)
R.id.menu_bottom_sel -> viewModel.bottomSelect(adapter.selection) R.id.menu_bottom_sel -> viewModel.bottomSelect(adapter.selection)
R.id.menu_export_selection -> exportDir.launch { R.id.menu_export_selection -> exportResult.launch {
mode = HandleFileContract.EXPORT mode = HandleFileContract.EXPORT
fileData = Triple( fileData = Triple(
"exportReplaceRule.json", "exportReplaceRule.json",

@ -17,6 +17,7 @@ import io.legado.app.data.appDb
import io.legado.app.data.entities.RssSource import io.legado.app.data.entities.RssSource
import io.legado.app.databinding.ActivityRssSourceBinding import io.legado.app.databinding.ActivityRssSourceBinding
import io.legado.app.databinding.DialogEditTextBinding import io.legado.app.databinding.DialogEditTextBinding
import io.legado.app.help.DirectLinkUpload
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.primaryTextColor import io.legado.app.lib.theme.primaryTextColor
@ -63,9 +64,14 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
toastOnUi("readTextError:${it.localizedMessage}") toastOnUi("readTextError:${it.localizedMessage}")
} }
} }
private val exportDir = registerForActivityResult(HandleFileContract()) { uri -> private val exportResult = registerForActivityResult(HandleFileContract()) { uri ->
uri ?: return@registerForActivityResult uri ?: return@registerForActivityResult
alert(R.string.export_success) { alert(R.string.export_success) {
if (uri.toString().isAbsUrl()) {
DirectLinkUpload.getSummary()?.let { summary ->
setMessage(summary)
}
}
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.hint = getString(R.string.path) editView.hint = getString(R.string.path)
editView.setText(uri.toString()) editView.setText(uri.toString())
@ -125,7 +131,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selection) R.id.menu_enable_selection -> viewModel.enableSelection(adapter.selection)
R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selection) R.id.menu_disable_selection -> viewModel.disableSelection(adapter.selection)
R.id.menu_del_selection -> viewModel.delSelection(adapter.selection) R.id.menu_del_selection -> viewModel.delSelection(adapter.selection)
R.id.menu_export_selection -> exportDir.launch { R.id.menu_export_selection -> exportResult.launch {
mode = HandleFileContract.EXPORT mode = HandleFileContract.EXPORT
fileData = Triple( fileData = Triple(
"exportRssSource.json", "exportRssSource.json",

Loading…
Cancel
Save