From d30c5d49a298b3f502066f47a91e28ebba13f2e9 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 25 Feb 2021 08:41:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/rss/read/ReadRssActivity.kt | 77 ++++++++++--------- 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index eff2dda40..42372eaf5 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -305,49 +305,15 @@ class ReadRssActivity : VMBaseActivity request: WebResourceRequest? ): Boolean { request?.let { - if (it.url.scheme == "http" || it.url.scheme == "https") { - return false - } else if (it.url.scheme == "yuedu") { - when (it.url.host) { - "booksource" -> { - val intent = Intent( - this@ReadRssActivity, - ImportBookSourceActivity::class.java - ) - intent.data = it.url - startActivity(intent) - } - "rsssource" -> { - val intent = Intent( - this@ReadRssActivity, - ImportRssSourceActivity::class.java - ) - intent.data = it.url - startActivity(intent) - } - "replace" -> { - val intent = Intent( - this@ReadRssActivity, - ImportReplaceRuleActivity::class.java - ) - intent.data = it.url - startActivity(intent) - } - } - return true - } - openUrl(it.url) + return shouldOverrideUrlLoading(it.url) } return true } @Suppress("DEPRECATION") override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean { - if (url?.startsWith("http", true) == true) { - return false - } url?.let { - openUrl(it) + return shouldOverrideUrlLoading(Uri.parse(it)) } return true } @@ -356,6 +322,45 @@ class ReadRssActivity : VMBaseActivity super.onPageFinished(view, url) upWebViewTheme() } + + private fun shouldOverrideUrlLoading(url: Uri): Boolean { + if (url.scheme == "http" || url.scheme == "https") { + return false + } else if (url.scheme == "yuedu") { + when (url.host) { + "booksource" -> { + val intent = Intent( + this@ReadRssActivity, + ImportBookSourceActivity::class.java + ) + intent.data = url + startActivity(intent) + } + "rsssource" -> { + val intent = Intent( + this@ReadRssActivity, + ImportRssSourceActivity::class.java + ) + intent.data = url + startActivity(intent) + } + "replace" -> { + val intent = Intent( + this@ReadRssActivity, + ImportReplaceRuleActivity::class.java + ) + intent.data = url + startActivity(intent) + } + } + return true + } + binding.root.longSnackbar("跳转其它应用", "确认") { + openUrl(url) + } + return true + } + } }