diff --git a/app/src/main/java/io/legado/app/constant/EventBus.kt b/app/src/main/java/io/legado/app/constant/EventBus.kt index 37bbf4be9..f5e9cee25 100644 --- a/app/src/main/java/io/legado/app/constant/EventBus.kt +++ b/app/src/main/java/io/legado/app/constant/EventBus.kt @@ -7,7 +7,8 @@ object EventBus { const val BOOKSHELF_REFRESH = "bookshelfRefresh" const val ALOUD_STATE = "aloud_state" const val TTS_PROGRESS = "ttsStart" - const val TTS_DS = "ttsDs" + const val AUDIO_DS = "audioDs" + const val READ_ALOUD_DS = "readAloudDs" const val BATTERY_CHANGED = "batteryChanged" const val TIME_CHANGED = "timeChanged" const val UP_CONFIG = "upConfig" @@ -17,13 +18,11 @@ object EventBus { const val AUDIO_PROGRESS = "audioProgress" const val AUDIO_SIZE = "audioSize" const val AUDIO_SPEED = "audioSpeed" - const val AUDIO_ERROR = "audioError" const val NOTIFY_MAIN = "notifyMain" const val WEB_SERVICE = "webService" const val UP_DOWNLOAD = "upDownload" const val SAVE_CONTENT = "saveContent" const val CHECK_SOURCE = "checkSource" - const val CHECK_SOURCE_MESSAGE = "checkSourceMessage" const val CHECK_SOURCE_DONE = "checkSourceDone" const val TIP_COLOR = "tipColor" const val SOURCE_CHANGED = "sourceChanged" diff --git a/app/src/main/java/io/legado/app/service/AudioPlayService.kt b/app/src/main/java/io/legado/app/service/AudioPlayService.kt index 88b012f38..8bc5eb1e2 100644 --- a/app/src/main/java/io/legado/app/service/AudioPlayService.kt +++ b/app/src/main/java/io/legado/app/service/AudioPlayService.kt @@ -76,6 +76,7 @@ class AudioPlayService : BaseService(), initMediaSession() initBroadcastReceiver() upMediaSessionPlaybackState(PlaybackStateCompat.STATE_PLAYING) + doDs() } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { @@ -273,7 +274,7 @@ class AudioPlayService : BaseService(), * 定时 */ private fun doDs() { - postEvent(EventBus.TTS_DS, timeMinute) + postEvent(EventBus.AUDIO_DS, timeMinute) upNotification() dsJob?.cancel() dsJob = launch { @@ -287,7 +288,7 @@ class AudioPlayService : BaseService(), AudioPlay.stop(this@AudioPlayService) } } - postEvent(EventBus.TTS_DS, timeMinute) + postEvent(EventBus.AUDIO_DS, timeMinute) upNotification() } } diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index 3f96a338a..eab6548c9 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -206,7 +206,7 @@ abstract class BaseReadAloudService : BaseService(), */ @Synchronized private fun doDs() { - postEvent(EventBus.TTS_DS, timeMinute) + postEvent(EventBus.READ_ALOUD_DS, timeMinute) upNotification() dsJob?.cancel() dsJob = launch { @@ -220,7 +220,7 @@ abstract class BaseReadAloudService : BaseService(), ReadAloud.stop(this@BaseReadAloudService) } } - postEvent(EventBus.TTS_DS, timeMinute) + postEvent(EventBus.READ_ALOUD_DS, timeMinute) upNotification() } } diff --git a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt index 1060f0eaa..e83ebcf59 100644 --- a/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/audio/AudioPlayActivity.kt @@ -1,5 +1,6 @@ package io.legado.app.ui.book.audio +import android.annotation.SuppressLint import android.app.Activity import android.icu.text.SimpleDateFormat import android.os.Build @@ -210,6 +211,7 @@ class AudioPlayActivity : } } + @SuppressLint("SetTextI18n") override fun observeLiveBus() { observeEvent(EventBus.MEDIA_BUTTON) { if (it) { @@ -239,6 +241,10 @@ class AudioPlayActivity : binding.tvSpeed.text = String.format("%.1fX", it) binding.tvSpeed.visible() } + observeEventSticky(EventBus.AUDIO_DS) { + binding.tvTimer.text = "${it}m" + binding.tvTimer.visible(it > 0) + } } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt index 136a2541c..181a50c39 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt @@ -184,7 +184,7 @@ class ReadAloudDialog : BaseDialogFragment(R.layout.dialog_read_aloud) { override fun observeLiveBus() { observeEvent(EventBus.ALOUD_STATE) { upPlayState() } - observeEvent(EventBus.TTS_DS) { binding.seekTimer.progress = it } + observeEvent(EventBus.READ_ALOUD_DS) { binding.seekTimer.progress = it } } interface CallBack { diff --git a/app/src/main/res/layout/activity_audio_play.xml b/app/src/main/res/layout/activity_audio_play.xml index acd36a805..37d157d7f 100644 --- a/app/src/main/res/layout/activity_audio_play.xml +++ b/app/src/main/res/layout/activity_audio_play.xml @@ -2,10 +2,10 @@ + + @@ -58,12 +73,12 @@ android:id="@+id/tv_sub_title" android:layout_width="match_parent" android:layout_height="wrap_content" + android:gravity="center" android:paddingStart="16dp" - android:paddingEnd="16dp" android:paddingTop="6dp" + android:paddingEnd="16dp" android:paddingBottom="6dp" android:textColor="@color/md_white_1000" - android:gravity="center" app:layout_constraintBottom_toTopOf="@+id/ll_player_progress" />