From 12558c3c18b9633209dde980c9b5d06729f3834e Mon Sep 17 00:00:00 2001 From: sk Date: Mon, 6 Feb 2023 14:31:53 +0100 Subject: [PATCH] handle saving draft when attachment not uploaded closes sk22#402 --- .../joinmastodon/android/fragments/ComposeFragment.java | 9 ++++++++- mastodon/src/main/res/values/strings_sk.xml | 2 ++ 2 files changed, 10 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 82edda8f2..928f31c2c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -1248,7 +1248,14 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr } private void confirmDiscardDraftAndFinish(){ - new M3AlertDialogBuilder(getActivity()) + boolean attachmentsPending = attachments.stream().anyMatch(att -> att.state != AttachmentUploadState.DONE); + if (attachmentsPending) new M3AlertDialogBuilder(getActivity()) + .setTitle(R.string.sk_unfinished_attachments) + .setMessage(R.string.sk_unfinished_attachments_message) + .setPositiveButton(R.string.edit, (d, w) -> {}) + .setNegativeButton(R.string.discard, (d, w) -> Nav.finish(this)) + .show(); + else new M3AlertDialogBuilder(getActivity()) .setTitle(editingStatus != null ? R.string.sk_confirm_save_changes : R.string.sk_confirm_save_draft) .setPositiveButton(R.string.save, (d, w) -> { updateScheduledAt(scheduledAt == null ? getDraftInstant() : scheduledAt); diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index 378f68183..63187a504 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -256,4 +256,6 @@ Expand Collapse Collapse very long posts + Fix attachments? + Some attachments haven’t finished uploading. \ No newline at end of file