pull/1352/head
gedoor 3 years ago
parent 903f06d10a
commit 8884ba76f8
  1. 20
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  2. 31
      app/src/main/java/io/legado/app/ui/web/WebViewActivity.kt
  3. 15
      app/src/main/res/menu/web_view.xml
  4. 2
      app/src/main/res/values-es-rES/strings.xml
  5. 2
      app/src/main/res/values-ja-rJP/strings.xml
  6. 2
      app/src/main/res/values-pt-rBR/strings.xml
  7. 2
      app/src/main/res/values-zh-rHK/strings.xml
  8. 2
      app/src/main/res/values-zh-rTW/strings.xml
  9. 2
      app/src/main/res/values-zh/strings.xml
  10. 2
      app/src/main/res/values/strings.xml

@ -13,7 +13,6 @@ import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature import androidx.webkit.WebViewFeature
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppConst
import io.legado.app.databinding.ActivityRssReadBinding import io.legado.app.databinding.ActivityRssReadBinding
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.SelectItem import io.legado.app.lib.dialogs.SelectItem
@ -29,7 +28,9 @@ import kotlinx.coroutines.launch
import org.apache.commons.text.StringEscapeUtils import org.apache.commons.text.StringEscapeUtils
import org.jsoup.Jsoup import org.jsoup.Jsoup
/**
* rss阅读界面
*/
class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>(false), class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>(false),
ReadRssViewModel.CallBack { ReadRssViewModel.CallBack {
@ -202,9 +203,6 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
binding.webView.settings, binding.webView.settings,
WebSettingsCompat.FORCE_DARK_ON WebSettingsCompat.FORCE_DARK_ON
) )
} else {
binding.webView
.evaluateJavascript(AppConst.darkWebViewJs, null)
} }
} }
} }
@ -282,6 +280,14 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
} }
inner class CustomWebChromeClient : WebChromeClient() { 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?) { override fun onShowCustomView(view: View?, callback: CustomViewCallback?) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
binding.llView.invisible() binding.llView.invisible()
@ -317,7 +323,9 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
override fun onPageFinished(view: WebView?, url: String?) { override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url) super.onPageFinished(view, url)
upWebViewTheme() view?.title?.let { title ->
binding.titleBar.title = title
}
} }
private fun shouldOverrideUrlLoading(url: Uri): Boolean { private fun shouldOverrideUrlLoading(url: Uri): Boolean {

@ -4,6 +4,8 @@ import android.annotation.SuppressLint
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View import android.view.View
import android.webkit.* import android.webkit.*
import androidx.activity.viewModels import androidx.activity.viewModels
@ -11,7 +13,6 @@ import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature import androidx.webkit.WebViewFeature
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppConst
import io.legado.app.databinding.ActivityWebViewBinding import io.legado.app.databinding.ActivityWebViewBinding
import io.legado.app.help.AppConfig import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.SelectItem import io.legado.app.lib.dialogs.SelectItem
@ -39,6 +40,19 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
} }
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") @SuppressLint("JavascriptInterface")
private fun initWebView() { private fun initWebView() {
binding.webView.webChromeClient = CustomWebChromeClient() binding.webView.webChromeClient = CustomWebChromeClient()
@ -83,9 +97,6 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
binding.webView.settings, binding.webView.settings,
WebSettingsCompat.FORCE_DARK_ON WebSettingsCompat.FORCE_DARK_ON
) )
} else {
binding.webView
.evaluateJavascript(AppConst.darkWebViewJs, null)
} }
} }
} }
@ -112,6 +123,14 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
} }
inner class CustomWebChromeClient : WebChromeClient() { 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?) { override fun onShowCustomView(view: View?, callback: CustomViewCallback?) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
binding.llView.invisible() binding.llView.invisible()
@ -147,7 +166,9 @@ class WebViewActivity : VMBaseActivity<ActivityWebViewBinding, WebViewModel>() {
override fun onPageFinished(view: WebView?, url: String?) { override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url) super.onPageFinished(view, url)
upWebViewTheme() view?.title?.let { title ->
binding.titleBar.title = title
}
} }
private fun shouldOverrideUrlLoading(url: Uri): Boolean { private fun shouldOverrideUrlLoading(url: Uri): Boolean {

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_open_in_browser"
android:title="@string/open_in_browser"
app:showAsAction="never" />
<item
android:id="@+id/menu_copy_url"
android:title="@string/copy_url"
app:showAsAction="never" />
</menu>

@ -891,5 +891,7 @@
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string> <string name="chapter_pay">购买</string>
<string name="double_page_horizontal">横屏双页</string> <string name="double_page_horizontal">横屏双页</string>
<string name="open_in_browser">浏览器打开</string>
<string name="copy_url">拷贝url</string>
</resources> </resources>

@ -895,5 +895,7 @@
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string> <string name="chapter_pay">购买</string>
<string name="double_page_horizontal">横屏双页</string> <string name="double_page_horizontal">横屏双页</string>
<string name="open_in_browser">浏览器打开</string>
<string name="copy_url">拷贝url</string>
</resources> </resources>

@ -895,5 +895,7 @@
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string> <string name="chapter_pay">购买</string>
<string name="double_page_horizontal">横屏双页</string> <string name="double_page_horizontal">横屏双页</string>
<string name="open_in_browser">浏览器打开</string>
<string name="copy_url">拷贝url</string>
</resources> </resources>

@ -892,5 +892,7 @@
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string> <string name="chapter_pay">购买</string>
<string name="double_page_horizontal">横屏双页</string> <string name="double_page_horizontal">横屏双页</string>
<string name="open_in_browser">浏览器打开</string>
<string name="copy_url">拷贝url</string>
</resources> </resources>

@ -894,5 +894,7 @@
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string> <string name="chapter_pay">购买</string>
<string name="double_page_horizontal">横屏双页</string> <string name="double_page_horizontal">横屏双页</string>
<string name="open_in_browser">浏览器打开</string>
<string name="copy_url">拷贝url</string>
</resources> </resources>

@ -894,5 +894,7 @@
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string> <string name="chapter_pay">购买</string>
<string name="double_page_horizontal">横屏双页</string> <string name="double_page_horizontal">横屏双页</string>
<string name="open_in_browser">浏览器打开</string>
<string name="copy_url">拷贝url</string>
</resources> </resources>

@ -895,5 +895,7 @@
<string name="delete_source">删除源</string> <string name="delete_source">删除源</string>
<string name="chapter_pay">购买</string> <string name="chapter_pay">购买</string>
<string name="double_page_horizontal">横屏双页</string> <string name="double_page_horizontal">横屏双页</string>
<string name="open_in_browser">浏览器打开</string>
<string name="copy_url">拷贝url</string>
</resources> </resources>

Loading…
Cancel
Save