diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index 1b49a70c1..dc6a6397a 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -254,7 +254,9 @@ class RssSourceEditActivity : override fun onHelpActionSelect(action: String) { when (action) { - "urlOption" -> UrlOptionDialog(this).show() + "urlOption" -> UrlOptionDialog(this) { + sendText(it) + }.show() "ruleHelp" -> showHelp("ruleHelp") "jsHelp" -> showHelp("jsHelp") "regexHelp" -> showHelp("regexHelp") diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/UrlOptionDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/UrlOptionDialog.kt index 560a33645..866c48dd1 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/UrlOptionDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/UrlOptionDialog.kt @@ -26,7 +26,7 @@ import io.legado.app.utils.GSON import io.legado.app.utils.setLayout import splitties.init.appCtx -class UrlOptionDialog(context: Context) : Dialog(context) { +class UrlOptionDialog(context: Context, private val success: (String) -> Unit) : Dialog(context) { val binding = DialogUrlOptionEditBinding.inflate(layoutInflater) @@ -39,10 +39,25 @@ class UrlOptionDialog(context: Context) : Dialog(context) { super.onCreate(savedInstanceState) setContentView(binding.root) binding.tvOk.setOnClickListener { + success.invoke(GSON.toJson(getUrlOption())) dismiss() } } + private fun getUrlOption(): AnalyzeUrl.UrlOption { + val urlOption = AnalyzeUrl.UrlOption() + urlOption.useWebView(binding.cbUseWebView.isChecked) + urlOption.setMethod(binding.editMethod.text.toString()) + urlOption.setCharset(binding.editMethod.text.toString()) + urlOption.setHeaders(binding.editHeaders.text.toString()) + urlOption.setBody(binding.editBody.text.toString()) + urlOption.setRetry(binding.editRetry.text.toString()) + urlOption.setType(binding.editType.text.toString()) + urlOption.setWebJs(binding.editWebJs.text.toString()) + urlOption.setJs(binding.editJs.text.toString()) + return urlOption + } + } diff --git a/app/src/main/res/layout/dialog_url_option_edit.xml b/app/src/main/res/layout/dialog_url_option_edit.xml index fe806dde4..2434831f7 100644 --- a/app/src/main/res/layout/dialog_url_option_edit.xml +++ b/app/src/main/res/layout/dialog_url_option_edit.xml @@ -108,6 +108,20 @@ + + + + + +