Skip to content

Redesigned long press menu#12032

Open
Stypox wants to merge 87 commits intoTeamNewPipe:refactorfrom
Stypox:long-press-menu
Open

Redesigned long press menu#12032
Stypox wants to merge 87 commits intoTeamNewPipe:refactorfrom
Stypox:long-press-menu

Conversation

@Stypox
Copy link
Copy Markdown
Member

@Stypox Stypox commented Feb 12, 2025

What is it?

  • [ x ] Feature (user facing)
  • [ x ] Codebase improvement (dev facing)

Description of the changes in your PR

This PR replaces InfoItemDialog with a JetpackCompose-based bottom sheet menu. This new menu is supposed to replace all item long press menus across the app, i.e. streams, playlists, channels. The menu contains more details than before about the stream/playlist/channel that was clicked, laid out in a (imo) nice design.

Please provide feedback both on the code and on the UI, but please keep in mind the points below when suggesting an alternative layout.

Update 11 Feb 2026: this PR is now fully ready for review!

  • The editor is now fully functional, it works with touch and DPAD, and it saves the button arrangement to settings
  • I added the "Background/Popup/Play shuffled" options (I ended up choosing thickness 3), which fetches a few pages of the queue before shuffling it, to solve Shuffle/queuing limited to first 100 videos #875
  • I wrote quite a few UI tests and normal tests (~1500 lines of code)
  • I cleaned up the code and added javadocs everywhere, so hopefully it should be rather easy to review despite the size
  • I updated the PR description with screenshots
  • Sorry for the 87 commits 😅, though I believe they shouldn't be squashed as they contain useful information

Screenshots

Since I put a lot of effort into writing good documentation in the code, I won't extend the description here, but instead show some screenshots:

Video Remote bookmarked playlist Queue item
Video in history Landscape/tablet
Channel Actions editor Dragging an item with DPAD

Motivation and design goals

  • A text-based menu is difficult to read and only allows for a handful of actions, while an icon-based menu is more compact and also easier to use. There still are some labels to explain what the actions do though.
  • The menu puts the most frequent actions always in the same places, so muscle memory can help perform press the buttons faster.
  • Users keep asking for new long press menu actions, therefore the long press actions system should be easily extendable and the set of actions should possibly even be editable by the user.
  • We want to provide the same experience across the app (hence same menu for streams, playlists, channels), which also deduplicates a lot of code.
  • A menu at the bottom of the screen is easier to use in one-handed mode.
  • The menu adapts well to different screen sizes, e.g. by showing more/less buttons or adapting the header with item information.

Some of these points arose after some discussions in the NewPipe Matrix channel

TODO

  • Also use the dialog for playlists
  • Also use the dialog for channels
  • Perform asynchronous stuff with coroutines instead of RxJava3
  • Implement "Start playing from here" actions
  • Handle Kodi action
  • Decide whether to allow the user to customize the menu (there is already a mini settings button in the top right of the menu for that purpose, but now it doesn't do anything)
  • Automatically enable/disable the Kodi action when the corresponding option is enabled/disabled in settings
  • Implement player long press actions for playlists and channels, including "Start shuffled"
  • Handle whether player is running
  • Add UI tests
  • Add documentation
  • Various other TODOs spread out in code
  • Understand which issues are solved by this PR (probably I haven't found them all)

TODO in future PRs

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

@github-actions github-actions Bot added the size/giant PRs with more than 750 changed lines label Feb 12, 2025
@sonarqubecloud
Copy link
Copy Markdown

}
}

Column {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FlowRow could be used here instead.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmh, that's what I was using in the beginning, but I don't think you can have a FlowRow with a maximum amount of items per row, but also have an item that weighs more than the others (i.e. the header). Also, I wanted the buttons to expand as much as possible, to not waste any space.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linked documentation mentions a maxItemsInEachRow attribute.

Copy link
Copy Markdown
Member Author

@Stypox Stypox Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but I need the header to be counted as if it were 4 items. And then if more items can fit alongside the header, I need those to be aligned well. If you want to give it a try with FlowRow go ahead, but I couldn't make it do what I want.

Copy link
Copy Markdown
Member

@Isira-Seneviratne Isira-Seneviratne Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to make the needed changes using FlowRow (it might need to be tweaked a bit).

Could you grant write access? I can't push the commit to this branch.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmmh, I should have given you write access to the NewPipe repository (or maybe you had it already), which should be enough according to what GitHub says:

[...] users with write access to TeamNewPipe/NewPipe can add new commits to your long-press-menu branch.

Anyways, thank you for the patch! I haven't tested it yet (will do tomorrow) but from a brief look it seems like the fact that the header is always 66% of the width means the buttons in the first row won't be aligned like the ones below. Also, the buttons should fill as much horizontal space as possible, so misclicks can still be caught, and there might also be more space for the button label text. One final (minor) thing is that I wanted the layout to scale well just based on the available space, not specifically based on whether the device is landscape or portrait, so the header sizing in your patch does not fulfill this requirement.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One final (minor) thing is that I wanted the layout to scale well just based on the available space, not specifically based on whether the device is landscape or portrait, so the header sizing in your patch does not fulfill this requirement.

That can be implemented using currentWindowAdaptiveInfo().windowSizeClass, like in the determineItemViewMode() method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but what's bad about using BoxWithConstraints and measuring the actual available space?

Copy link
Copy Markdown
Member

@Isira-Seneviratne Isira-Seneviratne Feb 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, though using it results in the IDE checking if the constraints are actually used. Also, it results in a lot more complexity than using FlowRow.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right that it is indeed much more complex, so we might want to change the requirements. In the meantime I will add more documentation on the requirements (so people reading the code know why it was made like that).

@NaN-Sz
Copy link
Copy Markdown

NaN-Sz commented Mar 1, 2025

I suggest something like this:

the idea of a more button is to trigger a second bottom sheet containing the remaining items.
Or perhaps it could expand to cover the entire screen, providing more space.

@Stypox
Copy link
Copy Markdown
Member Author

Stypox commented Mar 1, 2025

@NaN-Sz thanks for the feedback! We already thought of the More button but the bottom sheet dialog already has kind of a way to show more buttons when there are too many (i.e. the menu starts out partially expanded, and you can scroll up to see the other buttons). What do you think about that?

Also, do you think the buttons are too small in my screenshots? Your mockup has much bigger ones, that's why I'm asking. I find the buttons in my screenshots easy to press correctly but it's arguable. Maybe we could put a slider in the "long-press menu's settings menu" to pick a size for buttons. This would be quite a niche setting, but also easy to understand what it does (and we would put it only in the "long-press menu's settings menu", not in the app's settings).

@NaN-Sz
Copy link
Copy Markdown

NaN-Sz commented Mar 1, 2025

What do you think about that?

yes, it's actually better to scroll up than to use a button.

Also, do you think the buttons are too small in my screenshots?

Your buttons are a good size. But bigger buttons are easier to see and more intuitive. Having too many small buttons makes the interface look cluttered.

Maybe we could put a slider in the "long-press menu's settings menu" to pick a size for buttons.

I like the idea of customizing the app, I think it's a good idea.

@NaN-Sz
Copy link
Copy Markdown

NaN-Sz commented Mar 1, 2025

or maybe like this?

@TobiGr
Copy link
Copy Markdown
Contributor

TobiGr commented Mar 7, 2025

These are really good changes to the UI 🚀

I tested this on two devices and personally think that four columns are ok. The less columns we have, the more vertical space is required and thus the actions aren't within the "thumb-radius" anymore. However, it might be necessary to test this on small devices and potentially use three columns on those smaller screens.

I'd also suggest to not show more than three rows of actions by default on the smaller screens. It does not help people to find the stuff they need if their whole screens is plastered with action buttons. I'd vote in favour of the option to expand the bottom sheep by pulling it up which is quite intuitive. I do not think there is a need for a more button.

@Stypox Stypox closed this Mar 14, 2025
@Stypox Stypox deleted the long-press-menu branch March 14, 2025 10:41
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Rewrite Mar 14, 2025
@Stypox Stypox reopened this Mar 14, 2025
@sonarqubecloud
Copy link
Copy Markdown

@TobiGr TobiGr added the GUI Issue is related to the graphical user interface label Mar 15, 2025
@TobiGr TobiGr moved this from Done to In Progress in Rewrite Mar 21, 2025
@shivang1809
Copy link
Copy Markdown

or maybe like this?

Would it be a good idea to make it like only 3 or 4 most used options come on long press (delete, add to playlist, share, background ,etc). And then could be swiped up to show this all like it is. This will reduce vertical space.

A cherry on cake will be if there's a customize option to chose which options should come on long press and all other in swipe up menu.

@ShareASmile ShareASmile added feature request Issue is related to a feature in the app code quality Improvements to the codebase to improve the code quality rewrite Issues and PRs related to rewrite labels Apr 8, 2025
@MD77MD
Copy link
Copy Markdown

MD77MD commented May 2, 2025

the most important option is missing : Open Channel

@Stypox
Copy link
Copy Markdown
Member Author

Stypox commented May 3, 2025

@MD77MD no, it is still there, it was moved under the video name to save some space (it should be noticeable since it's colored in blue)

@Stypox
Copy link
Copy Markdown
Member Author

Stypox commented Jun 3, 2025

Idea to make the "open channel" link more accessible: adding a tiny "open" icon like this one after the channel name

@ShareASmile ShareASmile added the discussion This needs to be discussed before anything is done label Aug 2, 2025
@Stypox Stypox force-pushed the long-press-menu branch 2 times, most recently from 80a12bd to 8b4be69 Compare August 17, 2025 10:54
@Stypox
Copy link
Copy Markdown
Member Author

Stypox commented Aug 17, 2025

@MD77MD would an icon like this make it clearer?

image

@MD77MD
Copy link
Copy Markdown

MD77MD commented Aug 18, 2025

@MD77MD would an icon like this make it clearer?

image

it does...but to tell you the truth, its not necessary. i was just too hasty ... collerd in blue is enough

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it'd be a good idea to introduce separate Stream and Playlist data classes, like how I've done here: #11947

That would remove the need to define multiple factory methods.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good idea. We should definitely have a data type for the UI layer that is independent of the types in the extractor or the database. I don't think I will do the change in this PR though, as it's already quite big. I'd rather first merge #11947 and then rebase on top of it (or the other way around).

Instead of overriding the whole showInfoItemDialog
... and add TODO comments for the `onDelete` implementations, which will be embeddable only after migrating the list fragments to Compose.

Also remove incomplete and misleading toStreamInfoItem() implementations in StreamStatisticsEntry and PlaylistStreamEntry. Now one has to do statisticsEntry.streamEntry.toStreamInfoItem() instead, making it clear that the call only uses data from streamEntry.
Especially in and around LongPressAction.kt
Also add some logging / Toast when fetchAllAndShuffle() has to stop early
Also add 2 tests to make sure all menu buttons are the same size
Also simplify some code in LongPressMenu instantiation
Also make the LongPressMenuEditor appear on top of the LongPressMenu instead of closing and reopening the LongPressMenu
Also improve some tests for LongPressMenu and add some test utility functions
The Work In Progress versions may still be considered useful in case of future changes though!
@Stypox
Copy link
Copy Markdown
Member Author

Stypox commented Feb 11, 2026

Ok, this PR is not fully ready for review and user feedback :-D

  • The editor is now fully functional, it works with touch and DPAD, and it saves the button arrangement to settings
  • I added the "Background/Popup/Play shuffled" options (I ended up choosing thickness 3), which fetches a few pages of the queue before shuffling it, to solve Shuffle/queuing limited to first 100 videos #875
  • I wrote quite a few UI tests and normal tests (~1500 lines of code)
  • I cleaned up the code and added javadocs everywhere, so hopefully it should be rather easy to review despite the size
  • I updated the PR description with screenshots
  • Sorry for the 87 commits 😅, though I believe they shouldn't be squashed as they contain useful information

@TobiGr
Copy link
Copy Markdown
Contributor

TobiGr commented Feb 11, 2026

Thank you!
First impression: that stuff is now cleaner. Perfect! I'll come with a more detailed review later this week.
Just one small thing that I noticed already is that some of the new files do not have any SPDX license identifier headers. Please add them so that we can slowly make NewPipe REUSEable (you chose the perfect video for that screenshot :D)

@TobiGr
Copy link
Copy Markdown
Contributor

TobiGr commented Feb 13, 2026

Testing feedback

Bugs

The menu is not restored on screen rotation: Screen_recording_20260213_112625.webm

Stream that is already marked as watched can still be marked as wathched. You might want to disable that option if the stream is stored as watched (could ne done in a future PR).
Screenshot_NewPipe_20260213_113403

Log.w(TAG, "Actions in settings were not distinct: $actions != $actionsDistinct")
}
return actionsDistinct
} catch (e: NoSuchElementException) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better variable name everywhere please

Suggested change
} catch (e: NoSuchElementException) {
} catch (exception: NoSuchElementException) {

}
}

@Preview(showBackground = true, backgroundColor = 0xFFFFFFFF)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is specifying background color necessary?

val date =
Localization.relativeTimeOrTextual(context, stream.uploadDate, stream.textualUploadDate)

if (views.isEmpty()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use when wherever possible instead of if-else

*/
@Composable
fun TooltipIconButton(
onClick: () -> Unit,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onClick can be made last parameter to allow better kotlin syntax when calling it

.doOnError { throwable -> error = throwable }

fun toStreamInfoItem(): StreamInfoItem {
val item = StreamInfoItem(serviceId, url, title, streamType)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion but maybe we can simply return here with an apply to set other parameters instead of creating a new variable.

/**
* Asserts that [value] is NOT in the range [[l], [r]] (both extremes included).
*/
fun <T : Comparable<T>> assertNotInRange(l: T, r: T, value: T) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better variable names please, for all the function parameters as well.

/**
* Use this instead of passing contexts around in instrumented tests.
*/
val ctx: Context
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please prefer context and instrumentation instead

Copy link
Copy Markdown
Contributor

@TobiGr TobiGr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the new files do not have any SPDX license identifier headers. Please add them so that we can slowly make NewPipe REUSEable.

Comment on lines +298 to +299
// Note: this does a blocking I/O call to the database. Use coroutines when
// migrating to Kotlin/Compose instead.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that is highlighted for the next person taking care of it :)

Suggested change
// Note: this does a blocking I/O call to the database. Use coroutines when
// migrating to Kotlin/Compose instead.
// TODO: this does a blocking I/O call to the database. Use coroutines when
// migrating to Kotlin/Compose instead.

LongPressable.fromPlaylistMetadataEntry(selectedItem),
LongPressAction.fromPlaylistMetadataEntry(
selectedItem,
// Note: this does a blocking I/O call to the database. Use coroutines when
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Note: this does a blocking I/O call to the database. Use coroutines when
// TODO: this does a blocking I/O call to the database. Use coroutines when

Comment on lines 38 to 40
public ChannelTabPlayQueue(final int serviceId,
final ListLinkHandler linkHandler) {
this(serviceId, linkHandler, null, Collections.emptyList(), 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also rename the ListLinkHandler to tabHandler to be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality Improvements to the codebase to improve the code quality discussion This needs to be discussed before anything is done feature request Issue is related to a feature in the app GUI Issue is related to the graphical user interface rewrite Issues and PRs related to rewrite size/giant PRs with more than 750 changed lines

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.