From 201f7e9848d2585de9394b22dfdb1af3111fa378 Mon Sep 17 00:00:00 2001 From: Somethingweirdhere Date: Fri, 8 Jun 2018 15:59:05 +0200 Subject: [PATCH] Added share option to Popup and Background queues --- .../newpipe/player/ServicePlayerActivity.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 8b96b651e..7674105e1 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -340,6 +340,13 @@ public abstract class ServicePlayerActivity extends AppCompatActivity return true; }); + final MenuItem share = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, /*pos=*/3, + Menu.NONE, R.string.share); + share.setOnMenuItemClickListener(menuItem -> { + shareUrl(item.getTitle(), item.getUrl()); + return true; + }); + menu.show(); } @@ -509,6 +516,18 @@ public abstract class ServicePlayerActivity extends AppCompatActivity .show(getSupportFragmentManager(), getTag()); } + //////////////////////////////////////////////////////////////////////////// + // Share + //////////////////////////////////////////////////////////////////////////// + + private void shareUrl(String subject, String url) { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_SUBJECT, subject); + intent.putExtra(Intent.EXTRA_TEXT, url); + startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title))); + } + //////////////////////////////////////////////////////////////////////////// // Binding Service Listener ////////////////////////////////////////////////////////////////////////////