@@ -10,9 +10,11 @@ import androidx.compose.material.icons.filled.Cast
1010import androidx.compose.material.icons.filled.Delete
1111import androidx.compose.material.icons.filled.Done
1212import androidx.compose.material.icons.filled.Download
13+ import androidx.compose.material.icons.filled.Edit
1314import androidx.compose.material.icons.filled.Headset
15+ import androidx.compose.material.icons.filled.HideImage
16+ import androidx.compose.material.icons.filled.Image
1417import androidx.compose.material.icons.filled.OpenInBrowser
15- import androidx.compose.material.icons.filled.Panorama
1618import androidx.compose.material.icons.filled.Person
1719import androidx.compose.material.icons.filled.PictureInPicture
1820import androidx.compose.material.icons.filled.PlayArrow
@@ -21,7 +23,9 @@ import androidx.compose.material.icons.filled.Share
2123import androidx.compose.ui.graphics.vector.ImageVector
2224import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
2325import org.schabi.newpipe.R
26+ import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry
2427import org.schabi.newpipe.database.playlist.PlaylistStreamEntry
28+ import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity
2529import org.schabi.newpipe.database.stream.StreamStatisticsEntry
2630import org.schabi.newpipe.database.stream.model.StreamEntity
2731import org.schabi.newpipe.download.DownloadDialog
@@ -62,7 +66,9 @@ data class LongPressAction(
6266 ShowChannelDetails (R .string.show_channel_details, Icons .Default .Person ),
6367 MarkAsWatched (R .string.mark_as_watched, Icons .Default .Done ),
6468 Delete (R .string.delete, Icons .Default .Delete ),
65- SetAsPlaylistThumbnail (R .string.set_as_playlist_thumbnail, Icons .Default .Panorama ),
69+ Rename (R .string.rename, Icons .Default .Edit ),
70+ SetAsPlaylistThumbnail (R .string.set_as_playlist_thumbnail, Icons .Default .Image ),
71+ UnsetPlaylistThumbnail (R .string.unset_playlist_thumbnail, Icons .Default .HideImage ),
6672 ;
6773
6874 // TODO allow actions to return disposables
@@ -106,6 +112,17 @@ data class LongPressAction(
106112 )
107113 }
108114
115+ private fun buildShareActionList (name : String , url : String , thumbnailUrl : String? ): List <LongPressAction > {
116+ return listOf (
117+ Type .Share .buildAction { context ->
118+ ShareUtils .shareText(context, name, url, thumbnailUrl)
119+ },
120+ Type .OpenInBrowser .buildAction { context ->
121+ ShareUtils .openUrlInBrowser(context, url)
122+ },
123+ )
124+ }
125+
109126 @JvmStatic
110127 fun fromStreamInfoItem (
111128 item : StreamInfoItem ,
@@ -209,6 +226,7 @@ data class LongPressAction(
209226 @JvmStatic
210227 fun fromPlaylistStreamEntry (
211228 item : PlaylistStreamEntry ,
229+ // TODO possibly embed these two actions here
212230 onDelete : Runnable ,
213231 onSetAsPlaylistThumbnail : Runnable ,
214232 ): List <LongPressAction > {
@@ -218,5 +236,36 @@ data class LongPressAction(
218236 Type .SetAsPlaylistThumbnail .buildAction { onSetAsPlaylistThumbnail.run () }
219237 )
220238 }
239+
240+ @JvmStatic
241+ fun fromPlaylistMetadataEntry (
242+ item : PlaylistMetadataEntry ,
243+ onRename : Runnable ,
244+ onDelete : Runnable ,
245+ unsetPlaylistThumbnail : Runnable ? ,
246+ ): List <LongPressAction > {
247+ return listOf (
248+ Type .Rename .buildAction { onRename.run () },
249+ Type .Delete .buildAction { onDelete.run () },
250+ Type .UnsetPlaylistThumbnail .buildAction(
251+ enabled = { unsetPlaylistThumbnail != null }
252+ ) { unsetPlaylistThumbnail?.run () }
253+ )
254+ }
255+
256+ @JvmStatic
257+ fun fromPlaylistRemoteEntity (
258+ item : PlaylistRemoteEntity ,
259+ onDelete : Runnable ,
260+ ): List <LongPressAction > {
261+ return buildShareActionList(
262+ item.orderingName ? : " " ,
263+ item.url ? : " " ,
264+ item.thumbnailUrl
265+ ) +
266+ listOf (
267+ Type .Delete .buildAction { onDelete.run () },
268+ )
269+ }
221270 }
222271}
0 commit comments