Skip to content

Commit

Permalink
Fix title of the subject when sharing an URL
Browse files Browse the repository at this point in the history
  • Loading branch information
AudricV committed Jun 11, 2021
1 parent c972940 commit 2fb8636
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private void showUnsupportedUrlDialog(final String url) {
.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();
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/org/schabi/newpipe/util/ShareUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,21 @@ private static String getDefaultAppPackageName(final Context context, final Inte
* @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);
}
Expand Down

0 comments on commit 2fb8636

Please sign in to comment.