@@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.FlowRow
2222import androidx.compose.foundation.layout.PaddingValues
2323import androidx.compose.foundation.layout.Row
2424import androidx.compose.foundation.layout.Spacer
25+ import androidx.compose.foundation.layout.fillMaxSize
2526import androidx.compose.foundation.layout.fillMaxWidth
2627import androidx.compose.foundation.layout.height
2728import androidx.compose.foundation.layout.heightIn
@@ -40,7 +41,6 @@ import androidx.compose.material3.BottomSheetDefaults
4041import androidx.compose.material3.CircularProgressIndicator
4142import androidx.compose.material3.ExperimentalMaterial3Api
4243import androidx.compose.material3.Icon
43- import androidx.compose.material3.IconButton
4444import androidx.compose.material3.MaterialTheme
4545import androidx.compose.material3.ModalBottomSheet
4646import androidx.compose.material3.OutlinedButton
@@ -70,6 +70,7 @@ import androidx.compose.ui.res.painterResource
7070import androidx.compose.ui.res.stringResource
7171import androidx.compose.ui.semantics.contentDescription
7272import androidx.compose.ui.semantics.semantics
73+ import androidx.compose.ui.text.AnnotatedString
7374import androidx.compose.ui.text.Placeholder
7475import androidx.compose.ui.text.PlaceholderVerticalAlign
7576import androidx.compose.ui.text.SpanStyle
@@ -93,6 +94,8 @@ import org.schabi.newpipe.error.ErrorInfo
9394import org.schabi.newpipe.error.ErrorUtil
9495import org.schabi.newpipe.error.UserAction.LONG_PRESS_MENU_ACTION
9596import org.schabi.newpipe.extractor.stream.StreamType
97+ import org.schabi.newpipe.ui.components.common.SimpleTooltipBox
98+ import org.schabi.newpipe.ui.components.common.TooltipIconButton
9699import org.schabi.newpipe.ui.components.menu.LongPressAction.Type.EnqueueNext
97100import org.schabi.newpipe.ui.components.menu.LongPressAction.Type.ShowChannelDetails
98101import org.schabi.newpipe.ui.discardAllTouchesIf
@@ -284,7 +287,6 @@ private fun LongPressMenuContent(
284287 enabled = action.enabled(),
285288 modifier = Modifier
286289 .height(buttonHeight)
287- .fillMaxWidth()
288290 .weight(1F )
289291 )
290292 rowIndex + = 1
@@ -355,22 +357,19 @@ fun LongPressMenuDragHandle(onEditActions: () -> Unit) {
355357 BottomSheetDefaults .DragHandle (
356358 modifier = Modifier .align(Alignment .Center )
357359 )
358- IconButton (
360+
361+ // show a small button here, it's not an important button and it shouldn't
362+ // capture the user attention
363+ TooltipIconButton (
359364 onClick = onEditActions,
360- modifier = Modifier .align(Alignment .CenterEnd )
361- ) {
362- // show a small button here, it's not an important button and it shouldn't
363- // capture the user attention
364- Icon (
365- imageVector = Icons .Default .Tune ,
366- contentDescription = stringResource(R .string.edit),
367- // same color and height as the DragHandle
368- tint = MaterialTheme .colorScheme.onSurfaceVariant,
369- modifier = Modifier
370- .padding(2 .dp)
371- .size(16 .dp)
372- )
373- }
365+ icon = Icons .Default .Tune ,
366+ contentDescription = stringResource(R .string.long_press_menu_actions_editor),
367+ tint = MaterialTheme .colorScheme.onSurfaceVariant,
368+ modifier = Modifier .align(Alignment .CenterEnd ),
369+ iconModifier = Modifier
370+ .padding(2 .dp)
371+ .size(16 .dp)
372+ )
374373 }
375374}
376375
@@ -519,32 +518,42 @@ fun LongPressMenuHeader(
519518 if (subtitle.isNotBlank()) {
520519 Spacer (Modifier .height(1 .dp))
521520
522- Text (
523- text = subtitle,
524- style = MaterialTheme .typography.bodyMedium,
525- inlineContent = getSubtitleInlineContent(),
526- modifier = if (onUploaderClick == null ) {
527- Modifier
521+ if (onUploaderClick == null ) {
522+ LongPressMenuHeaderSubtitle (subtitle)
523+ } else {
524+ val label = if (item.uploader != null ) {
525+ stringResource(R .string.show_channel_details_for, item.uploader)
528526 } else {
529- Modifier .clickable(
530- onClick = onUploaderClick,
531- onClickLabel = if (item.uploader != null ) {
532- stringResource(R .string.show_channel_details_for, item.uploader)
533- } else {
534- stringResource(R .string.show_channel_details)
535- }
527+ stringResource(R .string.show_channel_details)
528+ }
529+ SimpleTooltipBox (
530+ text = label
531+ ) {
532+ LongPressMenuHeaderSubtitle (
533+ subtitle,
534+ Modifier .clickable(onClick = onUploaderClick, onClickLabel = label)
536535 )
537536 }
538- .fillMaxWidth()
539- .fadedMarquee(edgeWidth = 12 .dp)
540- .testTag(" ShowChannelDetails" )
541- )
537+ }
542538 }
543539 }
544540 }
545541 }
546542}
547543
544+ @Composable
545+ private fun LongPressMenuHeaderSubtitle (subtitle : AnnotatedString , modifier : Modifier = Modifier ) {
546+ Text (
547+ text = subtitle,
548+ style = MaterialTheme .typography.bodyMedium,
549+ inlineContent = getSubtitleInlineContent(),
550+ modifier = modifier
551+ .fillMaxWidth()
552+ .fadedMarquee(edgeWidth = 12 .dp)
553+ .testTag(" ShowChannelDetails" )
554+ )
555+ }
556+
548557fun getSubtitleAnnotatedString (
549558 item : LongPressable ,
550559 showLink : Boolean ,
@@ -618,30 +627,33 @@ fun LongPressMenuButton(
618627 icon : ImageVector ,
619628 text : String ,
620629 onClick : () -> Unit ,
621- modifier : Modifier = Modifier ,
622- enabled : Boolean = true
630+ enabled : Boolean ,
631+ modifier : Modifier = Modifier
623632) {
624- // TODO possibly make it so that when you long-press on the button, the label appears on-screen
625- // as a small popup, so in case the label text is cut off the users can still read it in full
626- OutlinedButton (
627- onClick = onClick,
628- enabled = enabled,
629- shape = MaterialTheme .shapes.large,
630- contentPadding = PaddingValues (start = 3 .dp, top = 8 .dp, end = 3 .dp, bottom = 2 .dp),
631- border = null ,
633+ SimpleTooltipBox (
634+ text = text,
632635 modifier = modifier
633636 ) {
634- Column (horizontalAlignment = Alignment .CenterHorizontally ) {
635- Icon (
636- imageVector = icon,
637- contentDescription = null ,
638- modifier = Modifier .size(32 .dp)
639- )
640- FixedHeightCenteredText (
641- text = text,
642- lines = 2 ,
643- style = MaterialTheme .typography.bodySmall
644- )
637+ OutlinedButton (
638+ onClick = onClick,
639+ enabled = enabled,
640+ shape = MaterialTheme .shapes.large,
641+ contentPadding = PaddingValues (start = 3 .dp, top = 8 .dp, end = 3 .dp, bottom = 2 .dp),
642+ border = null ,
643+ modifier = Modifier .fillMaxSize()
644+ ) {
645+ Column (horizontalAlignment = Alignment .CenterHorizontally ) {
646+ Icon (
647+ imageVector = icon,
648+ contentDescription = null ,
649+ modifier = Modifier .size(32 .dp)
650+ )
651+ FixedHeightCenteredText (
652+ text = text,
653+ lines = 2 ,
654+ style = MaterialTheme .typography.bodySmall
655+ )
656+ }
645657 }
646658 }
647659}
@@ -659,6 +671,7 @@ private fun LongPressMenuButtonPreviews() {
659671 icon = entry.icon,
660672 text = stringResource(entry.label),
661673 onClick = { },
674+ enabled = true ,
662675 modifier = Modifier .size(86 .dp)
663676 )
664677 }
0 commit comments