mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-29 11:15:51 +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) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", data.message.id);
|
||||
|
||||
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)
|
||||
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");
|
||||
Intent forward = new Intent(context, ActivityCompose.class)
|
||||
.putExtra("action", "forward")
|
||||
.putExtra("reference", data.message.id);
|
||||
context.startActivity(forward);
|
||||
}
|
||||
|
||||
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) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", data.message.id);
|
||||
args.putString("action", action);
|
||||
|
||||
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");
|
||||
Intent reply = new Intent(context, ActivityCompose.class)
|
||||
.putExtra("action", action)
|
||||
.putExtra("reference", data.message.id);
|
||||
context.startActivity(reply);
|
||||
}
|
||||
|
||||
private void onMenuAnswer(final ActionData data) {
|
||||
|
|
|
@ -2158,18 +2158,21 @@ public class FragmentCompose extends FragmentBase {
|
|||
int sequence = 0;
|
||||
List<EntityAttachment> attachments = db.attachment().getAttachments(ref.id);
|
||||
for (EntityAttachment attachment : attachments)
|
||||
if (attachment.available &&
|
||||
attachment.encryption == null &&
|
||||
("forward".equals(action) || attachment.isInline())) {
|
||||
File source = attachment.getFile(context);
|
||||
if (attachment.encryption == null &&
|
||||
("forward".equals(action) ||
|
||||
(attachment.isInline() && attachment.isImage()))) {
|
||||
if (attachment.available) {
|
||||
File source = attachment.getFile(context);
|
||||
|
||||
attachment.id = null;
|
||||
attachment.message = draft.id;
|
||||
attachment.sequence = ++sequence;
|
||||
attachment.id = db.attachment().insertAttachment(attachment);
|
||||
attachment.id = null;
|
||||
attachment.message = draft.id;
|
||||
attachment.sequence = ++sequence;
|
||||
attachment.id = db.attachment().insertAttachment(attachment);
|
||||
|
||||
File target = attachment.getFile(context);
|
||||
Helper.copy(source, target);
|
||||
File target = attachment.getFile(context);
|
||||
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);
|
||||
getActivity().invalidateOptionsMenu();
|
||||
|
||||
if (args.getBoolean("incomplete"))
|
||||
Snackbar.make(view, R.string.title_attachments_incomplete, Snackbar.LENGTH_LONG).show();
|
||||
|
||||
new SimpleTask<List<TupleIdentityEx>>() {
|
||||
@Override
|
||||
protected List<TupleIdentityEx> onExecute(Context context, Bundle args) {
|
||||
|
|
|
@ -421,8 +421,7 @@
|
|||
<string name="title_raw_saved">Raw message saved</string>
|
||||
<string name="title_attachment_saved">Attachment 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_image_unavailable">Some images 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_ask_delete">Delete message permanently?</string>
|
||||
<string name="title_ask_delete_answer">Delete reply template permanently?</string>
|
||||
<string name="title_ask_delete_rule">Delete rule permanently?</string>
|
||||
|
|
Loading…
Reference in a new issue