diff --git a/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java b/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java index 16f99c87..14007796 100644 --- a/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java @@ -172,9 +172,11 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana statusDraftList.add(status); //Restore a draft with all messages - if (statusDraft != null && statusDraft.statusReplyList != null) { + if (statusDraft != null) { new Thread(() -> { - statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList); + if (statusDraft.statusReplyList != null) { + statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList); + } Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { if (statusDraft.statusReplyList != null) { diff --git a/app/src/main/java/app/fedilab/android/services/PostMessageService.java b/app/src/main/java/app/fedilab/android/services/PostMessageService.java index 1ba0097d..218e6eb3 100644 --- a/app/src/main/java/app/fedilab/android/services/PostMessageService.java +++ b/app/src/main/java/app/fedilab/android/services/PostMessageService.java @@ -208,27 +208,32 @@ public class PostMessageService extends IntentService { if (statuses.get(i).media_attachments != null && statuses.get(i).media_attachments.size() > 0) { attachmentIds = new ArrayList<>(); for (Attachment attachment : statuses.get(i).media_attachments) { - MultipartBody.Part fileMultipartBody; - if (watermark && attachment.mimeType.contains("image")) { - fileMultipartBody = Helper.getMultipartBodyWithWM(PostMessageService.this, watermarkText, "file", attachment); + if (attachment.id != null) { + attachmentIds.add(attachment.id); } else { - fileMultipartBody = Helper.getMultipartBody("file", attachment); - } - Call attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, null, attachment.description, null); - if (attachmentCall != null) { - try { - Response attachmentResponse = attachmentCall.execute(); - if (attachmentResponse.isSuccessful()) { - Attachment attachmentReply = attachmentResponse.body(); - if (attachmentReply != null) { - attachmentIds.add(attachmentReply.id); + MultipartBody.Part fileMultipartBody; + if (watermark && attachment.mimeType.contains("image")) { + fileMultipartBody = Helper.getMultipartBodyWithWM(PostMessageService.this, watermarkText, "file", attachment); + } else { + fileMultipartBody = Helper.getMultipartBody("file", attachment); + } + Call attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, null, attachment.description, null); + if (attachmentCall != null) { + try { + Response attachmentResponse = attachmentCall.execute(); + if (attachmentResponse.isSuccessful()) { + Attachment attachmentReply = attachmentResponse.body(); + if (attachmentReply != null) { + attachmentIds.add(attachmentReply.id); + } } + } catch (IOException e) { + error = true; + e.printStackTrace(); } - } catch (IOException e) { - error = true; - e.printStackTrace(); } } + } } List poll_options = null; diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java index c27f46e5..95fa8f8a 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java @@ -1181,9 +1181,7 @@ public class ComposeAdapter extends RecyclerView.Adapter { - manageDrafts.onSubmit(prepareDraft(statusList, this, account.instance, account.user_id)); - }); + holder.binding.buttonPost.setOnClickListener(v -> manageDrafts.onSubmit(prepareDraft(statusList, this, account.instance, account.user_id))); } } diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index 7d8b1eca..73f5bf0e 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -1201,6 +1201,7 @@ public class StatusAdapter extends RecyclerView.Adapter StatusDraft statusDraft = new StatusDraft(); statusDraft.statusDraftList = new ArrayList<>(); statusDraft.statusReplyList = new ArrayList<>(); + statusDeleted.id = null; statusDraft.statusDraftList.add(statusDeleted); intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft); context.startActivity(intent);