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 56cc5fb8c..2b3e9a320 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 @@ -13,7 +13,6 @@ import androidx.webkit.WebSettingsCompat import androidx.webkit.WebViewFeature import io.legado.app.R import io.legado.app.base.VMBaseActivity -import io.legado.app.constant.AppConst import io.legado.app.databinding.ActivityRssReadBinding import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.SelectItem @@ -29,7 +28,9 @@ import kotlinx.coroutines.launch import org.apache.commons.text.StringEscapeUtils import org.jsoup.Jsoup - +/** + * rss阅读界面 + */ class ReadRssActivity : VMBaseActivity(false), ReadRssViewModel.CallBack { @@ -202,9 +203,6 @@ class ReadRssActivity : VMBaseActivity binding.webView.settings, WebSettingsCompat.FORCE_DARK_ON ) - } else { - binding.webView - .evaluateJavascript(AppConst.darkWebViewJs, null) } } } @@ -282,6 +280,14 @@ class ReadRssActivity : VMBaseActivity } inner class CustomWebChromeClient : WebChromeClient() { + + override fun onReceivedTitle(view: WebView?, title: String?) { + super.onReceivedTitle(view, title) + title.let { + binding.titleBar.title = title + } + } + override fun onShowCustomView(view: View?, callback: CustomViewCallback?) { requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR binding.llView.invisible() @@ -317,7 +323,9 @@ class ReadRssActivity : VMBaseActivity override fun onPageFinished(view: WebView?, url: String?) { super.onPageFinished(view, url) - upWebViewTheme() + view?.title?.let { title -> + binding.titleBar.title = title + } } private fun shouldOverrideUrlLoading(url: Uri): Boolean { diff --git a/app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt b/app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt index 7bf0e1378..7a42ae8b5 100644 --- a/app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt +++ b/app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt @@ -4,6 +4,8 @@ import android.annotation.SuppressLint import android.content.pm.ActivityInfo import android.net.Uri import android.os.Bundle +import android.view.Menu +import android.view.MenuItem import android.view.View import android.webkit.* import androidx.activity.viewModels @@ -11,7 +13,6 @@ import androidx.webkit.WebSettingsCompat import androidx.webkit.WebViewFeature import io.legado.app.R import io.legado.app.base.VMBaseActivity -import io.legado.app.constant.AppConst import io.legado.app.databinding.ActivityWebViewBinding import io.legado.app.help.AppConfig import io.legado.app.lib.dialogs.SelectItem @@ -39,6 +40,19 @@ class WebViewActivity : VMBaseActivity() { } + override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.web_view, menu) + return super.onCompatCreateOptionsMenu(menu) + } + + override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.menu_open_in_browser -> openUrl("") + R.id.menu_copy_url -> sendToClip("") + } + return super.onCompatOptionsItemSelected(item) + } + @SuppressLint("JavascriptInterface") private fun initWebView() { binding.webView.webChromeClient = CustomWebChromeClient() @@ -83,9 +97,6 @@ class WebViewActivity : VMBaseActivity() { binding.webView.settings, WebSettingsCompat.FORCE_DARK_ON ) - } else { - binding.webView - .evaluateJavascript(AppConst.darkWebViewJs, null) } } } @@ -112,6 +123,14 @@ class WebViewActivity : VMBaseActivity() { } inner class CustomWebChromeClient : WebChromeClient() { + + override fun onReceivedTitle(view: WebView?, title: String?) { + super.onReceivedTitle(view, title) + title?.let { + binding.titleBar.title = it + } + } + override fun onShowCustomView(view: View?, callback: CustomViewCallback?) { requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR binding.llView.invisible() @@ -147,7 +166,9 @@ class WebViewActivity : VMBaseActivity() { override fun onPageFinished(view: WebView?, url: String?) { super.onPageFinished(view, url) - upWebViewTheme() + view?.title?.let { title -> + binding.titleBar.title = title + } } private fun shouldOverrideUrlLoading(url: Uri): Boolean { diff --git a/app/src/main/res/menu/web_view.xml b/app/src/main/res/menu/web_view.xml new file mode 100644 index 000000000..281e17243 --- /dev/null +++ b/app/src/main/res/menu/web_view.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 1fe68aacd..4a816ed21 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -891,5 +891,7 @@ 删除源 购买 横屏双页 + 浏览器打开 + 拷贝url diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 8b8ad47f4..5c42ba161 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -895,5 +895,7 @@ 删除源 购买 横屏双页 + 浏览器打开 + 拷贝url diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index b24b6d308..e8ae30aae 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -895,5 +895,7 @@ 删除源 购买 横屏双页 + 浏览器打开 + 拷贝url diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 08b11c044..9ccbfa41f 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -892,5 +892,7 @@ 删除源 购买 横屏双页 + 浏览器打开 + 拷贝url diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index f39dfab1c..88c9f3f9f 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -894,5 +894,7 @@ 删除源 购买 横屏双页 + 浏览器打开 + 拷贝url diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 9f00fe6f6..9b9015346 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -894,5 +894,7 @@ 删除源 购买 横屏双页 + 浏览器打开 + 拷贝url diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4cbab645a..8d3a35a22 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -895,5 +895,7 @@ 删除源 购买 横屏双页 + 浏览器打开 + 拷贝url