mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 09:00:31 +00:00
Fix title of the subject when sharing an URL
This commit is contained in:
parent
c972940338
commit
2fb86364ab
@ -234,7 +234,7 @@ public class RouterActivity extends AppCompatActivity {
|
|||||||
.setPositiveButton(R.string.open_in_browser,
|
.setPositiveButton(R.string.open_in_browser,
|
||||||
(dialog, which) -> ShareUtils.openUrlInBrowser(this, url))
|
(dialog, which) -> ShareUtils.openUrlInBrowser(this, url))
|
||||||
.setNegativeButton(R.string.share,
|
.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)
|
.setNeutralButton(R.string.cancel, null)
|
||||||
.setOnDismissListener(dialog -> finish())
|
.setOnDismissListener(dialog -> finish())
|
||||||
.show();
|
.show();
|
||||||
|
@ -213,13 +213,21 @@ public final class ShareUtils {
|
|||||||
* @param url the url to share
|
* @param url the url to share
|
||||||
*/
|
*/
|
||||||
public static void shareText(final Context context, final String subject, final String url) {
|
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);
|
final Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||||
shareIntent.setType("text/plain");
|
shareIntent.setType("text/plain");
|
||||||
if (!subject.isEmpty()) {
|
if (!subject.isEmpty() && showPreviewText) {
|
||||||
shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
shareIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_TITLE, subject);
|
||||||
}
|
}
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, url);
|
shareIntent.putExtra(Intent.EXTRA_TEXT, url);
|
||||||
shareIntent.putExtra(Intent.EXTRA_TITLE, context.getString(R.string.share_dialog_title));
|
|
||||||
|
|
||||||
openAppChooser(context, shareIntent, false);
|
openAppChooser(context, shareIntent, false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user