pull/32/head
kunfei 5 years ago
parent 7a8b597748
commit 3882705332
  1. 14
      app/src/main/java/io/legado/app/service/ReadAloudService.kt
  2. 8
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  3. 1
      app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt

@ -206,11 +206,19 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener,
private fun newReadAloud(dataKey: String?, play: Boolean) { private fun newReadAloud(dataKey: String?, play: Boolean) {
dataKey?.let { dataKey?.let {
textChapter = IntentDataHelp.getData(dataKey) as? TextChapter textChapter = IntentDataHelp.getData(dataKey) as? TextChapter
textChapter?.let { textChapter?.let { textChapter ->
nowSpeak = 0 nowSpeak = 0
readAloudNumber = it.getReadLength(pageIndex) readAloudNumber = textChapter.getReadLength(pageIndex)
contentList.clear() contentList.clear()
contentList.addAll(it.getUnRead(pageIndex).split("\n")) if (getPrefBoolean("readAloudByPage")) {
for (index in pageIndex..textChapter.lastIndex()) {
textChapter.page(index)?.text?.split("\n")?.let {
contentList.addAll(it)
}
}
} else {
contentList.addAll(textChapter.getUnRead(pageIndex).split("\n"))
}
if (play) playTTS() if (play) playTTS()
} ?: stopSelf() } ?: stopSelf()
} ?: stopSelf() } ?: stopSelf()

@ -460,7 +460,13 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
viewModel.openChapter(it) viewModel.openChapter(it)
page_view.upContent() page_view.upContent()
} }
observeEvent<Boolean>(Bus.READ_ALOUD_BUTTON) { onClickReadAloud() } observeEvent<Boolean>(Bus.READ_ALOUD_BUTTON) {
if (it) {
onClickReadAloud()
} else {
readAloud()
}
}
observeEvent<Boolean>(Bus.UP_CONFIG) { observeEvent<Boolean>(Bus.UP_CONFIG) {
Help.upSystemUiVisibility(window, !read_menu.isVisible) Help.upSystemUiVisibility(window, !read_menu.isVisible)
page_view.upBg() page_view.upBg()

@ -71,6 +71,7 @@ class ReadAloudDialog : DialogFragment() {
cb_by_page.setOnCheckedChangeListener { buttonView, isChecked -> cb_by_page.setOnCheckedChangeListener { buttonView, isChecked ->
if (buttonView.isPressed) { if (buttonView.isPressed) {
requireContext().putPrefBoolean("readAloudByPage", isChecked) requireContext().putPrefBoolean("readAloudByPage", isChecked)
postEvent(Bus.READ_ALOUD_BUTTON, false)
} }
} }
cb_tts_follow_sys.setOnCheckedChangeListener { buttonView, isChecked -> cb_tts_follow_sys.setOnCheckedChangeListener { buttonView, isChecked ->

Loading…
Cancel
Save