diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 60b595ca2..ff4067850 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -100,7 +100,9 @@ class BookSourceActivity : VMBaseActivity startActivity() R.id.menu_import_source_qr -> startActivityForResult(qrRequestCode) - R.id.menu_share_source -> viewModel.shareSelection(adapter.getSelection()) + R.id.menu_share_source -> viewModel.shareSelection(adapter.getSelection()) { + startActivity(Intent.createChooser(it, getString(R.string.share_selected_source))) + } R.id.menu_group_manage -> GroupManageDialog().show(supportFragmentManager, "groupManage") R.id.menu_import_source_local -> FilePicker diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 126d47dac..0a42eb737 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -7,7 +7,6 @@ import androidx.core.content.FileProvider import androidx.documentfile.provider.DocumentFile import io.legado.app.App import io.legado.app.BuildConfig -import io.legado.app.R import io.legado.app.base.BaseViewModel import io.legado.app.constant.AppPattern import io.legado.app.data.entities.BookSource @@ -167,7 +166,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) } } - fun shareSelection(sources: List) { + fun shareSelection(sources: List, success: ((intent: Intent) -> Unit)) { execute { val intent = Intent(Intent.ACTION_SEND) val file = FileUtils.createFileWithReplace("${context.filesDir}/shareBookSource.json") @@ -183,9 +182,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent }.onSuccess { - context.startActivity( - Intent.createChooser(it, context.getString(R.string.share_selected_source)) - ) + success.invoke(it) } }