From b93d94b0bdea766a1269209c86e7c833610a6307 Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Tue, 9 Jan 2018 12:41:30 +0100 Subject: [PATCH] Add subject to shared URL's (fixes #975) --- .../org/schabi/newpipe/fragments/BaseStateFragment.java | 4 +++- .../newpipe/fragments/detail/VideoDetailFragment.java | 7 +------ .../newpipe/fragments/list/channel/ChannelFragment.java | 2 +- .../newpipe/fragments/list/playlist/PlaylistFragment.java | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java index 2ee467758..121bc46a2 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/BaseStateFragment.java @@ -19,6 +19,7 @@ import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.R; import org.schabi.newpipe.ReCaptchaActivity; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; +import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.ExtractorHelper; @@ -252,9 +253,10 @@ public abstract class BaseStateFragment extends BaseFragment implements ViewC startActivity(intent); } - protected void shareUrl(String url) { + protected 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))); } 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 5fb9e0105..802389a95 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 @@ -623,12 +623,7 @@ public class VideoDetailFragment extends BaseStateFragment implement if (DEBUG) Log.d(TAG, "setupActionBarHandler() called with: info = [" + info + "]"); sortedStreamVideosList = new ArrayList<>(ListHelper.getSortedStreamVideosList(activity, info.getVideoStreams(), info.getVideoOnlyStreams(), false)); actionBarHandler.setupStreamList(sortedStreamVideosList, spinnerToolbar); - actionBarHandler.setOnShareListener(new ActionBarHandler.OnActionListener() { - @Override - public void onActionSelected(int selectedStreamId) { - shareUrl(info.getUrl()); - } - }); + actionBarHandler.setOnShareListener(selectedStreamId -> shareUrl(info.name, info.url)); actionBarHandler.setOnOpenInBrowserListener(new ActionBarHandler.OnActionListener() { @Override 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 000aff487..0cc5cabf3 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 @@ -231,7 +231,7 @@ public class ChannelFragment extends BaseListInfoFragment { openUrlInBrowser(url); break; case R.id.menu_item_share: { - shareUrl(url); + shareUrl(name, url); break; } default: diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java index c798bf349..52eeb337c 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java @@ -167,7 +167,7 @@ public class PlaylistFragment extends BaseListInfoFragment { openUrlInBrowser(url); break; case R.id.menu_item_share: { - shareUrl(url); + shareUrl(name, url); break; } default: