Delete attachment improvements

pull/213/head
M66B 2 years ago
parent 8b7c882fdb
commit a70f8bb4b7

@ -510,7 +510,7 @@ class Core {
break; break;
case EntityOperation.DETACH: case EntityOperation.DETACH:
onDetach(context, jargs, message, (IMAPFolder) ifolder); onDetach(context, jargs, account, folder, message, (IMAPStore) istore, (IMAPFolder) ifolder, state);
break; break;
case EntityOperation.EXISTS: case EntityOperation.EXISTS:
@ -2092,7 +2092,7 @@ class Core {
EntityLog.log(context, "Operation attachment size=" + attachment.size); EntityLog.log(context, "Operation attachment size=" + attachment.size);
} }
private static void onDetach(Context context, JSONArray jargs, EntityMessage message, IMAPFolder ifolder) throws JSONException, MessagingException, IOException { private static void onDetach(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message, IMAPStore istore, IMAPFolder ifolder, State state) throws JSONException, MessagingException, IOException {
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
JSONArray jids = jargs.getJSONArray(0); JSONArray jids = jargs.getJSONArray(0);
@ -2126,6 +2126,13 @@ class Core {
ifolder.appendMessages(new Message[]{icopy}); ifolder.appendMessages(new Message[]{icopy});
Long uid = findUid(context, account, ifolder, msgid);
if (uid != null) {
JSONArray fargs = new JSONArray();
fargs.put(uid);
onFetch(context, fargs, folder, istore, ifolder, state);
}
if (trash == null) { if (trash == null) {
imessage.setFlag(Flags.Flag.DELETED, true); imessage.setFlag(Flags.Flag.DELETED, true);
expunge(context, ifolder, Arrays.asList(imessage)); expunge(context, ifolder, Arrays.asList(imessage));

@ -100,7 +100,7 @@ public class EntityAttachment {
public String error; public String error;
@Ignore @Ignore
public boolean selected = true; public boolean selected = false;
// Gmail sends inline images as attachments with a name and cid // Gmail sends inline images as attachments with a name and cid

@ -84,6 +84,9 @@ public class FragmentDialogDeleteAttachments extends FragmentDialogBase {
protected void onExecuted(final Bundle args, List<EntityAttachment> attachments) { protected void onExecuted(final Bundle args, List<EntityAttachment> attachments) {
if (attachments == null) if (attachments == null)
attachments = new ArrayList<>(); attachments = new ArrayList<>();
for (EntityAttachment attachment : attachments)
if (attachment.encryption == null)
attachment.selected = true;
adapter.set(attachments); adapter.set(attachments);
} }
@ -162,6 +165,7 @@ public class FragmentDialogDeleteAttachments extends FragmentDialogBase {
private void bindTo(EntityAttachment attachment) { private void bindTo(EntityAttachment attachment) {
cbEnabled.setText(attachment.name); cbEnabled.setText(attachment.name);
cbEnabled.setChecked(attachment.selected); cbEnabled.setChecked(attachment.selected);
cbEnabled.setEnabled(attachment.encryption == null);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (!TextUtils.isEmpty(attachment.type)) if (!TextUtils.isEmpty(attachment.type))

Loading…
Cancel
Save