Merge branch 'gedoor:master' into master

pull/1118/head
bushixuanqi 3 years ago committed by GitHub
commit 50af7c1ab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt
  2. 13
      app/src/main/java/io/legado/app/ui/book/read/TextActionMenu.kt

@ -13,7 +13,6 @@ import io.legado.app.service.help.ReadBook
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.postEvent
import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.launch
import java.util.*
class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener {
@ -56,9 +55,7 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
play()
}
} else {
launch {
toastOnUi(R.string.tts_init_failed)
}
toastOnUi(R.string.tts_init_failed)
}
}

@ -167,17 +167,22 @@ class TextActionMenu(private val context: Context, private val callBack: CallBac
}
if (!ttsInitFinish) return
if (text == "") return
if (textToSpeech?.isSpeaking == true)
if (textToSpeech?.isSpeaking == true) {
textToSpeech?.stop()
}
textToSpeech?.speak(text, TextToSpeech.QUEUE_ADD, null, "select_text")
lastText = ""
}
@Synchronized
override fun onInit(status: Int) {
textToSpeech?.language = Locale.CHINA
ttsInitFinish = true
readAloud(lastText)
if (status == TextToSpeech.SUCCESS) {
textToSpeech?.language = Locale.CHINA
ttsInitFinish = true
readAloud(lastText)
} else {
context.toastOnUi(R.string.tts_init_failed)
}
}
@RequiresApi(Build.VERSION_CODES.M)

Loading…
Cancel
Save