mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Check attachments complete on compose
This commit is contained in:
parent
3d52d8507b
commit
86a7816e8c
3 changed files with 25 additions and 95 deletions
|
@ -2055,47 +2055,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMenuForward(final ActionData data) {
|
private void onMenuForward(final ActionData data) {
|
||||||
Bundle args = new Bundle();
|
Intent forward = new Intent(context, ActivityCompose.class)
|
||||||
args.putLong("id", data.message.id);
|
.putExtra("action", "forward")
|
||||||
|
.putExtra("reference", data.message.id);
|
||||||
new SimpleTask<Boolean>() {
|
context.startActivity(forward);
|
||||||
@Override
|
|
||||||
protected Boolean onExecute(Context context, Bundle args) {
|
|
||||||
long id = args.getLong("id");
|
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
|
||||||
List<EntityAttachment> attachments = db.attachment().getAttachments(id);
|
|
||||||
for (EntityAttachment attachment : attachments)
|
|
||||||
if (!attachment.available)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onExecuted(Bundle args, Boolean available) {
|
|
||||||
final Intent forward = new Intent(context, ActivityCompose.class)
|
|
||||||
.putExtra("action", "forward")
|
|
||||||
.putExtra("reference", data.message.id);
|
|
||||||
if (available)
|
|
||||||
context.startActivity(forward);
|
|
||||||
else
|
|
||||||
new DialogBuilderLifecycle(context, owner)
|
|
||||||
.setMessage(R.string.title_attachment_unavailable)
|
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
context.startActivity(forward);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onException(Bundle args, Throwable ex) {
|
|
||||||
Helper.unexpectedError(context, owner, ex);
|
|
||||||
}
|
|
||||||
}.execute(context, owner, args, "message:forward");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMenuUnseen(final ActionData data) {
|
private void onMenuUnseen(final ActionData data) {
|
||||||
|
@ -2947,48 +2910,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMenuReply(final ActionData data, String action) {
|
private void onMenuReply(final ActionData data, String action) {
|
||||||
Bundle args = new Bundle();
|
Intent reply = new Intent(context, ActivityCompose.class)
|
||||||
args.putLong("id", data.message.id);
|
.putExtra("action", action)
|
||||||
args.putString("action", action);
|
.putExtra("reference", data.message.id);
|
||||||
|
context.startActivity(reply);
|
||||||
new SimpleTask<Boolean>() {
|
|
||||||
@Override
|
|
||||||
protected Boolean onExecute(Context context, Bundle args) {
|
|
||||||
long id = args.getLong("id");
|
|
||||||
|
|
||||||
DB db = DB.getInstance(context);
|
|
||||||
List<EntityAttachment> attachments = db.attachment().getAttachments(id);
|
|
||||||
for (EntityAttachment attachment : attachments)
|
|
||||||
if (!attachment.available && attachment.isInline() && attachment.isImage())
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onExecuted(Bundle args, Boolean available) {
|
|
||||||
final Intent reply = new Intent(context, ActivityCompose.class)
|
|
||||||
.putExtra("action", args.getString("action"))
|
|
||||||
.putExtra("reference", data.message.id);
|
|
||||||
if (available)
|
|
||||||
context.startActivity(reply);
|
|
||||||
else
|
|
||||||
new DialogBuilderLifecycle(context, owner)
|
|
||||||
.setMessage(R.string.title_image_unavailable)
|
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
context.startActivity(reply);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onException(Bundle args, Throwable ex) {
|
|
||||||
Helper.unexpectedError(context, owner, ex);
|
|
||||||
}
|
|
||||||
}.execute(context, owner, args, "message:reply");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMenuAnswer(final ActionData data) {
|
private void onMenuAnswer(final ActionData data) {
|
||||||
|
|
|
@ -2158,18 +2158,21 @@ public class FragmentCompose extends FragmentBase {
|
||||||
int sequence = 0;
|
int sequence = 0;
|
||||||
List<EntityAttachment> attachments = db.attachment().getAttachments(ref.id);
|
List<EntityAttachment> attachments = db.attachment().getAttachments(ref.id);
|
||||||
for (EntityAttachment attachment : attachments)
|
for (EntityAttachment attachment : attachments)
|
||||||
if (attachment.available &&
|
if (attachment.encryption == null &&
|
||||||
attachment.encryption == null &&
|
("forward".equals(action) ||
|
||||||
("forward".equals(action) || attachment.isInline())) {
|
(attachment.isInline() && attachment.isImage()))) {
|
||||||
File source = attachment.getFile(context);
|
if (attachment.available) {
|
||||||
|
File source = attachment.getFile(context);
|
||||||
|
|
||||||
attachment.id = null;
|
attachment.id = null;
|
||||||
attachment.message = draft.id;
|
attachment.message = draft.id;
|
||||||
attachment.sequence = ++sequence;
|
attachment.sequence = ++sequence;
|
||||||
attachment.id = db.attachment().insertAttachment(attachment);
|
attachment.id = db.attachment().insertAttachment(attachment);
|
||||||
|
|
||||||
File target = attachment.getFile(context);
|
File target = attachment.getFile(context);
|
||||||
Helper.copy(source, target);
|
Helper.copy(source, target);
|
||||||
|
} else
|
||||||
|
args.putBoolean("incomplete", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2221,6 +2224,9 @@ public class FragmentCompose extends FragmentBase {
|
||||||
plain_only = (draft.plain_only != null && draft.plain_only);
|
plain_only = (draft.plain_only != null && draft.plain_only);
|
||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
|
|
||||||
|
if (args.getBoolean("incomplete"))
|
||||||
|
Snackbar.make(view, R.string.title_attachments_incomplete, Snackbar.LENGTH_LONG).show();
|
||||||
|
|
||||||
new SimpleTask<List<TupleIdentityEx>>() {
|
new SimpleTask<List<TupleIdentityEx>>() {
|
||||||
@Override
|
@Override
|
||||||
protected List<TupleIdentityEx> onExecute(Context context, Bundle args) {
|
protected List<TupleIdentityEx> onExecute(Context context, Bundle args) {
|
||||||
|
|
|
@ -421,8 +421,7 @@
|
||||||
<string name="title_raw_saved">Raw message saved</string>
|
<string name="title_raw_saved">Raw message saved</string>
|
||||||
<string name="title_attachment_saved">Attachment saved</string>
|
<string name="title_attachment_saved">Attachment saved</string>
|
||||||
<string name="title_attachments_saved">Attachments saved</string>
|
<string name="title_attachments_saved">Attachments saved</string>
|
||||||
<string name="title_attachment_unavailable">Some attachments are not downloaded and will not be added, continue?</string>
|
<string name="title_attachments_incomplete">Some attachments or images were not downloaded and could not be added</string>
|
||||||
<string name="title_image_unavailable">Some images are not downloaded and will not be added, continue?</string>
|
|
||||||
<string name="title_ask_delete">Delete message permanently?</string>
|
<string name="title_ask_delete">Delete message permanently?</string>
|
||||||
<string name="title_ask_delete_answer">Delete reply template permanently?</string>
|
<string name="title_ask_delete_answer">Delete reply template permanently?</string>
|
||||||
<string name="title_ask_delete_rule">Delete rule permanently?</string>
|
<string name="title_ask_delete_rule">Delete rule permanently?</string>
|
||||||
|
|
Loading…
Reference in a new issue