|
@@ -1,5 +1,6 @@
|
|
|
package io.legado.app.ui.book.read.config
|
|
package io.legado.app.ui.book.read.config
|
|
|
|
|
|
|
|
|
|
+import android.annotation.SuppressLint
|
|
|
import android.content.DialogInterface
|
|
import android.content.DialogInterface
|
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
|
import android.view.Gravity
|
|
import android.view.Gravity
|
|
@@ -20,10 +21,7 @@ import io.legado.app.model.ReadBook
|
|
|
import io.legado.app.service.BaseReadAloudService
|
|
import io.legado.app.service.BaseReadAloudService
|
|
|
import io.legado.app.ui.book.read.ReadBookActivity
|
|
import io.legado.app.ui.book.read.ReadBookActivity
|
|
|
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
|
|
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
|
|
|
-import io.legado.app.utils.ColorUtils
|
|
|
|
|
-import io.legado.app.utils.getPrefBoolean
|
|
|
|
|
-import io.legado.app.utils.observeEvent
|
|
|
|
|
-import io.legado.app.utils.toastOnUi
|
|
|
|
|
|
|
+import io.legado.app.utils.*
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
|
|
|
|
|
|
|
|
|
|
|
@@ -67,6 +65,7 @@ class ReadAloudDialog : BaseDialogFragment(R.layout.dialog_read_aloud) {
|
|
|
tvTimer.setTextColor(textColor)
|
|
tvTimer.setTextColor(textColor)
|
|
|
ivTtsSpeechReduce.setColorFilter(textColor)
|
|
ivTtsSpeechReduce.setColorFilter(textColor)
|
|
|
tvTtsSpeed.setTextColor(textColor)
|
|
tvTtsSpeed.setTextColor(textColor)
|
|
|
|
|
+ tvTtsSpeedValue.setTextColor(textColor)
|
|
|
ivTtsSpeechAdd.setColorFilter(textColor)
|
|
ivTtsSpeechAdd.setColorFilter(textColor)
|
|
|
ivCatalog.setColorFilter(textColor)
|
|
ivCatalog.setColorFilter(textColor)
|
|
|
tvCatalog.setTextColor(textColor)
|
|
tvCatalog.setTextColor(textColor)
|
|
@@ -138,6 +137,12 @@ class ReadAloudDialog : BaseDialogFragment(R.layout.dialog_read_aloud) {
|
|
|
//设置保存的默认值
|
|
//设置保存的默认值
|
|
|
seekTtsSpeechRate.progress = AppConfig.ttsSpeechRate
|
|
seekTtsSpeechRate.progress = AppConfig.ttsSpeechRate
|
|
|
seekTtsSpeechRate.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
|
seekTtsSpeechRate.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
|
|
|
|
+
|
|
|
|
|
+ override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
|
|
|
|
+ super.onProgressChanged(seekBar, progress, fromUser)
|
|
|
|
|
+ upTtsSpeechRateText(progress)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
|
|
AppConfig.ttsSpeechRate = seekBar.progress
|
|
AppConfig.ttsSpeechRate = seekBar.progress
|
|
|
upTtsSpeechRate()
|
|
upTtsSpeechRate()
|
|
@@ -156,6 +161,8 @@ class ReadAloudDialog : BaseDialogFragment(R.layout.dialog_read_aloud) {
|
|
|
|
|
|
|
|
private fun upTtsSpeechRateEnabled(enabled: Boolean) {
|
|
private fun upTtsSpeechRateEnabled(enabled: Boolean) {
|
|
|
binding.run {
|
|
binding.run {
|
|
|
|
|
+ upTtsSpeechRateText(AppConfig.ttsSpeechRate)
|
|
|
|
|
+ tvTtsSpeedValue.visible(enabled)
|
|
|
seekTtsSpeechRate.isEnabled = enabled
|
|
seekTtsSpeechRate.isEnabled = enabled
|
|
|
ivTtsSpeechReduce.isEnabled = enabled
|
|
ivTtsSpeechReduce.isEnabled = enabled
|
|
|
ivTtsSpeechAdd.isEnabled = enabled
|
|
ivTtsSpeechAdd.isEnabled = enabled
|
|
@@ -194,6 +201,11 @@ class ReadAloudDialog : BaseDialogFragment(R.layout.dialog_read_aloud) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
|
|
+ private fun upTtsSpeechRateText(value: Int) {
|
|
|
|
|
+ binding.tvTtsSpeedValue.text = ((value + 5) / 10f).toString()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private fun upTtsSpeechRate() {
|
|
private fun upTtsSpeechRate() {
|
|
|
ReadAloud.upTtsSpeechRate(requireContext())
|
|
ReadAloud.upTtsSpeechRate(requireContext())
|
|
|
if (!BaseReadAloudService.pause) {
|
|
if (!BaseReadAloudService.pause) {
|