pull/71/head^2^2
kunfei 5 years ago
parent 3fdcdec074
commit 39ce729ac2
  1. 8
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt

@ -14,8 +14,11 @@ import io.legado.app.lib.theme.DrawableUtils
import io.legado.app.lib.theme.primaryTextColor import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.utils.NetworkUtils import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import io.legado.app.utils.htmlFormat
import io.legado.app.utils.shareText import io.legado.app.utils.shareText
import kotlinx.android.synthetic.main.activity_rss_read.* import kotlinx.android.synthetic.main.activity_rss_read.*
import org.apache.commons.text.StringEscapeUtils
import org.jsoup.Jsoup
class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_read), class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_read),
ReadRssViewModel.CallBack { ReadRssViewModel.CallBack {
@ -134,9 +137,12 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
return super.onKeyUp(keyCode, event) return super.onKeyUp(keyCode, event)
} }
@SuppressLint("SetJavaScriptEnabled")
private fun readAloud() { private fun readAloud() {
webView.settings.javaScriptEnabled = true
webView.evaluateJavascript("document.documentElement.outerHTML") { webView.evaluateJavascript("document.documentElement.outerHTML") {
viewModel.readAloud(it) val html = StringEscapeUtils.unescapeJson(it)
viewModel.readAloud(Jsoup.parse(html).body().html().htmlFormat())
} }
} }

Loading…
Cancel
Save