From ca105c81c5f1ebbc9d313db99dbfac462aee41ac Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 4 Nov 2019 17:16:58 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/constant/Bus.kt | 1 + .../main/java/io/legado/app/receiver/MediaButtonReceiver.kt | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) 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 67e6ee84e..f974bdcca 100644 --- a/app/src/main/java/io/legado/app/constant/Bus.kt +++ b/app/src/main/java/io/legado/app/constant/Bus.kt @@ -10,6 +10,7 @@ object Bus { const val BATTERY_CHANGED = "batteryChanged" const val TIME_CHANGED = "timeChanged" const val READ_ALOUD_BUTTON = "readAloudButton" + const val AUDIO_PLAY_BUTTON = "audioPlayButton" const val UP_CONFIG = "upConfig" const val OPEN_CHAPTER = "openChapter" const val REPLACE = "replace" diff --git a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt index 3cad86893..586d13423 100644 --- a/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt +++ b/app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt @@ -6,6 +6,7 @@ import android.content.Intent import android.view.KeyEvent import io.legado.app.constant.Bus import io.legado.app.help.ActivityHelp +import io.legado.app.ui.audio.AudioPlayActivity import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.utils.postEvent @@ -32,7 +33,9 @@ class MediaButtonReceiver : BroadcastReceiver() { } private fun readAloud(context: Context) { - if (!ActivityHelp.isExist(ReadBookActivity::class.java)) { + if (ActivityHelp.isExist(AudioPlayActivity::class.java)) { + postEvent(Bus.READ_ALOUD_BUTTON, true) + } else if (!ActivityHelp.isExist(ReadBookActivity::class.java)) { val intent = Intent(context, ReadBookActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.putExtra("readAloud", true)