Warn when forwarding if not all attachments are downloaded

Fixes #137
This commit is contained in:
M66B
2018-09-22 06:13:53 +00:00
parent 2888217c29
commit 1226acd11a
38 changed files with 71 additions and 3 deletions

View File

@@ -729,9 +729,40 @@ public class FragmentMessage extends FragmentEx {
}
private void onMenuForward() {
startActivity(new Intent(getContext(), ActivityCompose.class)
.putExtra("action", "forward")
.putExtra("reference", message.id));
Bundle args = new Bundle();
args.putLong("id", message.id);
new SimpleTask<Boolean>() {
@Override
protected Boolean onLoad(Context context, Bundle args) {
long id = args.getLong("id");
List<EntityAttachment> attachments = DB.getInstance(context).attachment().getAttachments(id);
for (EntityAttachment attachment : attachments)
if (!attachment.available)
return false;
return true;
}
@Override
protected void onLoaded(Bundle args, Boolean available) {
final Intent forward = new Intent(getContext(), ActivityCompose.class)
.putExtra("action", "forward")
.putExtra("reference", message.id);
if (available)
startActivity(forward);
else
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setMessage(R.string.title_attachment_unavailable)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(forward);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
}.load(this, args);
}
private void onMenuReplyAll() {