Fix #41 - Delete & Redraft cannot be sent

This commit is contained in:
Thomas 2022-05-09 16:22:34 +02:00
parent 97c926e8dc
commit ac7dd0484d
4 changed files with 27 additions and 21 deletions

View File

@ -172,9 +172,11 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
statusDraftList.add(status); statusDraftList.add(status);
//Restore a draft with all messages //Restore a draft with all messages
if (statusDraft != null && statusDraft.statusReplyList != null) { if (statusDraft != null) {
new Thread(() -> { 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()); Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> { Runnable myRunnable = () -> {
if (statusDraft.statusReplyList != null) { if (statusDraft.statusReplyList != null) {

View File

@ -208,27 +208,32 @@ public class PostMessageService extends IntentService {
if (statuses.get(i).media_attachments != null && statuses.get(i).media_attachments.size() > 0) { if (statuses.get(i).media_attachments != null && statuses.get(i).media_attachments.size() > 0) {
attachmentIds = new ArrayList<>(); attachmentIds = new ArrayList<>();
for (Attachment attachment : statuses.get(i).media_attachments) { for (Attachment attachment : statuses.get(i).media_attachments) {
MultipartBody.Part fileMultipartBody; if (attachment.id != null) {
if (watermark && attachment.mimeType.contains("image")) { attachmentIds.add(attachment.id);
fileMultipartBody = Helper.getMultipartBodyWithWM(PostMessageService.this, watermarkText, "file", attachment);
} else { } else {
fileMultipartBody = Helper.getMultipartBody("file", attachment); MultipartBody.Part fileMultipartBody;
} if (watermark && attachment.mimeType.contains("image")) {
Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, null, attachment.description, null); fileMultipartBody = Helper.getMultipartBodyWithWM(PostMessageService.this, watermarkText, "file", attachment);
if (attachmentCall != null) { } else {
try { fileMultipartBody = Helper.getMultipartBody("file", attachment);
Response<Attachment> attachmentResponse = attachmentCall.execute(); }
if (attachmentResponse.isSuccessful()) { Call<Attachment> attachmentCall = mastodonStatusesService.postMedia(token, fileMultipartBody, null, attachment.description, null);
Attachment attachmentReply = attachmentResponse.body(); if (attachmentCall != null) {
if (attachmentReply != null) { try {
attachmentIds.add(attachmentReply.id); Response<Attachment> 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<String> poll_options = null; List<String> poll_options = null;

View File

@ -1181,9 +1181,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
ImageViewCompat.setImageTintList(holder.binding.buttonPoll, null); ImageViewCompat.setImageTintList(holder.binding.buttonPoll, null);
} }
holder.binding.buttonPost.setOnClickListener(v -> { holder.binding.buttonPost.setOnClickListener(v -> manageDrafts.onSubmit(prepareDraft(statusList, this, account.instance, account.user_id)));
manageDrafts.onSubmit(prepareDraft(statusList, this, account.instance, account.user_id));
});
} }
} }

View File

@ -1201,6 +1201,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
StatusDraft statusDraft = new StatusDraft(); StatusDraft statusDraft = new StatusDraft();
statusDraft.statusDraftList = new ArrayList<>(); statusDraft.statusDraftList = new ArrayList<>();
statusDraft.statusReplyList = new ArrayList<>(); statusDraft.statusReplyList = new ArrayList<>();
statusDeleted.id = null;
statusDraft.statusDraftList.add(statusDeleted); statusDraft.statusDraftList.add(statusDeleted);
intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft); intent.putExtra(Helper.ARG_STATUS_DRAFT, statusDraft);
context.startActivity(intent); context.startActivity(intent);