diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt b/app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt index 520587589..977be3b53 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/items/ItemList.kt @@ -19,15 +19,22 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem import org.schabi.newpipe.extractor.stream.StreamInfoItem import org.schabi.newpipe.info_list.ItemViewMode import org.schabi.newpipe.ktx.findFragmentActivity +import org.schabi.newpipe.player.playqueue.PlayQueue import org.schabi.newpipe.ui.components.common.LazyColumnThemedScrollbar import org.schabi.newpipe.ui.components.items.playlist.PlaylistListItem import org.schabi.newpipe.ui.components.items.stream.StreamListItem import org.schabi.newpipe.util.DependentPreferenceHelper import org.schabi.newpipe.util.NavigationHelper +/** + * @param getPlayQueueStartingAt a builder for a queue containing all of the items in this list, + * with the queue index set to the item passed as parameter; return `null` if no "start playing from + * here" options should be shown in the long press menu + */ @Composable fun ItemList( items: List, + getPlayQueueStartingAt: ((item: StreamInfoItem) -> PlayQueue)? = null, mode: ItemViewMode = determineItemViewMode(), listHeader: LazyListScope.() -> Unit = {} ) { @@ -72,7 +79,7 @@ fun ItemList( val item = items[it] if (item is StreamInfoItem) { - StreamListItem(item, showProgress, onClick) + StreamListItem(item, showProgress, getPlayQueueStartingAt, onClick) } else if (item is PlaylistInfoItem) { PlaylistListItem(item, onClick) } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/items/stream/StreamListItem.kt b/app/src/main/java/org/schabi/newpipe/ui/components/items/stream/StreamListItem.kt index dac6d32ae..61d3f0928 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/items/stream/StreamListItem.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/items/stream/StreamListItem.kt @@ -26,16 +26,23 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import org.schabi.newpipe.extractor.stream.StreamInfoItem +import org.schabi.newpipe.player.playqueue.PlayQueue import org.schabi.newpipe.ui.components.menu.LongPressAction import org.schabi.newpipe.ui.components.menu.LongPressMenu import org.schabi.newpipe.ui.components.menu.LongPressable import org.schabi.newpipe.ui.theme.AppTheme +/** + * @param getPlayQueueStartingAt a builder for a queue containing all of the items in this list, + * with the queue index set to the item passed as parameter; return `null` if no "start playing from + * here" options should be shown in the long press menu + */ @OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class) @Composable fun StreamListItem( stream: StreamInfoItem, showProgress: Boolean, + getPlayQueueStartingAt: ((item: StreamInfoItem) -> PlayQueue)? = null, onClick: (StreamInfoItem) -> Unit = {} ) { var showLongPressMenu by rememberSaveable { mutableStateOf(false) } @@ -79,8 +86,10 @@ fun StreamListItem( if (showLongPressMenu) { LongPressMenu( longPressable = LongPressable.fromStreamInfoItem(stream), - // TODO queueFromHere: allow playing the whole list starting from one stream - longPressActions = LongPressAction.fromStreamInfoItem(stream, null), + longPressActions = LongPressAction.fromStreamInfoItem( + stream, + getPlayQueueStartingAt?.let { { it(stream) } } + ), onDismissRequest = { showLongPressMenu = false } ) } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/video/RelatedItems.kt b/app/src/main/java/org/schabi/newpipe/ui/components/video/RelatedItems.kt index 3f444a9d9..1bcb0b87f 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/video/RelatedItems.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/video/RelatedItems.kt @@ -44,6 +44,7 @@ fun RelatedItems(info: StreamInfo) { ItemList( items = info.relatedItems, + getPlayQueueStartingAt = null, // it does not make sense to play related items "from here" mode = ItemViewMode.LIST, listHeader = { item {