Skip to content

Commit

Permalink
Add a "Add to playlist" item to the remote playlist menu
Browse files Browse the repository at this point in the history
  • Loading branch information
petlyh committed Nov 3, 2021
1 parent 2e862b4 commit ded991e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.schabi.newpipe.NewPipeDatabase;
import org.schabi.newpipe.R;
import org.schabi.newpipe.database.playlist.model.PlaylistRemoteEntity;
import org.schabi.newpipe.database.stream.model.StreamEntity;
import org.schabi.newpipe.databinding.PlaylistControlBinding;
import org.schabi.newpipe.databinding.PlaylistHeaderBinding;
import org.schabi.newpipe.error.ErrorActivity;
Expand All @@ -36,6 +37,7 @@
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
import org.schabi.newpipe.info_list.InfoItemDialog;
import org.schabi.newpipe.local.dialog.PlaylistDialog;
import org.schabi.newpipe.local.playlist.RemotePlaylistManager;
import org.schabi.newpipe.player.MainPlayer.PlayerType;
import org.schabi.newpipe.player.helper.PlayerHolder;
Expand All @@ -53,6 +55,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Flowable;
Expand Down Expand Up @@ -267,6 +270,17 @@ public boolean onOptionsItemSelected(final MenuItem item) {
case R.id.menu_item_bookmark:
onBookmarkClicked();
break;
case R.id.menu_item_append_playlist:
disposables.add(PlaylistDialog.createCorrespondingDialog(
getContext(),
getPlayQueue()
.getStreams()
.stream()
.map(StreamEntity::new)
.collect(Collectors.toList()),
dialog -> dialog.show(getFM(), TAG)
));
break;
default:
return super.onOptionsItemSelected(item);
}
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/menu_playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@
android:orderInCategory="2"
android:title="@string/open_in_browser"
app:showAsAction="never" />

<item
android:id="@+id/menu_item_append_playlist"
android:orderInCategory="3"
android:title="@string/add_to_playlist"
app:showAsAction="never" />
</menu>

0 comments on commit ded991e

Please sign in to comment.