diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index d6635e314..01ce09690 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -490,8 +490,9 @@ class ReadBookActivity : ReadBookBaseActivity(), ReadBook.bookSource?.bookSourceUrl?.let { scopes.add(it) } - ReplaceEditActivity.show( + ReplaceEditActivity.startForResult( this, + requestCodeReplace, pattern = selectedText, scope = scopes.joinToString(";") ) @@ -955,9 +956,6 @@ class ReadBookActivity : ReadBookBaseActivity(), observeEvent(PreferKey.showBrightnessView) { readMenu.upBrightnessState() } - observeEvent(EventBus.REPLACE_RULE_SAVE) { - viewModel.replaceRuleChanged() - } } private fun upScreenTimeOut() { diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt index 9b5926b5f..9ffcb7126 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt @@ -54,6 +54,7 @@ class ReplaceRuleActivity : VMBaseActivity() @@ -179,7 +180,7 @@ class ReplaceRuleActivity : VMBaseActivity - ReplaceEditActivity.show(this) + ReplaceEditActivity.startForResult(this, requestCodeEdit) R.id.menu_group_manage -> GroupManageDialog().show(supportFragmentManager, "groupManage") @@ -260,8 +261,10 @@ class ReplaceRuleActivity : VMBaseActivity if (resultCode == Activity.RESULT_OK) { + requestCodeEdit -> setResult(RESULT_OK) + importRequestCode -> { data?.data?.let { uri -> kotlin.runCatching { uri.readText(this)?.let { @@ -275,14 +278,14 @@ class ReplaceRuleActivity : VMBaseActivity if (resultCode == Activity.RESULT_OK) { + importRequestCodeQr -> { data?.getStringExtra("result")?.let { startActivity { putExtra("source", it) } } } - exportRequestCode -> if (resultCode == RESULT_OK) { + exportRequestCode -> { data?.data?.let { uri -> if (uri.isContentScheme()) { DocumentFile.fromTreeUri(this, uri)?.let { @@ -322,7 +325,7 @@ class ReplaceRuleActivity : VMBaseActivity