pull/34/head
kunfei 5 years ago
parent c7c96f93c6
commit fd3192e2ab
  1. 9
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  2. 9
      app/src/main/java/io/legado/app/service/HttpReadAloudService.kt
  3. 9
      app/src/main/java/io/legado/app/service/TTSReadAloudService.kt

@ -321,15 +321,12 @@ abstract class BaseReadAloudService : BaseService(),
startForeground(112201, notification) startForeground(112201, notification)
} }
fun readBookActivityPendingIntent(context: Context): PendingIntent { private fun readBookActivityPendingIntent(context: Context): PendingIntent {
val intent = Intent(context, ReadBookActivity::class.java) val intent = Intent(context, ReadBookActivity::class.java)
intent.action = "readBookActivity" intent.action = "readBookActivity"
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
} }
fun aloudServicePendingIntent(context: Context, actionStr: String): PendingIntent { abstract fun aloudServicePendingIntent(context: Context, actionStr: String): PendingIntent
val intent = Intent(context, TTSReadAloudService::class.java)
intent.action = actionStr
return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
} }

@ -1,5 +1,8 @@
package io.legado.app.service package io.legado.app.service
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.media.MediaPlayer import android.media.MediaPlayer
import io.legado.app.constant.Bus import io.legado.app.constant.Bus
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
@ -90,4 +93,10 @@ class HttpReadAloudService : BaseReadAloudService(),
postEvent(Bus.TTS_TURN_PAGE, 2) postEvent(Bus.TTS_TURN_PAGE, 2)
} }
} }
override fun aloudServicePendingIntent(context: Context, actionStr: String): PendingIntent {
val intent = Intent(context, HttpReadAloudService::class.java)
intent.action = actionStr
return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
} }

@ -1,5 +1,8 @@
package io.legado.app.service package io.legado.app.service
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.Build import android.os.Build
import android.speech.tts.TextToSpeech import android.speech.tts.TextToSpeech
import android.speech.tts.UtteranceProgressListener import android.speech.tts.UtteranceProgressListener
@ -185,4 +188,10 @@ class TTSReadAloudService : BaseReadAloudService(), TextToSpeech.OnInitListener
} }
override fun aloudServicePendingIntent(context: Context, actionStr: String): PendingIntent {
val intent = Intent(context, TTSReadAloudService::class.java)
intent.action = actionStr
return PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
} }
Loading…
Cancel
Save