@@ -52,8 +52,11 @@ import org.schabi.newpipe.player.playqueue.PlayQueue
5252import org.schabi.newpipe.player.playqueue.PlayQueueItem
5353import org.schabi.newpipe.player.playqueue.PlaylistPlayQueue
5454import org.schabi.newpipe.ui.components.menu.icons.BackgroundFromHere
55+ import org.schabi.newpipe.ui.components.menu.icons.BackgroundShuffled
5556import org.schabi.newpipe.ui.components.menu.icons.PlayFromHere
57+ import org.schabi.newpipe.ui.components.menu.icons.PlayShuffled
5658import org.schabi.newpipe.ui.components.menu.icons.PopupFromHere
59+ import org.schabi.newpipe.ui.components.menu.icons.PopupShuffled
5760import org.schabi.newpipe.util.NavigationHelper
5861import org.schabi.newpipe.util.external_communication.KoreUtils
5962import org.schabi.newpipe.util.external_communication.ShareUtils
@@ -73,28 +76,31 @@ data class LongPressAction(
7376 @StringRes val label : Int ,
7477 val icon : ImageVector
7578 ) {
76- Enqueue (0 , R .string.enqueue, Icons .Default .AddToQueue ),
77- EnqueueNext (1 , R .string.enqueue_next_stream, Icons .Default .QueuePlayNext ),
78- Background (2 , R .string.controls_background_title, Icons .Default .Headset ),
79- Popup (3 , R .string.controls_popup_title, Icons .Default .PictureInPicture ),
80- Play (4 , R .string.play, Icons .Default .PlayArrow ),
81- BackgroundFromHere (5 , R .string.background_from_here, Icons .Default .BackgroundFromHere ),
82- PopupFromHere (6 , R .string.popup_from_here, Icons .Default .PopupFromHere ),
83- PlayFromHere (7 , R .string.play_from_here, Icons .Default .PlayFromHere ),
84- PlayWithKodi (8 , R .string.play_with_kodi_title, Icons .Default .Cast ),
85- Download (9 , R .string.download, Icons .Default .Download ),
86- AddToPlaylist (10 , R .string.add_to_playlist, Icons .AutoMirrored .Default .PlaylistAdd ),
87- Share (11 , R .string.share, Icons .Default .Share ),
88- OpenInBrowser (12 , R .string.open_in_browser, Icons .Default .OpenInBrowser ),
89- ShowChannelDetails (13 , R .string.show_channel_details, Icons .Default .Person ),
90- MarkAsWatched (14 , R .string.mark_as_watched, Icons .Default .Done ),
91- Delete (15 , R .string.delete, Icons .Default .Delete ),
92- Rename (16 , R .string.rename, Icons .Default .Edit ),
93- SetAsPlaylistThumbnail (17 , R .string.set_as_playlist_thumbnail, Icons .Default .Image ),
94- UnsetPlaylistThumbnail (18 , R .string.unset_playlist_thumbnail, Icons .Default .HideImage ),
95- Unsubscribe (19 , R .string.unsubscribe, Icons .Default .Delete ),
96- ShowDetails (20 , R .string.play_queue_stream_detail, Icons .Default .Info ),
97- Remove (21 , R .string.play_queue_remove, Icons .Default .Delete );
79+ ShowDetails (0 , R .string.play_queue_stream_detail, Icons .Default .Info ),
80+ Enqueue (1 , R .string.enqueue, Icons .Default .AddToQueue ),
81+ EnqueueNext (2 , R .string.enqueue_next_stream, Icons .Default .QueuePlayNext ),
82+ Background (3 , R .string.controls_background_title, Icons .Default .Headset ),
83+ Popup (4 , R .string.controls_popup_title, Icons .Default .PictureInPicture ),
84+ Play (5 , R .string.play, Icons .Default .PlayArrow ),
85+ BackgroundFromHere (6 , R .string.background_from_here, Icons .Default .BackgroundFromHere ),
86+ PopupFromHere (7 , R .string.popup_from_here, Icons .Default .PopupFromHere ),
87+ PlayFromHere (8 , R .string.play_from_here, Icons .Default .PlayFromHere ),
88+ BackgroundShuffled (9 , R .string.background_shuffled, Icons .Default .BackgroundShuffled ),
89+ PopupShuffled (10 , R .string.popup_shuffled, Icons .Default .PopupShuffled ),
90+ PlayShuffled (11 , R .string.play_shuffled, Icons .Default .PlayShuffled ),
91+ PlayWithKodi (12 , R .string.play_with_kodi_title, Icons .Default .Cast ),
92+ Download (13 , R .string.download, Icons .Default .Download ),
93+ AddToPlaylist (14 , R .string.add_to_playlist, Icons .AutoMirrored .Default .PlaylistAdd ),
94+ Share (15 , R .string.share, Icons .Default .Share ),
95+ OpenInBrowser (16 , R .string.open_in_browser, Icons .Default .OpenInBrowser ),
96+ ShowChannelDetails (17 , R .string.show_channel_details, Icons .Default .Person ),
97+ MarkAsWatched (18 , R .string.mark_as_watched, Icons .Default .Done ),
98+ Rename (19 , R .string.rename, Icons .Default .Edit ),
99+ SetAsPlaylistThumbnail (20 , R .string.set_as_playlist_thumbnail, Icons .Default .Image ),
100+ UnsetPlaylistThumbnail (21 , R .string.unset_playlist_thumbnail, Icons .Default .HideImage ),
101+ Delete (22 , R .string.delete, Icons .Default .Delete ),
102+ Unsubscribe (23 , R .string.unsubscribe, Icons .Default .Delete ),
103+ Remove (24 , R .string.play_queue_remove, Icons .Default .Delete );
98104
99105 fun buildAction (
100106 enabled : () -> Boolean = { true },
@@ -105,9 +111,9 @@ data class LongPressAction(
105111 // ShowChannelDetails is not enabled by default, since navigating to channel details can
106112 // also be done by clicking on the uploader name in the long press menu header
107113 val DefaultEnabledActions : List <Type > = listOf (
108- ShowDetails , Enqueue , EnqueueNext , Background , Popup , BackgroundFromHere , Download ,
109- AddToPlaylist , Share , OpenInBrowser , MarkAsWatched , Delete ,
110- Rename , SetAsPlaylistThumbnail , UnsetPlaylistThumbnail , Unsubscribe , Remove
114+ ShowDetails , Enqueue , EnqueueNext , Background , Popup , BackgroundFromHere ,
115+ BackgroundShuffled , Download , AddToPlaylist , Share , OpenInBrowser , MarkAsWatched ,
116+ Rename , SetAsPlaylistThumbnail , UnsetPlaylistThumbnail , Delete , Unsubscribe , Remove
111117 )
112118 }
113119 }
@@ -159,6 +165,25 @@ data class LongPressAction(
159165 )
160166 }
161167
168+ private fun buildPlayerShuffledActionList (queue : suspend (Context ) -> PlayQueue ): List <LongPressAction > {
169+ val shuffledQueue: suspend (Context ) -> PlayQueue = { context ->
170+ val q = queue(context)
171+ q.fetchAllAndShuffle()
172+ q
173+ }
174+ return listOf (
175+ Type .BackgroundShuffled .buildAction { context ->
176+ NavigationHelper .playOnBackgroundPlayer(context, shuffledQueue(context), true )
177+ },
178+ Type .PopupShuffled .buildAction { context ->
179+ NavigationHelper .playOnPopupPlayer(context, shuffledQueue(context), true )
180+ },
181+ Type .PlayShuffled .buildAction { context ->
182+ NavigationHelper .playOnMainPlayer(context, shuffledQueue(context), false )
183+ }
184+ )
185+ }
186+
162187 private fun buildShareActionList (item : InfoItem ): List <LongPressAction > {
163188 return listOf (
164189 Type .Share .buildAction { context ->
@@ -337,6 +362,7 @@ data class LongPressAction(
337362 unsetPlaylistThumbnail : Runnable ?
338363 ): List <LongPressAction > {
339364 return buildPlayerActionList { LocalPlaylistPlayQueue (item) } +
365+ buildPlayerShuffledActionList { LocalPlaylistPlayQueue (item) } +
340366 listOf (
341367 Type .Rename .buildAction { onRename.run () },
342368 Type .Delete .buildAction { onDelete.run () },
@@ -352,6 +378,7 @@ data class LongPressAction(
352378 onDelete : Runnable
353379 ): List <LongPressAction > {
354380 return buildPlayerActionList { PlaylistPlayQueue (item.serviceId, item.url) } +
381+ buildPlayerShuffledActionList { PlaylistPlayQueue (item.serviceId, item.url) } +
355382 buildShareActionList(
356383 item.orderingName ? : " " ,
357384 item.orderingName ? : " " ,
@@ -368,6 +395,7 @@ data class LongPressAction(
368395 onUnsubscribe : Runnable ?
369396 ): List <LongPressAction > {
370397 return buildPlayerActionList { ChannelTabPlayQueue (item.serviceId, item.url) } +
398+ buildPlayerShuffledActionList { ChannelTabPlayQueue (item.serviceId, item.url) } +
371399 buildShareActionList(item) +
372400 listOfNotNull(
373401 Type .ShowChannelDetails .buildAction { context ->
@@ -385,6 +413,7 @@ data class LongPressAction(
385413 @JvmStatic
386414 fun fromPlaylistInfoItem (item : PlaylistInfoItem ): List <LongPressAction > {
387415 return buildPlayerActionList { PlaylistPlayQueue (item.serviceId, item.url) } +
416+ buildPlayerShuffledActionList { PlaylistPlayQueue (item.serviceId, item.url) } +
388417 buildShareActionList(item)
389418 }
390419 }
0 commit comments