From 2837e44bab24ddd2be53578958d097add0f4fa44 Mon Sep 17 00:00:00 2001 From: shan11812 <11812r@gmail.com> Date: Sun, 1 Apr 2018 20:47:24 +0530 Subject: [PATCH] Adds 'Add to Playlist' option to Related and Channel lists --- .../newpipe/fragments/detail/VideoDetailFragment.java | 10 +++++++++- .../fragments/list/channel/ChannelFragment.java | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 74e561f99..c2da9071a 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -86,6 +86,7 @@ import org.schabi.newpipe.util.ThemeHelper; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import icepick.State; @@ -549,7 +550,8 @@ public class VideoDetailFragment final String[] commands = new String[]{ context.getResources().getString(R.string.enqueue_on_background), - context.getResources().getString(R.string.enqueue_on_popup) + context.getResources().getString(R.string.enqueue_on_popup), + context.getResources().getString(R.string.append_playlist) }; final DialogInterface.OnClickListener actions = (DialogInterface dialogInterface, int i) -> { @@ -560,6 +562,12 @@ public class VideoDetailFragment case 1: NavigationHelper.enqueueOnPopupPlayer(getActivity(), new SinglePlayQueue(item)); break; + case 2: + if (getFragmentManager() != null) { + PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item)) + .show(getFragmentManager(), TAG); + } + break; default: break; } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index dbc61961e..683286764 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -36,6 +36,7 @@ import org.schabi.newpipe.extractor.stream.Stream; import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.fragments.list.BaseListInfoFragment; +import org.schabi.newpipe.fragments.local.dialog.PlaylistAppendDialog; import org.schabi.newpipe.info_list.InfoItemDialog; import org.schabi.newpipe.playlist.ChannelPlayQueue; import org.schabi.newpipe.playlist.PlayQueue; @@ -49,6 +50,7 @@ import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.NavigationHelper; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; @@ -161,6 +163,7 @@ public class ChannelFragment extends BaseListInfoFragment { context.getResources().getString(R.string.start_here_on_main), context.getResources().getString(R.string.start_here_on_background), context.getResources().getString(R.string.start_here_on_popup), + context.getResources().getString(R.string.append_playlist) }; final DialogInterface.OnClickListener actions = new DialogInterface.OnClickListener() { @@ -183,6 +186,12 @@ public class ChannelFragment extends BaseListInfoFragment { case 4: NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index)); break; + case 5: + if (getFragmentManager() != null) { + PlaylistAppendDialog.fromStreamInfoItems(Collections.singletonList(item)) + .show(getFragmentManager(), TAG); + } + break; default: break; }