[Android] Display repeat control (if enabled) during podcast mode
Robert Stone
git at videolan.org
Wed Nov 20 06:47:54 UTC 2024
vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Sat Aug 10 08:51:18 2024 -0700| [4936fbe2f07e344e98826fb6a82c93acb6e48f89] | committer: Duncan McNamara
Display repeat control (if enabled) during podcast mode
> https://code.videolan.org/videolan/vlc-android/commit/4936fbe2f07e344e98826fb6a82c93acb6e48f89
---
.../src/org/videolan/vlc/PlaybackService.kt | 47 ++++++++++------------
1 file changed, 21 insertions(+), 26 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 039c4bfe7a..8f3e4ac2d3 100644
--- a/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/application/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -1256,20 +1256,11 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
when {
podcastMode -> {
- addCustomSeekActions(pscb)
- addCustomSpeedActions(pscb)
+ manageAutoActions(actions, pscb, repeatType, true)
pscb.addCustomAction(CUSTOM_ACTION_BOOKMARK, getString(R.string.add_bookmark), R.drawable.ic_bookmark_add)
}
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> {
- if (!isCarMode()) {
- addCustomSeekActions(pscb)
- } else {
- manageAutoActions(actions, pscb, repeatType)
- }
- }
- else -> {
- manageAutoActions(actions, pscb, repeatType)
- }
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && !isCarMode() -> addCustomSeekActions(pscb)
+ else -> manageAutoActions(actions, pscb, repeatType)
}
pscb.setActions(actions.getCapabilities())
mediaSession.setRepeatMode(repeatType)
@@ -1298,25 +1289,29 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
}
}
- private fun manageAutoActions(actions: FlagSet<PlaybackAction>, pscb: PlaybackStateCompat.Builder, repeatType: Int) {
+ private fun manageAutoActions(actions: FlagSet<PlaybackAction>, pscb: PlaybackStateCompat.Builder, repeatType: Int, podcastMode: Boolean = false) {
if (playlistManager.canRepeat())
actions.add(PlaybackAction.ACTION_SET_REPEAT_MODE)
if (playlistManager.canShuffle())
actions.add(PlaybackAction.ACTION_SET_SHUFFLE_MODE)
/* Always add the icons, regardless of the allowed actions */
- val shuffleResId = when {
- isShuffling -> R.drawable.ic_auto_shuffle_enabled
- else -> R.drawable.ic_auto_shuffle_disabled
- }
- pscb.addCustomAction(CUSTOM_ACTION_SHUFFLE, getString(R.string.shuffle_title), shuffleResId)
- val repeatResId = when (repeatType) {
- PlaybackStateCompat.REPEAT_MODE_ALL -> R.drawable.ic_auto_repeat_pressed
- PlaybackStateCompat.REPEAT_MODE_ONE -> R.drawable.ic_auto_repeat_one_pressed
- else -> R.drawable.ic_auto_repeat_normal
- }
- pscb.addCustomAction(CUSTOM_ACTION_REPEAT, getString(R.string.repeat_title), repeatResId)
- addCustomSpeedActions(pscb, settings.getBoolean(ENABLE_ANDROID_AUTO_SPEED_BUTTONS, false))
- addCustomSeekActions(pscb, settings.getBoolean(ENABLE_ANDROID_AUTO_SEEK_BUTTONS, false))
+ if (!podcastMode) {
+ val shuffleResId = when {
+ isShuffling -> R.drawable.ic_auto_shuffle_enabled
+ else -> R.drawable.ic_auto_shuffle_disabled
+ }
+ pscb.addCustomAction(CUSTOM_ACTION_SHUFFLE, getString(R.string.shuffle_title), shuffleResId)
+ }
+ if (!podcastMode || repeatType != PlaybackStateCompat.REPEAT_MODE_NONE) {
+ val repeatResId = when (repeatType) {
+ PlaybackStateCompat.REPEAT_MODE_ALL -> R.drawable.ic_auto_repeat_pressed
+ PlaybackStateCompat.REPEAT_MODE_ONE -> R.drawable.ic_auto_repeat_one_pressed
+ else -> R.drawable.ic_auto_repeat_normal
+ }
+ pscb.addCustomAction(CUSTOM_ACTION_REPEAT, getString(R.string.repeat_title), repeatResId)
+ }
+ addCustomSeekActions(pscb, podcastMode or settings.getBoolean(ENABLE_ANDROID_AUTO_SEEK_BUTTONS, false))
+ addCustomSpeedActions(pscb, podcastMode or settings.getBoolean(ENABLE_ANDROID_AUTO_SPEED_BUTTONS, false))
}
private fun addCustomSeekActions(pscb: PlaybackStateCompat.Builder, showSeekActions: Boolean = true) {
More information about the Android
mailing list