-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix "Add to playlist" not working and cleanup "RouterActivity" choice handling #8340
Conversation
RouterActicity
choice handling
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code mostly looks good
|
||
final List<AdapterChoiceItem> returnedItems = new ArrayList<>(); | ||
returnedItems.add(showInfo); // Always present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, why is it always present? Shouldn't it be hidden in cases where it would do the exact same thing as videoPlayer
, to save some space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You would end up with an action "Video player" that behaves like "Show Info". If thought logically it should be exactly opposite: We shouldn't show "Video player" when it can be done with "Show info".
- This would require a ton of if logic and another logical layer on top of the choices. Which is in my opinion overkill.
- It may be unexpected for the user if no "Show info" or "Video player" is present.
- Saving space is not relevant because there is still a huge portion of users that have all entries anyway visible (e.g. if the have auto-play enabled - which is default).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmh ok, then in a separate PR the router activity should be made scrollable. When I have the phone in landscape I can't see all options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't notice that.
Sound's like a new issue 😉
Update: Fixed it on the fly.
The cause of the problem was single_choice_dialog_view
:
The view is used inside:
All those are now scrollable.
And the Player-Notfication configurator
also uses viewbinding now.
If this is too much for the PR I can also create a separate PR.
final List<StreamingService.ServiceInfo.MediaCapability> capabilities = | ||
currentService.getServiceInfo().getMediaCapabilities(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhm, why isn't checkstyle complaining? The =
should be on the newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, from the checkstyle link you provided, the default value is nl
, i.e. putting the operator on new line. It always has been this way in NewPipe, so I think you should stick to that (as you did e.g. for &&
and ||
in if
s), though this is really minor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, from the checkstyle link you provided, the default value is nl, i.e. putting the operator on new line.
It only checks the tokens in the right (not left) column.
It always has been this way in NewPipe...
Also no. Example:
NewPipe/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java
Lines 138 to 147 in 1daece3
public static final String ACTION_SHOW_MAIN_PLAYER = | |
App.PACKAGE_NAME + ".VideoDetailFragment.ACTION_SHOW_MAIN_PLAYER"; | |
public static final String ACTION_HIDE_MAIN_PLAYER = | |
App.PACKAGE_NAME + ".VideoDetailFragment.ACTION_HIDE_MAIN_PLAYER"; | |
public static final String ACTION_PLAYER_STARTED = | |
App.PACKAGE_NAME + ".VideoDetailFragment.ACTION_PLAYER_STARTED"; | |
public static final String ACTION_VIDEO_FRAGMENT_RESUMED = | |
App.PACKAGE_NAME + ".VideoDetailFragment.ACTION_VIDEO_FRAGMENT_RESUMED"; | |
public static final String ACTION_VIDEO_FRAGMENT_STOPPED = | |
App.PACKAGE_NAME + ".VideoDetailFragment.ACTION_VIDEO_FRAGMENT_STOPPED"; |
NewPipe/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java
Lines 131 to 139 in 1daece3
private final ActivityResultLauncher<Intent> requestDownloadSaveAsLauncher = | |
registerForActivityResult( | |
new StartActivityForResult(), this::requestDownloadSaveAsResult); | |
private final ActivityResultLauncher<Intent> requestDownloadPickAudioFolderLauncher = | |
registerForActivityResult( | |
new StartActivityForResult(), this::requestDownloadPickAudioFolderResult); | |
private final ActivityResultLauncher<Intent> requestDownloadPickVideoFolderLauncher = | |
registerForActivityResult( | |
new StartActivityForResult(), this::requestDownloadPickVideoFolderResult); |
Update: I went a bit through git history and found these commits:
- Check code style with Checkstyle #3282 - fda5405 (looks like the origin of the
=
on new line) - Expandable player with unified UI #2907 - d8f7db4 (overwrites/reverts some of these changes)
So apparently someone (cough wb9688) introduced his personal code "style" but didn't persist the changes inside checkstyle and also no one noticed it inside the PR...
Anyway I - and I also think most other developers (as seen above) - favor the =
after assignment style. So I would stick with that ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmh ok. I still don't see why all operators should be on newlines (like you did for ||
below here) but =
should not, but anyway... If this is the standard across the industry, if you have a little spare time please open a PR to enforce such style in checkstyle
serviceSupportsChoice = capabilities.contains(AUDIO); | ||
// Check if the service supports the choice | ||
if (isVideoPlayerSelected && capabilities.contains(VIDEO) | ||
|| isAudioPlayerSelected && capabilities.contains(AUDIO)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parenthesis around the &&
s
c492d1f
to
1f5795d
Compare
1f5795d
to
2985258
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Code looks good to me. I also tested and everything works well.
A note for a separate PR: the "processing, will take a moment" toast should be shown on any action that waits for video info to be obtained. Currently it is only shown for "Add to playlist". I think the same string should also be used for actions in the long-press menu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, when the router activity closes (because the dialog is dismissed), a strange animation is shown with a red line swiping through the screen. I thought this happened on dev, too, but it doesn't. I think it is some activity theming issue.
Look a easy fix: Oh we are still supporting Android 4.4.... So not an easy fix... yay Fixed it only for Android 5+ up because Android 4.4 will soon be no longer supported. And btw, this issue arose in #8332. So a new PR would have been better :) |
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you :-)
What is it?
Description of the changes in your PR
Problem: Setting Preferred 'open' action to "Add to playlist" does nothing when opening a video
Discovered while working on #8332
This PR also cleans up how the choices are handled inside
RouterActivity
. It was until now possible to e.g. download a channel (which resulted in an error/unsupported url page) due to incorrect choice-availability-checks.Now everything is centralized in open place and should be easier to maintain.
Before/After Screenshots/Screen Record
NPRouterActivityDemo1.gif.mp4
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.
Due diligence