Merge "Compose: Fix bug where attachments can't be removed"

This commit is contained in:
Makoto Onuki 2011-03-02 17:53:56 -08:00 committed by Android (Google) Code Review
commit ace01c0fb1

View File

@ -680,9 +680,10 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
// Drafts and "forwards" need to include attachments from the original unless the // Drafts and "forwards" need to include attachments from the original unless the
// account is marked as supporting smart forward // account is marked as supporting smart forward
if (ACTION_EDIT_DRAFT.equals(mAction) || ACTION_FORWARD.equals(mAction)) { final boolean isEditDraft = ACTION_EDIT_DRAFT.equals(mAction);
final boolean draft = ACTION_EDIT_DRAFT.equals(mAction); final boolean isForward = ACTION_FORWARD.equals(mAction);
if (draft) { if (isEditDraft || isForward) {
if (isEditDraft) {
mDraft = message; mDraft = message;
} else { } else {
mSource = message; mSource = message;
@ -698,14 +699,23 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
if (attachments == null) { if (attachments == null) {
return; return;
} }
boolean smartForward = final boolean supportsSmartForward =
(account.mFlags & Account.FLAGS_SUPPORTS_SMART_FORWARD) != 0; (account.mFlags & Account.FLAGS_SUPPORTS_SMART_FORWARD) != 0;
for (Attachment attachment : attachments) { for (Attachment attachment : attachments) {
if (smartForward && !draft) { if (supportsSmartForward && isForward) {
attachment.mFlags |= Attachment.FLAG_SMART_FORWARD; attachment.mFlags |= Attachment.FLAG_SMART_FORWARD;
} }
addAttachment(attachment, !smartForward); // Note allowDelete is set in two cases:
// 1. First time a message (w/ attachments) is forwarded,
// where action == ACTION_FORWARD
// 2. 1 -> Save -> Reopen, where action == EDIT_DRAFT,
// but FLAG_SMART_FORWARD is already set at 1.
// Even if the account supports smart-forward, attachments added
// manually are still removable.
final boolean allowDelete =
(attachment.mFlags & Attachment.FLAG_SMART_FORWARD) == 0;
addAttachment(attachment, allowDelete);
} }
} }
}.execute(message.mId); }.execute(message.mId);