Merge pull request #13 from gedoor/master

up
pull/72/head
口口吕 5 years ago committed by GitHub
commit 67261cc1f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/src/main/assets/updateLog.md
  2. 4
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  3. 5
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt

@ -6,6 +6,7 @@
**2020/01/11
* RSS阅读界面添加朗读功能
* 其它一些优化
* 合并KKL369提交的代码,重写LinearLayoutManager,修复书籍目录模糊搜索后scrollToPosition在可见范围不置顶
**2020/01/10
* 合并KKL369提交的代码

@ -14,12 +14,12 @@ import io.legado.app.lib.theme.DrawableUtils
import io.legado.app.lib.theme.primaryTextColor
import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.getViewModel
import io.legado.app.utils.htmlFormat
import io.legado.app.utils.shareText
import kotlinx.android.synthetic.main.activity_rss_read.*
import kotlinx.coroutines.launch
import org.apache.commons.text.StringEscapeUtils
import org.jsoup.Jsoup
import org.jsoup.safety.Whitelist
class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_read),
ReadRssViewModel.CallBack {
@ -149,7 +149,7 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
webView.settings.javaScriptEnabled = true
webView.evaluateJavascript("document.documentElement.outerHTML") {
val html = StringEscapeUtils.unescapeJson(it)
viewModel.readAloud(Jsoup.parse(html).body().html().htmlFormat())
viewModel.readAloud(Jsoup.clean(html, Whitelist()))
}
}
}

@ -110,7 +110,10 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
}
fun readAloud(text: String) {
textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null, "rss")
textToSpeech.stop()
text.split("\n", " ", "  ").forEach {
textToSpeech.speak(it, TextToSpeech.QUEUE_ADD, null, "rss")
}
}
override fun onCleared() {

Loading…
Cancel
Save