Fix title of the subject when sharing an URL

This commit is contained in:
TiA4f8R 2021-03-18 19:19:41 +01:00
parent c972940338
commit 2fb86364ab
No known key found for this signature in database
GPG key ID: E6D3E7F5949450DD
2 changed files with 11 additions and 3 deletions

View file

@ -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);
}