Merge pull request #4111 from tick-guo/feature-5-buttons
feature# 按钮定义 : 停止, 上一章, 播放, 下一章, 定时
This commit is contained in:
@@ -189,6 +189,8 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
IntentAction.upTtsSpeechRate -> upSpeechRate(true)
|
IntentAction.upTtsSpeechRate -> upSpeechRate(true)
|
||||||
IntentAction.prevParagraph -> prevP()
|
IntentAction.prevParagraph -> prevP()
|
||||||
IntentAction.nextParagraph -> nextP()
|
IntentAction.nextParagraph -> nextP()
|
||||||
|
IntentAction.prev -> prevChapter()
|
||||||
|
IntentAction.next -> nextChapter()
|
||||||
IntentAction.addTimer -> addTimer()
|
IntentAction.addTimer -> addTimer()
|
||||||
IntentAction.setTimer -> setTimer(intent.getIntExtra("minute", 0))
|
IntentAction.setTimer -> setTimer(intent.getIntExtra("minute", 0))
|
||||||
IntentAction.stop -> stopSelf()
|
IntentAction.stop -> stopSelf()
|
||||||
@@ -485,7 +487,7 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
|
|
||||||
private fun choiceMediaStyle(): androidx.media.app.NotificationCompat.MediaStyle {
|
private fun choiceMediaStyle(): androidx.media.app.NotificationCompat.MediaStyle {
|
||||||
val mediaStyle = androidx.media.app.NotificationCompat.MediaStyle()
|
val mediaStyle = androidx.media.app.NotificationCompat.MediaStyle()
|
||||||
.setShowActionsInCompactView(0, 1, 2)
|
.setShowActionsInCompactView(1, 2, 4);
|
||||||
if (isVivoDevice) {
|
if (isVivoDevice) {
|
||||||
//fix #4090 android 14 can not show play control in lock screen
|
//fix #4090 android 14 can not show play control in lock screen
|
||||||
mediaStyle.setMediaSession(mediaSessionCompat.sessionToken)
|
mediaStyle.setMediaSession(mediaSessionCompat.sessionToken)
|
||||||
@@ -525,6 +527,12 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
.setSound(null)
|
.setSound(null)
|
||||||
.setLights(0, 0, 0)
|
.setLights(0, 0, 0)
|
||||||
builder.setLargeIcon(cover)
|
builder.setLargeIcon(cover)
|
||||||
|
// 按钮定义 : 停止, 上一章, 播放, 下一章, 定时
|
||||||
|
builder.addAction(
|
||||||
|
R.drawable.ic_skip_previous,
|
||||||
|
getString(R.string.previous_chapter),
|
||||||
|
aloudServicePendingIntent(IntentAction.prev)
|
||||||
|
)
|
||||||
if (pause) {
|
if (pause) {
|
||||||
builder.addAction(
|
builder.addAction(
|
||||||
R.drawable.ic_play_24dp,
|
R.drawable.ic_play_24dp,
|
||||||
@@ -543,6 +551,11 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
getString(R.string.stop),
|
getString(R.string.stop),
|
||||||
aloudServicePendingIntent(IntentAction.stop)
|
aloudServicePendingIntent(IntentAction.stop)
|
||||||
)
|
)
|
||||||
|
builder.addAction(
|
||||||
|
R.drawable.ic_skip_next,
|
||||||
|
getString(R.string.next_chapter),
|
||||||
|
aloudServicePendingIntent(IntentAction.next)
|
||||||
|
)
|
||||||
builder.addAction(
|
builder.addAction(
|
||||||
R.drawable.ic_time_add_24dp,
|
R.drawable.ic_time_add_24dp,
|
||||||
getString(R.string.set_timer),
|
getString(R.string.set_timer),
|
||||||
@@ -570,6 +583,11 @@ abstract class BaseReadAloudService : BaseService(),
|
|||||||
|
|
||||||
abstract fun aloudServicePendingIntent(actionStr: String): PendingIntent?
|
abstract fun aloudServicePendingIntent(actionStr: String): PendingIntent?
|
||||||
|
|
||||||
|
open fun prevChapter() {
|
||||||
|
toLast = false
|
||||||
|
ReadBook.moveToPrevChapter(true, false)
|
||||||
|
}
|
||||||
|
|
||||||
open fun nextChapter() {
|
open fun nextChapter() {
|
||||||
ReadBook.upReadTime()
|
ReadBook.upReadTime()
|
||||||
AppLog.putDebug("${ReadBook.curTextChapter?.chapter?.title} 朗读结束跳转下一章并朗读")
|
AppLog.putDebug("${ReadBook.curTextChapter?.chapter?.title} 朗读结束跳转下一章并朗读")
|
||||||
|
|||||||
Reference in New Issue
Block a user