pull/46/head
kunfei 5 years ago
parent 2dbc6d60ca
commit ca105c81c5
  1. 1
      app/src/main/java/io/legado/app/constant/Bus.kt
  2. 5
      app/src/main/java/io/legado/app/receiver/MediaButtonReceiver.kt

@ -10,6 +10,7 @@ object Bus {
const val BATTERY_CHANGED = "batteryChanged" const val BATTERY_CHANGED = "batteryChanged"
const val TIME_CHANGED = "timeChanged" const val TIME_CHANGED = "timeChanged"
const val READ_ALOUD_BUTTON = "readAloudButton" const val READ_ALOUD_BUTTON = "readAloudButton"
const val AUDIO_PLAY_BUTTON = "audioPlayButton"
const val UP_CONFIG = "upConfig" const val UP_CONFIG = "upConfig"
const val OPEN_CHAPTER = "openChapter" const val OPEN_CHAPTER = "openChapter"
const val REPLACE = "replace" const val REPLACE = "replace"

@ -6,6 +6,7 @@ import android.content.Intent
import android.view.KeyEvent import android.view.KeyEvent
import io.legado.app.constant.Bus import io.legado.app.constant.Bus
import io.legado.app.help.ActivityHelp 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.ui.book.read.ReadBookActivity
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
@ -32,7 +33,9 @@ class MediaButtonReceiver : BroadcastReceiver() {
} }
private fun readAloud(context: Context) { 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) val intent = Intent(context, ReadBookActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.putExtra("readAloud", true) intent.putExtra("readAloud", true)

Loading…
Cancel
Save