-
-
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
Added the ability to remove all watched videos from a local playlist #3065
Conversation
Thanks for the contribution. I guess the idea is to have a dynamic playlist which contains all videos you want to watch later. Is this what you want to achieve? If this is a case, we might want to create a "watch later" playlist which comes with this feature by default. Otherwise, I'd suggest to move this action to the menu in the toolbar. |
Yeah, a 'watch later' playlist was the idea. I'll look into making the a 'watch later' playlist. Questions:
|
Here is my opinion, sorry for the late response @GradyClark:
This requires an action by the user, but the automatic alternative has this problem: what if one wanted to watch a video, but then changed his mind after opening it? That video would be removed from the watch-later playlist, which was not intended. So I think we should leave this manual. The other advantage of this approach is that there is no need to implement different types of playlists, or such. Basically you just have to move the button you added to the three-dot menu and we are good to go.
@TobiGr For the reasons explained above I think an automatic-removal watch later playlist would be problematic, and the alternative of pressing a button is not that much of a hassle. |
@GradyClark could you provide a test apk based on the latest changes? Just zip it and upload it here |
Here's the zipped apk. |
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.
Are we sure we want to use an AsyncTask
? In the other parts of the repository we use ReactiveX. In this case it would greatly simplify your code, since you could plug in directly to the playlistManager.getPlaylistStreams(playlistId);
flowable.
Anyways, the APK works correctly, thank you :-D
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
Merged it with current 'dev' branch. 8fa29ff APK: |
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 for implementing the ReactiveX method. Now the approach is correct, the things I pointed out are more about style and code organization. :-D
@GradyClark
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
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.
I just realized the algorithm to check for history has a complexity of O(m*n)
, where n
is the number of watched videos and m
is the length of the playlist. This is quadratic and grows fast, needing more and more time to complete as history grows. Take a look at HistoryRecordManage.loadLocalStreamStateBatch(). With that method you can load the watched state of every stream at once and the complexity would be lowered to O(m*log(n))
which is a great improvement.
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
HistoryRecordManage.loadLocalStreamStateBatch() Thanks for the advice! |
Changes: - local_playlist_control.xml * A copy of playlist_control.xml * To hold the 'Remove Watched Videos' buttton - local_playlist_header.xml * Changed the include layout to now include local_playlist_control.xml - strings.xml * added string 'remove_watched' with value 'Remove Watched' - LocalPlaylistFragment.java * Added the functionality to remove watched videos, to the 'Remove Watched Videos' button in local_playlist_control.xml. In the background via AsyncTask. This will also change the playlist's thumbnail, if the thumbnail video is removed. Tested on: - Pixel
…videos. - Removed redundant file 'local_playlist_control' - Fixed grammer issue
…tchedStreams` Replaced unnecessary nested class. Fixed formating issues
Removed merge mistake Reordered code Refactored 'removeWatchedWorker' to 'removeWatchedDisposable'
@GradyClark I pushed a commit that really makes the algoritm |
@TobiGr can I merge this? The work now is polished and fast, as explained in the comment above. |
Sorry for the late reply, I've been busy. Also I haven't been able to test the new code, Android Studio has been troublesome. Once I get that sorted out I will test it, and get back with you on that. As for how the code looks, it looks great! |
Try |
Two things to note which might be good to be displayed to the user in a dialog:
The dialog should have an option to "do not show again". @Stypox @GradyClark @wb9688 What do you think? |
Here is my comment on this PR's usage of ReactiveX that I sent to @Stypox on IRC: |
I don't think there is a way to know for sure that the video watched watched completely. We could have it ignore any video with a 'where you left off' marker.
That was the intended function. Solution: 1st dialog |
Show one "are you sure?" dialog with those 2 things as checkboxes. |
But wouldn't the third option require a database restructuring, to keep track of when every video has been added to a playlist? |
That would require changes to the database, perhaps just warning the user will suffice. |
- Will now execute on the io thread - Added confirmation dialog - Warning the user, and asking if they also want to remove partially watched videos
Latest and Greatest |
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.
I'm not sure about one thing: videos that have been watched for <=5s
would have a null
stream state, since the player saves the timestamp only if it is >5s
. This could cause issues when the user presses "Delete all completely watched videos", since it would also erase videos that have been watched for <=5s
.
Edit: the above concern should not be fixed here, I think. See #3371 (comment)
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
reorganized code
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.
In general the code looks good though
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
Also do not show any dialog if the user is aready removing watched videos in a local playlist
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 again @GradyClark :-D
Your welcome. |
Features:
Tested on:
Pixel
I carefully read the contribution guidelines and agree to them.
EDIT: Changed Location of 'Remove Watched' button to the three dot menu, see below comments for photos.
Before:
Loading Screen:
After: