@@ -64,41 +64,30 @@ import androidx.compose.ui.tooling.preview.datasource.LoremIpsum
6464import androidx.compose.ui.unit.dp
6565import coil3.compose.AsyncImage
6666import org.schabi.newpipe.R
67- import org.schabi.newpipe.extractor.stream.StreamInfoItem
6867import org.schabi.newpipe.ktx.popFirst
6968import org.schabi.newpipe.ui.components.menu.LongPressAction.Type.EnqueueNext
7069import org.schabi.newpipe.ui.components.menu.LongPressAction.Type.ShowChannelDetails
7170import org.schabi.newpipe.ui.theme.AppTheme
7271import org.schabi.newpipe.ui.theme.customColors
7372import org.schabi.newpipe.util.Either
7473import org.schabi.newpipe.util.Localization
75- import org.schabi.newpipe.util.image.ImageStrategy
7674import java.time.OffsetDateTime
7775
7876fun getLongPressMenuView (
7977 context : Context ,
80- item : StreamInfoItem ,
78+ longPressable : LongPressable ,
79+ longPressActions : List <LongPressAction >,
8180): ComposeView {
8281 return ComposeView (context).apply {
8382 setContent {
84- LongPressMenu (
85- longPressable = LongPressable (
86- title = item.name,
87- url = item.url?.takeIf { it.isNotBlank() },
88- thumbnailUrl = ImageStrategy .choosePreferredImage(item.thumbnails),
89- uploader = item.uploaderName?.takeIf { it.isNotBlank() },
90- uploaderUrl = item.uploaderUrl?.takeIf { it.isNotBlank() },
91- viewCount = item.viewCount.takeIf { it >= 0 },
92- uploadDate = item.uploadDate?.let { Either .right(it.offsetDateTime()) }
93- ? : item.textualUploadDate?.let { Either .left(it) },
94- decoration = item.duration.takeIf { it >= 0 }?.let {
95- LongPressable .Decoration .Duration (it)
96- },
97- ),
98- onDismissRequest = { (this .parent as ViewGroup ).removeView(this ) },
99- longPressActions = LongPressAction .buildActionList(item, false ),
100- onEditActions = {},
101- )
83+ AppTheme {
84+ LongPressMenu (
85+ longPressable = longPressable,
86+ onDismissRequest = { (this .parent as ViewGroup ).removeView(this ) },
87+ longPressActions = longPressActions,
88+ onEditActions = {},
89+ )
90+ }
10291 }
10392 }
10493}
@@ -157,7 +146,6 @@ fun LongPressMenu(
157146 .weight((buttonsPerRow - rowIndex).toFloat()),
158147 )
159148 break
160-
161149 } else if (actionIndex >= 0 ) {
162150 val action = actions[actionIndex]
163151 LongPressMenuButton (
@@ -174,7 +162,6 @@ fun LongPressMenu(
174162 .weight(1F ),
175163 )
176164 rowIndex + = 1
177-
178165 } else if (headerWidthInButtons >= buttonsPerRow) {
179166 // this branch is taken if the header is going to fit on one line
180167 // (i.e. on phones in portrait)
@@ -189,7 +176,6 @@ fun LongPressMenu(
189176 .weight(headerWidthInButtons.toFloat()),
190177 )
191178 rowIndex + = headerWidthInButtons
192-
193179 } else {
194180 // this branch is taken if the header will have some buttons to its
195181 // right (i.e. on tablets or on phones in landscape)
@@ -203,7 +189,6 @@ fun LongPressMenu(
203189 .weight(headerWidthInButtons.toFloat()),
204190 )
205191 rowIndex + = headerWidthInButtons
206-
207192 }
208193 actionIndex + = 1
209194 }
0 commit comments