优化,修复在线朗读遇到单行标点时停止朗读的bug

pull/1649/head 3.22.022509
kunfei 3 years ago
parent f31ef3337e
commit 67f64a8fd8
  1. 8
      app/src/main/java/io/legado/app/model/ReadBook.kt
  2. 2
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  3. 10
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  4. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  6. 2
      app/src/main/java/io/legado/app/ui/book/read/page/api/DataSource.kt

@ -224,12 +224,10 @@ object ReadBook : CoroutineScope by MainScope() {
/**
* 当前页数
*/
fun durPageIndex(): Int {
curTextChapter?.let {
return it.getPageIndexByCharIndex(durChapterPos)
val durPageIndex: Int
get() {
return curTextChapter?.getPageIndexByCharIndex(durChapterPos) ?: durChapterPos
}
return durChapterPos
}
/**
* chapterOnDur: 0为当前页,1为下一页,-1为上一页

@ -93,7 +93,7 @@ abstract class BaseReadAloudService : BaseService(),
when (intent?.action) {
IntentAction.play -> {
textChapter = ReadBook.curTextChapter
pageIndex = ReadBook.durPageIndex()
pageIndex = ReadBook.durPageIndex
newReadAloud(
intent.getBooleanExtra("play", true)
)

@ -110,15 +110,11 @@ class HttpReadAloudService : BaseReadAloudService(),
clearSpeakCache()
removeCacheFile()
val httpTts = ReadAloud.httpTTS ?: return@execute
contentList.forEachIndexed { index, item ->
contentList.forEachIndexed { index, content ->
ensureActive()
val speakText = item.replace(AppPattern.notReadAloudRegex, "")
val fileName =
md5SpeakFileName(
httpTts.url,
AppConfig.ttsSpeechRate.toString(),
speakText
)
md5SpeakFileName(httpTts.url, AppConfig.ttsSpeechRate.toString(), content)
val speakText = content.replace(AppPattern.notReadAloudRegex, "")
if (hasSpeakFile(fileName)) { //已经下载好的语音缓存
if (index == nowSpeak) {
val file = getSpeakFileAsMd5(fileName)

@ -290,7 +290,7 @@ class ReadBookActivity : BaseReadBookActivity(),
R.id.menu_download -> showDownloadDialog()
R.id.menu_add_bookmark -> {
val book = ReadBook.book
val page = ReadBook.curTextChapter?.page(ReadBook.durPageIndex())
val page = ReadBook.curTextChapter?.page(ReadBook.durPageIndex)
if (book != null && page != null) {
val bookmark = book.createBookMark().apply {
chapterIndex = ReadBook.durChapterIndex
@ -657,7 +657,7 @@ class ReadBookActivity : BaseReadBookActivity(),
launch {
autoPageProgress = 0
binding.readView.upContent(relativePosition, resetPageOffset)
binding.readMenu.setSeekPage(ReadBook.durPageIndex())
binding.readMenu.setSeekPage(ReadBook.durPageIndex)
loadStates = false
success?.invoke()
}
@ -675,7 +675,7 @@ class ReadBookActivity : BaseReadBookActivity(),
override fun pageChanged() {
launch {
autoPageProgress = 0
binding.readMenu.setSeekPage(ReadBook.durPageIndex())
binding.readMenu.setSeekPage(ReadBook.durPageIndex)
startBackupJob()
}
}

@ -376,7 +376,7 @@ class ReadMenu @JvmOverloads constructor(
binding.tvChapterUrl.gone()
}
binding.seekReadPage.max = it.pageSize.minus(1)
binding.seekReadPage.progress = ReadBook.durPageIndex()
binding.seekReadPage.progress = ReadBook.durPageIndex
binding.tvPre.isEnabled = ReadBook.durChapterIndex != 0
binding.tvNext.isEnabled = ReadBook.durChapterIndex != ReadBook.chapterSize - 1
} ?: let {

@ -5,7 +5,7 @@ import io.legado.app.ui.book.read.page.entities.TextChapter
interface DataSource {
val pageIndex: Int get() = ReadBook.durPageIndex()
val pageIndex: Int get() = ReadBook.durPageIndex
val currentChapter: TextChapter?

Loading…
Cancel
Save