From 1a12659a2363f731335aeed6868ce7b7fd0b5e84 Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 11 Nov 2022 15:35:26 +0100 Subject: [PATCH 1/6] Revert "preserve visibility when re-drafting" This reverts commit e8b43c71799dc57bff9270d2f5f3d1c9cfa2075c. --- .../org/joinmastodon/android/fragments/ComposeFragment.java | 5 ----- .../java/org/joinmastodon/android/ui/utils/UiUtils.java | 6 ------ 2 files changed, 11 deletions(-) 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 0f0b7e546..5179b326d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -213,11 +213,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr replyTo=Parcels.unwrap(getArguments().getParcelable("replyTo")); statusVisibility=replyTo.visibility; } - - if(getArguments().containsKey("visibility")){ - statusVisibility=(StatusPrivacy) getArguments().getSerializable("visibility"); - } - if(savedInstanceState!=null){ statusVisibility=(StatusPrivacy) savedInstanceState.getSerializable("visibility"); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index b13c59858..5c7cefa94 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -54,7 +54,6 @@ import org.joinmastodon.android.model.Account; import org.joinmastodon.android.model.Emoji; import org.joinmastodon.android.model.Relationship; import org.joinmastodon.android.model.Status; -import org.joinmastodon.android.model.StatusPrivacy; import org.joinmastodon.android.ui.M3AlertDialogBuilder; import org.joinmastodon.android.ui.text.CustomEmojiSpan; import org.joinmastodon.android.ui.text.HtmlParser; @@ -81,10 +80,6 @@ import androidx.annotation.StringRes; import androidx.browser.customtabs.CustomTabsIntent; import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.RecyclerView; - -import com.google.gson.Gson; -import com.google.gson.annotations.SerializedName; - import me.grishka.appkit.Nav; import me.grishka.appkit.api.Callback; import me.grishka.appkit.api.ErrorResponse; @@ -391,7 +386,6 @@ public class UiUtils{ args.putBoolean("hasDraft", true); args.putString("prefilledText", HtmlParser.parse(status.content, status.emojis, status.mentions, status.tags, accountID).toString()); args.putString("spoilerText", status.spoilerText); - args.putSerializable("visibility", status.visibility); if(status.poll!=null){ args.putInt("pollDuration", (int)status.poll.expiresAt.minus(status.createdAt.getEpochSecond(), ChronoUnit.SECONDS).getEpochSecond()); ArrayList opts=status.poll.options.stream().map(o -> o.title).collect(Collectors.toCollection(ArrayList::new)); From 56b76080eca3f22eadeadf5e2a9b748d29355efc Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 11 Nov 2022 15:35:30 +0100 Subject: [PATCH 2/6] Revert "implement deleting and re-drafting" This reverts commit 3a4d13b1c6b9ab6c06d19395db505dcf48caf5f9. --- .../android/fragments/ComposeFragment.java | 52 ++++------------ .../displayitems/HeaderStatusDisplayItem.java | 9 ++- .../android/ui/utils/UiUtils.java | 60 ------------------- mastodon/src/main/res/values/strings.xml | 3 - 4 files changed, 20 insertions(+), 104 deletions(-) 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 5179b326d..3ca595a86 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -22,7 +22,6 @@ import android.text.Layout; import android.text.Spanned; import android.text.TextUtils; import android.text.TextWatcher; -import android.text.format.DateUtils; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; @@ -175,14 +174,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr private Instance instance; private boolean attachmentsErrorShowing; - public static DraftMediaAttachment redraftAttachment(Attachment att) { - DraftMediaAttachment draft=new DraftMediaAttachment(); - draft.serverAttachment=att; - draft.description=att.description; - draft.uri=Uri.parse(att.url); - return draft; - } - @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); @@ -295,18 +286,11 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr pollDurationView.setOnClickListener(v->showPollDurationMenu()); pollOptions.clear(); - ArrayList restoredPollOptions=(savedInstanceState!=null ? savedInstanceState : getArguments()) - .getStringArrayList("pollOptions"); - if(restoredPollOptions!=null){ - if(savedInstanceState==null){ - // restoring from arguments - pollDuration=getArguments().getInt("pollDuration"); - pollDurationStr=DateUtils.formatElapsedTime(pollDuration); // getResources().getQuantityString(R.plurals.x_hours, pollDuration/3600); - } + if(savedInstanceState!=null && savedInstanceState.containsKey("pollOptions")){ pollBtn.setSelected(true); mediaBtn.setEnabled(false); pollWrap.setVisibility(View.VISIBLE); - for(String oldText:restoredPollOptions){ + for(String oldText:savedInstanceState.getStringArrayList("pollOptions")){ DraftPollOption opt=createDraftPollOption(); opt.edit.setText(oldText); } @@ -326,9 +310,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr spoilerBtn.setSelected(true); } - ArrayList serializedAttachments=(savedInstanceState!=null ? savedInstanceState : getArguments()) - .getParcelableArrayList("attachments"); - if(serializedAttachments!=null){ + if(savedInstanceState!=null && savedInstanceState.containsKey("attachments")){ + ArrayList serializedAttachments=savedInstanceState.getParcelableArrayList("attachments"); for(Parcelable a:serializedAttachments){ DraftMediaAttachment att=Parcels.unwrap(a); attachmentsView.addView(createMediaAttachmentView(att)); @@ -471,7 +454,10 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr mainEditText.setText(initialText); mainEditText.setSelection(mainEditText.length()); if(!TextUtils.isEmpty(replyTo.spoilerText) && AccountSessionManager.getInstance().isSelf(accountID, replyTo.account)){ - insertSpoiler(replyTo.spoilerText); + hasSpoiler=true; + spoilerEdit.setVisibility(View.VISIBLE); + spoilerEdit.setText(replyTo.spoilerText); + spoilerBtn.setSelected(true); } } }else{ @@ -484,8 +470,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr mainEditText.setSelection(mainEditText.length()); initialText=prefilledText; } - String spoilerText=getArguments().getString("spoilerText"); - if(!TextUtils.isEmpty(spoilerText)) insertSpoiler(spoilerText); ArrayList mediaUris=getArguments().getParcelableArrayList("mediaAttachments"); if(mediaUris!=null && !mediaUris.isEmpty()){ for(Uri uri:mediaUris){ @@ -495,13 +479,6 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr } } - private void insertSpoiler(String text) { - hasSpoiler=true; - if (text!=null) spoilerEdit.setText(text); - spoilerEdit.setVisibility(View.VISIBLE); - spoilerBtn.setSelected(true); - } - @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){ publishButton=new Button(getActivity()); @@ -570,11 +547,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr if(opt.edit.length()>0) nonEmptyPollOptionsCount++; } - if(publishButton!=null){ - publishButton.setEnabled((trimmedCharCount>0 || !attachments.isEmpty()) && charCount<=charLimit - && uploadingAttachment==null && failedAttachments.isEmpty() && queuedAttachments.isEmpty() - && (pollOptions.isEmpty() || nonEmptyPollOptionsCount>1)); - } + publishButton.setEnabled((trimmedCharCount>0 || !attachments.isEmpty()) && charCount<=charLimit && uploadingAttachment==null && failedAttachments.isEmpty() && queuedAttachments.isEmpty() + && (pollOptions.isEmpty() || nonEmptyPollOptionsCount>1)); } private void onCustomEmojiClick(Emoji emoji){ @@ -661,10 +635,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr boolean pollFieldsHaveContent=false; for(DraftPollOption opt:pollOptions) pollFieldsHaveContent|=opt.edit.length()>0; - return getArguments().getBoolean("hasDraft", false) - || (mainEditText.length()>0 && !mainEditText.getText().toString().equals(initialText)) - || !attachments.isEmpty() || uploadingAttachment!=null || !queuedAttachments.isEmpty() - || !failedAttachments.isEmpty() || pollFieldsHaveContent; + return (mainEditText.length()>0 && !mainEditText.getText().toString().equals(initialText)) || !attachments.isEmpty() + || uploadingAttachment!=null || !queuedAttachments.isEmpty() || !failedAttachments.isEmpty() || pollFieldsHaveContent; } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index d1b087f42..0612227f3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -23,6 +23,7 @@ import org.joinmastodon.android.R; import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.fragments.BaseStatusListFragment; +import org.joinmastodon.android.fragments.ComposeFragment; import org.joinmastodon.android.fragments.ProfileFragment; import org.joinmastodon.android.fragments.report.ReportReasonChoiceFragment; import org.joinmastodon.android.model.Account; @@ -138,7 +139,13 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ if(id==R.id.delete){ UiUtils.confirmDeletePost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, s->{}); }else if(id==R.id.delete_and_redraft) { - UiUtils.confirmDeleteAndRedraftPost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, s->{}); + UiUtils.confirmDeletePost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, s->{ + Bundle args=new Bundle(); + args.putString("account", item.parentFragment.getAccountID()); + args.putString("prefilledText", HtmlParser.parse(item.status.content, item.status.emojis, item.status.mentions, item.status.tags, item.parentFragment.getAccountID()).toString()); // demo + // TODO: restore re-drafted text and attachments + Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); + }); }else if(id==R.id.mute){ UiUtils.confirmToggleMuteUser(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), account, relationship!=null && relationship.muting, r->{}); }else if(id==R.id.block){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 5c7cefa94..e40a4a7eb 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -20,7 +20,6 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; -import android.os.Parcelable; import android.provider.OpenableColumns; import android.text.SpannableStringBuilder; import android.text.Spanned; @@ -45,8 +44,6 @@ import org.joinmastodon.android.api.requests.statuses.DeleteStatus; import org.joinmastodon.android.api.requests.statuses.GetStatusByID; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.StatusDeletedEvent; -import org.joinmastodon.android.fragments.BaseStatusListFragment; -import org.joinmastodon.android.fragments.ComposeFragment; import org.joinmastodon.android.fragments.HashtagTimelineFragment; import org.joinmastodon.android.fragments.ProfileFragment; import org.joinmastodon.android.fragments.ThreadFragment; @@ -56,7 +53,6 @@ import org.joinmastodon.android.model.Relationship; import org.joinmastodon.android.model.Status; import org.joinmastodon.android.ui.M3AlertDialogBuilder; import org.joinmastodon.android.ui.text.CustomEmojiSpan; -import org.joinmastodon.android.ui.text.HtmlParser; import org.joinmastodon.android.ui.text.SpacerSpan; import org.parceler.Parcels; @@ -66,8 +62,6 @@ import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -358,60 +352,6 @@ public class UiUtils{ }); } - public static void confirmDeleteAndRedraftPost(Activity activity, String accountID, Status status, Consumer resultCallback){ - showConfirmationAlert(activity, R.string.confirm_delete_and_redraft_title, R.string.confirm_delete_and_redraft, R.string.delete_and_redraft, ()->{ - new DeleteStatus(status.id) - .setCallback(new Callback<>(){ - @Override - public void onSuccess(Status result){ - resultCallback.accept(result); - AccountSessionManager.getInstance().getAccount(accountID).getCacheController().deleteStatus(status.id); - E.post(new StatusDeletedEvent(status.id, accountID)); - UiUtils.redraftStatus(status, accountID, activity); - } - - @Override - public void onError(ErrorResponse error){ - error.showToast(activity); - } - }) - .wrapProgress(activity, R.string.deleting, false) - .exec(accountID); - }); - } - - public static void redraftStatus(Status status, String accountID, Activity activity) { - Bundle args=new Bundle(); - args.putString("account", accountID); - args.putBoolean("hasDraft", true); - args.putString("prefilledText", HtmlParser.parse(status.content, status.emojis, status.mentions, status.tags, accountID).toString()); - args.putString("spoilerText", status.spoilerText); - if(status.poll!=null){ - args.putInt("pollDuration", (int)status.poll.expiresAt.minus(status.createdAt.getEpochSecond(), ChronoUnit.SECONDS).getEpochSecond()); - ArrayList opts=status.poll.options.stream().map(o -> o.title).collect(Collectors.toCollection(ArrayList::new)); - args.putStringArrayList("pollOptions", opts); - } - if(!status.mediaAttachments.isEmpty()){ - ArrayList serializedAttachments=status.mediaAttachments.stream() - .map(att -> Parcels.wrap(ComposeFragment.redraftAttachment(att))) - .collect(Collectors.toCollection(ArrayList::new)); - args.putParcelableArrayList("attachments", serializedAttachments); - } - Callback cb=new Callback<>(){ - @Override public void onError(ErrorResponse error) { - onSuccess(null); - error.showToast(activity); - } - @Override public void onSuccess(Status status) { - if (status!=null) args.putParcelable("replyTo", Parcels.wrap(status)); - Nav.go(activity, ComposeFragment.class, args); - } - }; - - if(status.inReplyToId!=null) new GetStatusByID(status.inReplyToId).setCallback(cb).exec(accountID); - else cb.onSuccess(null); - } - public static void setRelationshipToActionButton(Relationship relationship, Button button){ boolean secondaryStyle; if(relationship.blocking){ diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index afda1737c..813814edf 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -126,11 +126,8 @@ Vote Tap to reveal Delete - Delete and re-draft Delete Post - Delete and re-draft Post Are you sure you want to delete this post? - Are you sure you want to delete and re-draft this post? Deleting… Audio playback Play From 57424931855b065b2d3ac845bd2d0ed3413ef1ee Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 11 Nov 2022 16:12:26 +0100 Subject: [PATCH 3/6] re-implement redraft from upstream edit function --- .../android/fragments/ComposeFragment.java | 6 ++++-- .../displayitems/HeaderStatusDisplayItem.java | 19 +++++++++---------- .../android/ui/utils/UiUtils.java | 8 ++++++-- mastodon/src/main/res/values/strings.xml | 3 +++ 4 files changed, 22 insertions(+), 14 deletions(-) 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 be33b4393..170deb827 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -192,6 +192,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr private boolean attachmentsErrorShowing; private Status editingStatus; + private boolean redraftStatus; private boolean pollChanged; private boolean creatingView; private boolean ignoreSelectionChanges=false; @@ -210,6 +211,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr instance=AccountSessionManager.getInstance().getInstanceInfo(instanceDomain); if(getArguments().containsKey("editStatus")){ editingStatus=Parcels.unwrap(getArguments().getParcelable("editStatus")); + redraftStatus=getArguments().getBoolean("redraftStatus"); } if(instance==null){ Nav.finish(this); @@ -561,7 +563,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){ publishButton=new Button(getActivity()); - publishButton.setText(editingStatus==null ? R.string.publish : R.string.save); + publishButton.setText(editingStatus==null || redraftStatus ? R.string.publish : R.string.save); publishButton.setOnClickListener(this::onPublishClick); LinearLayout wrap=new LinearLayout(getActivity()); wrap.setOrientation(LinearLayout.HORIZONTAL); @@ -722,7 +724,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr } }; - if(editingStatus!=null){ + if(editingStatus!=null && !redraftStatus){ new EditStatus(req, editingStatus.id) .setCallback(resCallback) .exec(accountID); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index 0785865a0..223476c2c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -137,10 +137,11 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ optionsMenu.setOnMenuItemClickListener(menuItem->{ Account account=item.user; int id=menuItem.getItemId(); - if(id==R.id.edit){ + if(id==R.id.edit || id==R.id.delete_and_redraft) { final Bundle args=new Bundle(); args.putString("account", item.parentFragment.getAccountID()); args.putParcelable("editStatus", Parcels.wrap(item.status)); + if (id==R.id.delete_and_redraft) args.putBoolean("redraftStatus", true); if(TextUtils.isEmpty(item.status.content) && TextUtils.isEmpty(item.status.spoilerText)){ Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); }else{ @@ -150,7 +151,13 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ public void onSuccess(GetStatusSourceText.Response result){ args.putString("sourceText", result.text); args.putString("sourceSpoiler", result.spoilerText); - Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); + if (id==R.id.delete_and_redraft) { + UiUtils.confirmDeletePost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, s->{ + Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); + }, true); + } else { + Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); + } } @Override @@ -163,14 +170,6 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ } }else if(id==R.id.delete){ UiUtils.confirmDeletePost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, s->{}); - }else if(id==R.id.delete_and_redraft) { - UiUtils.confirmDeletePost(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), item.status, s->{ - Bundle args=new Bundle(); - args.putString("account", item.parentFragment.getAccountID()); - args.putString("prefilledText", HtmlParser.parse(item.status.content, item.status.emojis, item.status.mentions, item.status.tags, item.parentFragment.getAccountID()).toString()); // demo - // TODO: restore re-drafted text and attachments - Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); - }); }else if(id==R.id.mute){ UiUtils.confirmToggleMuteUser(item.parentFragment.getActivity(), item.parentFragment.getAccountID(), account, relationship!=null && relationship.muting, r->{}); }else if(id==R.id.block){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 84436cca2..15a60356a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -44,6 +44,7 @@ import org.joinmastodon.android.api.requests.statuses.DeleteStatus; import org.joinmastodon.android.api.requests.statuses.GetStatusByID; import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.StatusDeletedEvent; +import org.joinmastodon.android.fragments.ComposeFragment; import org.joinmastodon.android.fragments.HashtagTimelineFragment; import org.joinmastodon.android.fragments.ProfileFragment; import org.joinmastodon.android.fragments.ThreadFragment; @@ -378,9 +379,12 @@ public class UiUtils{ .exec(accountID); }); } - public static void confirmDeletePost(Activity activity, String accountID, Status status, Consumer resultCallback){ - showConfirmationAlert(activity, R.string.confirm_delete_title, R.string.confirm_delete, R.string.delete, ()->{ + confirmDeletePost(activity, accountID, status, resultCallback, false); + } + + public static void confirmDeletePost(Activity activity, String accountID, Status status, Consumer resultCallback, boolean forRedraft){ + showConfirmationAlert(activity, forRedraft ? R.string.confirm_delete_and_redraft_title : R.string.confirm_delete_title, forRedraft ? R.string.confirm_delete_and_redraft : R.string.confirm_delete, forRedraft ? R.string.delete_and_redraft : R.string.delete, ()->{ new DeleteStatus(status.id) .setCallback(new Callback<>(){ @Override diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index 2ee4d9975..9a5493cdc 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -126,8 +126,11 @@ Vote Tap to reveal Delete + Delete and re-draft Delete Post + Delete and re-draft Post Are you sure you want to delete this post? + Are you sure you want to delete and re-draft this post? Deleting… Audio playback Play From 977f3d0635bd401611e6a650354656e238dc9389 Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 11 Nov 2022 17:17:52 +0100 Subject: [PATCH 4/6] fix re-drafting replies --- .../org/joinmastodon/android/fragments/ComposeFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 170deb827..59772a74b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -667,8 +667,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr if(!attachments.isEmpty()){ req.mediaIds=attachments.stream().map(a->a.serverAttachment.id).collect(Collectors.toList()); } - if(replyTo!=null){ - req.inReplyToId=replyTo.id; + if(replyTo!=null || editingStatus.inReplyToId!=null){ + req.inReplyToId=editingStatus!=null ? editingStatus.inReplyToId : replyTo.id; } if(!pollOptions.isEmpty()){ req.poll=new CreateStatus.Request.Poll(); From aecaba2a926432e4327084b4e80a5f21af5ab841 Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 11 Nov 2022 17:18:21 +0100 Subject: [PATCH 5/6] show reply icon as workaround for mastodon#341 --- .../org/joinmastodon/android/fragments/ComposeFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 59772a74b..b05d2074a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -513,7 +513,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr spoilerBtn.setSelected(true); } } - }else{ + }else if (editingStatus==null || editingStatus.inReplyToId==null){ + // TODO: remove workaround after https://github.com/mastodon/mastodon-android/issues/341 gets fixed replyText.setVisibility(View.GONE); } if(savedInstanceState==null){ From 443b985b066f03e0b0a25d713986b9d54366bc81 Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 11 Nov 2022 17:53:04 +0100 Subject: [PATCH 6/6] navigate to re-drafted status when opened --- .../android/fragments/ComposeFragment.java | 7 +++++++ .../ui/displayitems/HeaderStatusDisplayItem.java | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) 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 b05d2074a..827331ba0 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -712,6 +712,13 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr E.post(new StatusUpdatedEvent(result)); } Nav.finish(ComposeFragment.this); + if (getArguments().getBoolean("navigateToStatus", false)) { + Bundle args=new Bundle(); + args.putString("account", accountID); + args.putParcelable("status", Parcels.wrap(result)); + if(replyTo!=null) args.putParcelable("inReplyToAccount", Parcels.wrap(replyTo)); + Nav.go(getActivity(), ThreadFragment.class, args); + } } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index 223476c2c..b5c52a335 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -26,6 +26,7 @@ import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.fragments.BaseStatusListFragment; import org.joinmastodon.android.fragments.ComposeFragment; import org.joinmastodon.android.fragments.ProfileFragment; +import org.joinmastodon.android.fragments.ThreadFragment; import org.joinmastodon.android.fragments.report.ReportReasonChoiceFragment; import org.joinmastodon.android.model.Account; import org.joinmastodon.android.model.Attachment; @@ -141,7 +142,14 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ final Bundle args=new Bundle(); args.putString("account", item.parentFragment.getAccountID()); args.putParcelable("editStatus", Parcels.wrap(item.status)); - if (id==R.id.delete_and_redraft) args.putBoolean("redraftStatus", true); + if (id==R.id.delete_and_redraft) { + args.putBoolean("redraftStatus", true); + if (item.parentFragment instanceof ThreadFragment thread && !thread.isItemEnabled(item.status.id)) { + // ("enabled" = clickable; opened status is not clickable) + // request navigation to the re-drafted status if status is currently opened + args.putBoolean("navigateToStatus", true); + } + } if(TextUtils.isEmpty(item.status.content) && TextUtils.isEmpty(item.status.spoilerText)){ Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args); }else{