From 2fb86364ab452a4585d284d0af76cfc6b3ec65f0 Mon Sep 17 00:00:00 2001 From: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com> Date: Thu, 18 Mar 2021 19:19:41 +0100 Subject: [PATCH] Fix title of the subject when sharing an URL --- .../main/java/org/schabi/newpipe/RouterActivity.java | 2 +- .../java/org/schabi/newpipe/util/ShareUtils.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 0d70a7181..b1045bd4e 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -234,7 +234,7 @@ public class RouterActivity extends AppCompatActivity { .setPositiveButton(R.string.open_in_browser, (dialog, which) -> ShareUtils.openUrlInBrowser(this, url)) .setNegativeButton(R.string.share, - (dialog, which) -> ShareUtils.shareText(this, "", url)) // no subject + (dialog, which) -> ShareUtils.shareText(this, "", url, false)) //no subject .setNeutralButton(R.string.cancel, null) .setOnDismissListener(dialog -> finish()) .show(); diff --git a/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java b/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java index 18b2aa5d0..4474d1811 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java @@ -213,13 +213,21 @@ public final class ShareUtils { * @param url the url to share */ public static void shareText(final Context context, final String subject, final String url) { + shareText(context, subject, url, true); + } + + + public static void shareText(final Context context, + final String subject, + final String url, + final boolean showPreviewText) { final Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); - if (!subject.isEmpty()) { + if (!subject.isEmpty() && showPreviewText) { shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject); + shareIntent.putExtra(Intent.EXTRA_TITLE, subject); } shareIntent.putExtra(Intent.EXTRA_TEXT, url); - shareIntent.putExtra(Intent.EXTRA_TITLE, context.getString(R.string.share_dialog_title)); openAppChooser(context, shareIntent, false); }