diff --git a/app/src/main/java/io/legado/app/constant/Bus.kt b/app/src/main/java/io/legado/app/constant/Bus.kt index eb2783a8f..d81f8f224 100644 --- a/app/src/main/java/io/legado/app/constant/Bus.kt +++ b/app/src/main/java/io/legado/app/constant/Bus.kt @@ -5,7 +5,7 @@ object Bus { const val UP_BOOK = "sourceDebugLog" const val ALOUD_STATE = "aloud_state" const val TTS_START = "ttsStart" - const val TTS_NEXT = "ttsNextPage" + const val TTS_TURN_PAGE = "ttsTurnPage" const val TTS_DS = "ttsDs" const val BATTERY_CHANGED = "batteryChanged" const val TIME_CHANGED = "timeChanged" 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 bb138ad9f..e6b62b68f 100644 --- a/app/src/main/java/io/legado/app/service/ReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/ReadAloudService.kt @@ -416,7 +416,7 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, readAloudNumber += contentList[nowSpeak].length + 1 nowSpeak += 1 if (nowSpeak >= contentList.size) { - postEvent(Bus.TTS_NEXT, true) + postEvent(Bus.TTS_TURN_PAGE, 2) } } @@ -425,7 +425,7 @@ class ReadAloudService : BaseService(), TextToSpeech.OnInitListener, textChapter?.let { if (readAloudNumber + start > it.getReadLength(pageIndex + 1)) { pageIndex++ - postEvent(Bus.TTS_NEXT, false) + postEvent(Bus.TTS_TURN_PAGE, 1) postEvent(Bus.TTS_START, readAloudNumber + start) } } 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 899074477..a913c90ef 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 @@ -581,13 +581,24 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } } } - observeEvent(Bus.TTS_NEXT) { - if (it) { - moveToNextChapter() - } else { - viewModel.durPageIndex = viewModel.durPageIndex + 1 - page_view.upContent() - viewModel.saveRead() + observeEvent(Bus.TTS_TURN_PAGE) { + when (it) { + 1 -> { + viewModel.durPageIndex = viewModel.durPageIndex + 1 + page_view.upContent() + viewModel.saveRead() + } + 2 -> moveToNextChapter() + -1 -> { + if (viewModel.durPageIndex > 0) { + viewModel.durPageIndex = viewModel.durPageIndex - 1 + page_view.upContent() + viewModel.saveRead() + } else { + moveToPrevChapter() + } + } + -2 -> moveToPrevChapter() } } observeEvent(Bus.REPLACE) { 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 0069e748d..e3f26e37c 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 @@ -18,6 +18,7 @@ import io.legado.app.utils.* import kotlinx.android.synthetic.main.activity_read_book.* import kotlinx.android.synthetic.main.dialog_read_aloud.* import org.jetbrains.anko.sdk27.listeners.onClick +import org.jetbrains.anko.sdk27.listeners.onLongClick class ReadAloudDialog : DialogFragment() { @@ -119,7 +120,9 @@ class ReadAloudDialog : DialogFragment() { iv_stop.onClick { ReadAloudService.stop(requireContext()); dismiss() } iv_play_pause.onClick { postEvent(Bus.READ_ALOUD_BUTTON, true) } iv_play_prev.onClick { ReadAloudService.prevParagraph(requireContext()) } + iv_play_prev.onLongClick { postEvent(Bus.TTS_TURN_PAGE, -2); true } iv_play_next.onClick { ReadAloudService.nextParagraph(requireContext()) } + iv_play_next.onLongClick { postEvent(Bus.TTS_TURN_PAGE, 2); true } } private fun upPlayState(state: Int) {