Reply/forward original message

This commit is contained in:
M66B
2018-12-14 12:04:50 +01:00
parent dd97f7c6f8
commit ae9d35c084
6 changed files with 69 additions and 27 deletions

View File

@@ -874,7 +874,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
onArchive(data);
return true;
case R.id.action_reply:
onReply(data);
onReply(data, false);
return true;
default:
return false;
@@ -965,12 +965,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}.load(context, owner, args);
}
private void onReplyAll(ActionData data) {
context.startActivity(new Intent(context, ActivityCompose.class)
.putExtra("action", "reply_all")
.putExtra("reference", data.message.id));
}
private void onAnswer(final ActionData data) {
new SimpleTask<List<EntityAnswer>>() {
@Override
@@ -1313,7 +1307,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
onForward(data, true);
return true;
case R.id.menu_reply_all:
onReplyAll(data);
onReply(data, true);
return true;
case R.id.menu_answer:
onAnswer(data);
@@ -1468,10 +1462,46 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
properties.move(data.message.id, EntityFolder.ARCHIVE, true);
}
private void onReply(ActionData data) {
context.startActivity(new Intent(context, ActivityCompose.class)
.putExtra("action", "reply")
.putExtra("reference", data.message.id));
private void onReply(final ActionData data, final boolean all) {
Bundle args = new Bundle();
args.putLong("id", data.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.cid != null && !attachment.available)
return false;
return true;
}
@Override
protected void onLoaded(Bundle args, Boolean available) {
final Intent reply = new Intent(context, ActivityCompose.class)
.putExtra("action", all ? "reply_all" : "reply")
.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);
}
}.load(context, owner, args);
}
ItemDetailsLookup.ItemDetails<Long> getItemDetails(@NonNull MotionEvent motionEvent) {