From 0923594e51b4300faade4bce79e49793377be3b1 Mon Sep 17 00:00:00 2001 From: Jared Fantaye Date: Sun, 4 Dec 2022 20:35:06 +0100 Subject: [PATCH] Added option to download items in the queue --- .../java/org/schabi/newpipe/QueueItemMenuUtil.java | 12 ++++++++++++ app/src/main/res/menu/menu_play_queue_item.xml | 3 +++ 2 files changed, 15 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java b/app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java index 7c646d0e4..66c19f86d 100644 --- a/app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java +++ b/app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java @@ -1,5 +1,6 @@ package org.schabi.newpipe; +import static org.schabi.newpipe.util.SparseItemUtil.fetchStreamInfoAndSaveToDatabase; import static org.schabi.newpipe.util.external_communication.ShareUtils.shareText; import android.content.Context; @@ -7,9 +8,11 @@ import android.view.ContextThemeWrapper; import android.view.View; import android.widget.PopupMenu; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentManager; import org.schabi.newpipe.database.stream.model.StreamEntity; +import org.schabi.newpipe.download.DownloadDialog; import org.schabi.newpipe.local.dialog.PlaylistDialog; import org.schabi.newpipe.player.playqueue.PlayQueue; import org.schabi.newpipe.player.playqueue.PlayQueueItem; @@ -75,6 +78,15 @@ public final class QueueItemMenuUtil { shareText(context, item.getTitle(), item.getUrl(), item.getThumbnailUrl()); return true; + case R.id.menu_item_download: + fetchStreamInfoAndSaveToDatabase(context, item.getServiceId(), + item.getUrl(), info -> { + final DownloadDialog downloadDialog = new DownloadDialog(context, + info); + downloadDialog.show(((AppCompatActivity) context) + .getSupportFragmentManager(), "downloadDialog"); + }); + return true; } return false; }); diff --git a/app/src/main/res/menu/menu_play_queue_item.xml b/app/src/main/res/menu/menu_play_queue_item.xml index b23f8008f..00c63e1e0 100644 --- a/app/src/main/res/menu/menu_play_queue_item.xml +++ b/app/src/main/res/menu/menu_play_queue_item.xml @@ -16,4 +16,7 @@ + \ No newline at end of file