From 0923594e51b4300faade4bce79e49793377be3b1 Mon Sep 17 00:00:00 2001 From: Jared Fantaye Date: Sun, 4 Dec 2022 20:35:06 +0100 Subject: [PATCH 1/2] 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 From b3bfec9505ac956883dd62cc5db410568ef1bb1b Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 31 Dec 2022 19:31:24 +0100 Subject: [PATCH 2/2] Use correct fragment manager for download dialog Tapping download on the long-press menu of queue items when the queue is shown inside the player would crash otherwise --- .../main/java/org/schabi/newpipe/QueueItemMenuUtil.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java b/app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java index 66c19f86d..3255489b0 100644 --- a/app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java +++ b/app/src/main/java/org/schabi/newpipe/QueueItemMenuUtil.java @@ -8,7 +8,6 @@ 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; @@ -79,12 +78,11 @@ public final class QueueItemMenuUtil { item.getThumbnailUrl()); return true; case R.id.menu_item_download: - fetchStreamInfoAndSaveToDatabase(context, item.getServiceId(), - item.getUrl(), info -> { + fetchStreamInfoAndSaveToDatabase(context, item.getServiceId(), item.getUrl(), + info -> { final DownloadDialog downloadDialog = new DownloadDialog(context, info); - downloadDialog.show(((AppCompatActivity) context) - .getSupportFragmentManager(), "downloadDialog"); + downloadDialog.show(fragmentManager, "downloadDialog"); }); return true; }