@@ -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
@@ -59,7 +63,9 @@ data class LongPressAction(
5963 ShowChannelDetails (R .string.show_channel_details, Icons .Default .Person ),
6064 MarkAsWatched (R .string.mark_as_watched, Icons .Default .Done ),
6165 Delete (R .string.delete, Icons .Default .Delete ),
62- SetAsPlaylistThumbnail (R .string.set_as_playlist_thumbnail, Icons .Default .Panorama ),
66+ Rename (R .string.rename, Icons .Default .Edit ),
67+ SetAsPlaylistThumbnail (R .string.set_as_playlist_thumbnail, Icons .Default .Image ),
68+ UnsetPlaylistThumbnail (R .string.unset_playlist_thumbnail, Icons .Default .HideImage ),
6369 ;
6470
6571 // TODO allow actions to return disposables
@@ -103,6 +109,17 @@ data class LongPressAction(
103109 )
104110 }
105111
112+ private fun buildShareActionList (name : String , url : String , thumbnailUrl : String? ): List <LongPressAction > {
113+ return listOf (
114+ Type .Share .buildAction { context ->
115+ ShareUtils .shareText(context, name, url, thumbnailUrl)
116+ },
117+ Type .OpenInBrowser .buildAction { context ->
118+ ShareUtils .openUrlInBrowser(context, url)
119+ },
120+ )
121+ }
122+
106123 @JvmStatic
107124 fun fromStreamInfoItem (
108125 item : StreamInfoItem ,
@@ -196,6 +213,7 @@ data class LongPressAction(
196213 @JvmStatic
197214 fun fromPlaylistStreamEntry (
198215 item : PlaylistStreamEntry ,
216+ // TODO possibly embed these two actions here
199217 onDelete : Runnable ,
200218 onSetAsPlaylistThumbnail : Runnable ,
201219 ): List <LongPressAction > {
@@ -205,5 +223,32 @@ data class LongPressAction(
205223 Type .SetAsPlaylistThumbnail .buildAction { onSetAsPlaylistThumbnail.run () }
206224 )
207225 }
226+
227+ @JvmStatic
228+ fun fromPlaylistMetadataEntry (
229+ item : PlaylistMetadataEntry ,
230+ onRename : Runnable ,
231+ onDelete : Runnable ,
232+ unsetPlaylistThumbnail : Runnable ? ,
233+ ): List <LongPressAction > {
234+ return listOf (
235+ Type .Rename .buildAction { onRename.run () },
236+ Type .Delete .buildAction { onDelete.run () },
237+ Type .UnsetPlaylistThumbnail .buildAction(
238+ enabled = { unsetPlaylistThumbnail != null }
239+ ) { unsetPlaylistThumbnail?.run () }
240+ )
241+ }
242+
243+ @JvmStatic
244+ fun fromPlaylistRemoteEntity (
245+ item : PlaylistRemoteEntity ,
246+ onDelete : Runnable ,
247+ ): List <LongPressAction > {
248+ return buildShareActionList(item.name, item.url, item.thumbnailUrl) +
249+ listOf (
250+ Type .Delete .buildAction { onDelete.run () },
251+ )
252+ }
208253 }
209254}
0 commit comments