diff --git a/app/src/main/java/io/legado/app/service/ReadAloudService.kt b/app/src/main/java/io/legado/app/service/ReadAloudService.kt index 69f451a6e..bb138ad9f 100644 --- a/app/src/main/java/io/legado/app/service/ReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/ReadAloudService.kt @@ -206,11 +206,19 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, private fun newReadAloud(dataKey: String?, play: Boolean) { dataKey?.let { textChapter = IntentDataHelp.getData(dataKey) as? TextChapter - textChapter?.let { + textChapter?.let { textChapter -> nowSpeak = 0 - readAloudNumber = it.getReadLength(pageIndex) + readAloudNumber = textChapter.getReadLength(pageIndex) 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() } ?: stopSelf() } ?: stopSelf() diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index bb30ba243..7c0da36d6 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -460,7 +460,13 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea viewModel.openChapter(it) page_view.upContent() } - observeEvent(Bus.READ_ALOUD_BUTTON) { onClickReadAloud() } + observeEvent(Bus.READ_ALOUD_BUTTON) { + if (it) { + onClickReadAloud() + } else { + readAloud() + } + } observeEvent(Bus.UP_CONFIG) { Help.upSystemUiVisibility(window, !read_menu.isVisible) page_view.upBg() diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt index d182cfa11..0069e748d 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadAloudDialog.kt @@ -71,6 +71,7 @@ class ReadAloudDialog : DialogFragment() { cb_by_page.setOnCheckedChangeListener { buttonView, isChecked -> if (buttonView.isPressed) { requireContext().putPrefBoolean("readAloudByPage", isChecked) + postEvent(Bus.READ_ALOUD_BUTTON, false) } } cb_tts_follow_sys.setOnCheckedChangeListener { buttonView, isChecked ->