diff --git a/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java b/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java index 639b5303d..c289bde53 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java @@ -52,7 +52,8 @@ public class ExternalShareActivity extends FragmentStackActivity{ Intent intent=getIntent(); StringBuilder builder=new StringBuilder(); - if (intent.hasExtra(Intent.EXTRA_SUBJECT)) builder.append(intent.getStringExtra(Intent.EXTRA_SUBJECT)).append("\n\n"); + String subject = ""; + if (intent.hasExtra(Intent.EXTRA_SUBJECT)) builder.append(subject = intent.getStringExtra(Intent.EXTRA_SUBJECT)).append("\n\n"); if (intent.hasExtra(Intent.EXTRA_TEXT)) builder.append(intent.getStringExtra(Intent.EXTRA_TEXT)).append("\n"); String text=builder.toString(); List mediaUris; @@ -80,6 +81,8 @@ public class ExternalShareActivity extends FragmentStackActivity{ args.putString("account", accountID); if(!TextUtils.isEmpty(text)) args.putString("prefilledText", text); + if(!subject.isBlank()) + args.putInt("selectionEnd", subject.length()); if(mediaUris!=null && !mediaUris.isEmpty()) args.putParcelableArrayList("mediaAttachments", toArrayList(mediaUris)); Fragment fragment=new ComposeFragment(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index 2d5161056..23d3a3781 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -602,6 +602,11 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr ignoreSelectionChanges=false; initialText=prefilledText; } + if (getArguments().containsKey("selectionStart") || getArguments().containsKey("selectionEnd")) { + int selectionStart=getArguments().getInt("selectionStart", 0); + int selectionEnd=getArguments().getInt("selectionEnd", selectionStart); + mainEditText.setSelection(selectionStart, selectionEnd); + } ArrayList mediaUris=getArguments().getParcelableArrayList("mediaAttachments"); if(mediaUris!=null && !mediaUris.isEmpty()){ for(Uri uri:mediaUris){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java index 910aa638e..9bbccab8c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java @@ -95,6 +95,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ reply.setAccessibilityDelegate(buttonAccessibilityDelegate); boost.setOnTouchListener(this::onButtonTouch); boost.setOnClickListener(this::onBoostClick); + boost.setOnLongClickListener(this::onBoostLongClick); boost.setAccessibilityDelegate(buttonAccessibilityDelegate); favorite.setOnTouchListener(this::onButtonTouch); favorite.setOnClickListener(this::onFavoriteClick); @@ -166,6 +167,16 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ }); } + private boolean onBoostLongClick(View v){ + v.startAnimation(opacityIn); + Bundle args=new Bundle(); + args.putString("account", item.accountID); + args.putString("prefilledText", "\n\n" + item.status.url); + args.putInt("selectionStart", 0); + Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); + return true; + } + private void onFavoriteClick(View v){ favorite.setSelected(!item.status.favourited); AccountSessionManager.getInstance().getAccount(item.accountID).getStatusInteractionController().setFavorited(item.status, !item.status.favourited, r->{