From 732d7b6178c071767ee63112d41ab61d195700cd Mon Sep 17 00:00:00 2001 From: tick <895866818@qq.com> Date: Tue, 20 Aug 2024 04:47:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feature#=20=E6=8C=89=E9=92=AE=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=20=EF=BC=9A=20=20=E5=81=9C=E6=AD=A2=EF=BC=8C=20?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E7=AB=A0=EF=BC=8C=20=E6=92=AD=E6=94=BE,=20?= =?UTF-8?q?=E4=B8=8B=E4=B8=80=E7=AB=A0=EF=BC=8C=20=E5=AE=9A=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/service/BaseReadAloudService.kt | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) 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 5c68a3dd2..8ff3f94ba 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -189,6 +189,8 @@ abstract class BaseReadAloudService : BaseService(), IntentAction.upTtsSpeechRate -> upSpeechRate(true) IntentAction.prevParagraph -> prevP() IntentAction.nextParagraph -> nextP() + IntentAction.prev -> prevChapter() + IntentAction.next -> nextChapter() IntentAction.addTimer -> addTimer() IntentAction.setTimer -> setTimer(intent.getIntExtra("minute", 0)) IntentAction.stop -> stopSelf() @@ -485,7 +487,7 @@ abstract class BaseReadAloudService : BaseService(), private fun choiceMediaStyle(): androidx.media.app.NotificationCompat.MediaStyle { val mediaStyle = androidx.media.app.NotificationCompat.MediaStyle() - .setShowActionsInCompactView(0, 1, 2) + .setShowActionsInCompactView(0, 2, 4); if (isVivoDevice) { //fix #4090 android 14 can not show play control in lock screen mediaStyle.setMediaSession(mediaSessionCompat.sessionToken) @@ -525,6 +527,17 @@ abstract class BaseReadAloudService : BaseService(), .setSound(null) .setLights(0, 0, 0) builder.setLargeIcon(cover) + // 按钮定义 : 停止, 上一章, 播放, 下一章, 定时 + builder.addAction( + R.drawable.ic_stop_black_24dp, + getString(R.string.stop), + aloudServicePendingIntent(IntentAction.stop) + ) + builder.addAction( + R.drawable.ic_skip_previous, + getString(R.string.previous_chapter), + aloudServicePendingIntent(IntentAction.prev) + ) if (pause) { builder.addAction( R.drawable.ic_play_24dp, @@ -539,9 +552,9 @@ abstract class BaseReadAloudService : BaseService(), ) } builder.addAction( - R.drawable.ic_stop_black_24dp, - getString(R.string.stop), - aloudServicePendingIntent(IntentAction.stop) + R.drawable.ic_skip_next, + getString(R.string.next_chapter), + aloudServicePendingIntent(IntentAction.next) ) builder.addAction( R.drawable.ic_time_add_24dp, @@ -570,6 +583,11 @@ abstract class BaseReadAloudService : BaseService(), abstract fun aloudServicePendingIntent(actionStr: String): PendingIntent? + open fun prevChapter() { + toLast = false + ReadBook.moveToPrevChapter(true, false) + } + open fun nextChapter() { ReadBook.upReadTime() AppLog.putDebug("${ReadBook.curTextChapter?.chapter?.title} 朗读结束跳转下一章并朗读") From 61e48aba8adbb1931f74d3272c7f96f6faa4048d Mon Sep 17 00:00:00 2001 From: tick <895866818@qq.com> Date: Tue, 20 Aug 2024 20:18:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feature#=20=E8=B0=83=E6=95=B4=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E9=A1=BA=E5=BA=8F:=E4=B8=8A=E4=B8=80=E7=AB=A0,?= =?UTF-8?q?=E6=92=AD=E6=94=BE,=E5=81=9C=E6=AD=A2,=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E7=AB=A0,=E5=AE=9A=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/service/BaseReadAloudService.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 8ff3f94ba..2446a6579 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -487,7 +487,7 @@ abstract class BaseReadAloudService : BaseService(), private fun choiceMediaStyle(): androidx.media.app.NotificationCompat.MediaStyle { val mediaStyle = androidx.media.app.NotificationCompat.MediaStyle() - .setShowActionsInCompactView(0, 2, 4); + .setShowActionsInCompactView(1, 2, 4); if (isVivoDevice) { //fix #4090 android 14 can not show play control in lock screen mediaStyle.setMediaSession(mediaSessionCompat.sessionToken) @@ -528,11 +528,6 @@ abstract class BaseReadAloudService : BaseService(), .setLights(0, 0, 0) builder.setLargeIcon(cover) // 按钮定义 : 停止, 上一章, 播放, 下一章, 定时 - builder.addAction( - R.drawable.ic_stop_black_24dp, - getString(R.string.stop), - aloudServicePendingIntent(IntentAction.stop) - ) builder.addAction( R.drawable.ic_skip_previous, getString(R.string.previous_chapter), @@ -551,6 +546,11 @@ abstract class BaseReadAloudService : BaseService(), aloudServicePendingIntent(IntentAction.pause) ) } + builder.addAction( + R.drawable.ic_stop_black_24dp, + getString(R.string.stop), + aloudServicePendingIntent(IntentAction.stop) + ) builder.addAction( R.drawable.ic_skip_next, getString(R.string.next_chapter),