Merge pull request #7194 from KalleStruik/add-to-playlist-in-share

Add a "add to playlist" option in the share menu
This commit is contained in:
litetex 2021-10-13 20:34:07 +02:00 committed by GitHub
commit 4af49ee5a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 264 additions and 180 deletions

View file

@ -8,9 +8,10 @@ import androidx.fragment.app.Fragment;
import org.schabi.newpipe.NewPipeDatabase;
import org.schabi.newpipe.R;
import org.schabi.newpipe.database.stream.model.StreamEntity;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.local.dialog.PlaylistAppendDialog;
import org.schabi.newpipe.local.dialog.PlaylistCreationDialog;
import org.schabi.newpipe.local.dialog.PlaylistDialog;
import org.schabi.newpipe.local.history.HistoryRecordManager;
import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
import org.schabi.newpipe.util.external_communication.KoreUtils;
@ -81,14 +82,16 @@ public enum StreamDialogEntry {
delete(R.string.delete, (fragment, item) -> {
}), // has to be set manually
append_playlist(R.string.append_playlist, (fragment, item) -> {
final PlaylistAppendDialog d = PlaylistAppendDialog
.fromStreamInfoItems(Collections.singletonList(item));
PlaylistAppendDialog.onPlaylistFound(fragment.getContext(),
() -> d.show(fragment.getParentFragmentManager(), "StreamDialogEntry@append_playlist"),
() -> PlaylistCreationDialog.newInstance(d)
.show(fragment.getParentFragmentManager(), "StreamDialogEntry@create_playlist")
append_playlist(R.string.add_to_playlist, (fragment, item) -> {
PlaylistDialog.createCorrespondingDialog(
fragment.getContext(),
Collections.singletonList(new StreamEntity(item)),
dialog -> dialog.show(
fragment.getParentFragmentManager(),
"StreamDialogEntry@"
+ (dialog instanceof PlaylistAppendDialog ? "append" : "create")
+ "_playlist"
)
);
}),