Skip to content

Commit c30716f

Browse files
committed
Include first 100 characters of status text when sharing to share sheet.
1 parent bec0fb9 commit c30716f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,30 +1011,32 @@ public static void openSystemShareSheet(Context context, Object obj){
10111011
Intent intent=new Intent(Intent.ACTION_SEND);
10121012
intent.setType("text/plain");
10131013
Account account;
1014-
String url;
1014+
String text;
10151015
String previewTitle;
10161016

10171017
if(obj instanceof Account acc){
10181018
account=acc;
1019-
url=acc.url;
1019+
text=acc.url;
10201020
previewTitle=context.getString(R.string.share_sheet_preview_profile, account.displayName);
10211021
}else if(obj instanceof Status st){
10221022
account=st.account;
1023-
url=st.url;
10241023
String postText=st.getStrippedText();
10251024
if(TextUtils.isEmpty(postText)){
10261025
previewTitle=context.getString(R.string.share_sheet_preview_profile, account.displayName);
1026+
text=st.url;
10271027
}else{
10281028
if(postText.length()>100)
10291029
postText=postText.substring(0, 100)+"...";
10301030
previewTitle=context.getString(R.string.share_sheet_preview_post, account.displayName, postText);
1031+
text=context.getString(R.string.share_sheet_post, account.displayName, postText, st.url);
10311032
}
10321033
}else{
10331034
throw new IllegalArgumentException("Unsupported share object type");
10341035
}
10351036

1036-
intent.putExtra(Intent.EXTRA_TEXT, url);
1037+
intent.putExtra(Intent.EXTRA_TEXT, text);
10371038
intent.putExtra(Intent.EXTRA_TITLE, previewTitle);
1039+
intent.putExtra(Intent.EXTRA_SUBJECT, previewTitle);
10381040
ImageCache cache=ImageCache.getInstance(context);
10391041
try{
10401042
File ava=cache.getFile(new UrlImageLoaderRequest(account.avatarStatic));

mastodon/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@
700700
<string name="view_file">View</string>
701701
<string name="share_sheet_preview_profile">%s on Mastodon</string>
702702
<string name="share_sheet_preview_post">%1$s on Mastodon: “%2$s”</string>
703+
<string name="share_sheet_post">%1$s on Mastodon: “%2$s\n\n%3$s”</string>
703704
<string name="copy_profile_link">Copy link to profile</string>
704705
<string name="in_app_browser">In-app browser</string>
705706
<string name="system_browser">System browser</string>
@@ -863,4 +864,4 @@
863864
<string name="private_mention">Private mention</string>
864865
<string name="post_header_reply">Reply</string>
865866
<string name="post_header_mention">Mention</string>
866-
</resources>
867+
</resources>

0 commit comments

Comments
 (0)