Send attachments w/ UnifiedEmail outgoing mail
Change-Id: I471816dcaac1ab53aea1465dd69ae4453a1a0268
This commit is contained in:
parent
1d3f98c522
commit
c8afa2f5cb
@ -26,7 +26,9 @@ unified_email_src_dir := ../UnifiedEmail/src
|
||||
|
||||
imported_unified_email_files := \
|
||||
$(unified_email_src_dir)/com/android/mail/providers/UIProviderValidator.java \
|
||||
$(unified_email_src_dir)/com/android/mail/providers/UIProvider.java
|
||||
$(unified_email_src_dir)/com/android/mail/providers/UIProvider.java \
|
||||
$(unified_email_src_dir)/com/android/mail/providers/Attachment.java \
|
||||
$(unified_email_src_dir)/com/android/mail/providers/Message.java
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
|
@ -2999,6 +2999,22 @@ outer:
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a UIProvider attachment to an EmailProvider attachment (for sending); we only need
|
||||
* a few of the fields
|
||||
* @param uiAtt the UIProvider attachment to convert
|
||||
* @return the EmailProvider attachment
|
||||
*/
|
||||
private Attachment convertUiAttachmentToAttachment(
|
||||
com.android.mail.providers.Attachment uiAtt) {
|
||||
Attachment att = new Attachment();
|
||||
att.mContentUri = uiAtt.contentUri;
|
||||
att.mFileName = uiAtt.name;
|
||||
att.mMimeType = uiAtt.mimeType;
|
||||
att.mSize = uiAtt.size;
|
||||
return att;
|
||||
}
|
||||
|
||||
private int uiSendmail(Uri uri, ContentValues values) {
|
||||
Context context = getContext();
|
||||
String accountName = uri.getPathSegments().get(1);
|
||||
@ -3016,6 +3032,18 @@ outer:
|
||||
msg.mHtml = values.getAsString(UIProvider.MessageColumns.BODY_HTML);
|
||||
msg.mMailboxKey = mailbox.mId;
|
||||
msg.mAccountKey = mailbox.mAccountKey;
|
||||
// Get attachments from the ContentValues
|
||||
ArrayList<com.android.mail.providers.Attachment> uiAtts =
|
||||
com.android.mail.providers.Attachment.getAttachmentsFromJoinedAttachmentInfo(
|
||||
values.getAsString(UIProvider.MessageColumns.JOINED_ATTACHMENT_INFOS));
|
||||
ArrayList<Attachment> atts = new ArrayList<Attachment>();
|
||||
for (com.android.mail.providers.Attachment uiAtt: uiAtts) {
|
||||
// Convert to our attachments and add to the list; everything else should "just work"
|
||||
atts.add(convertUiAttachmentToAttachment(uiAtt));
|
||||
}
|
||||
if (!atts.isEmpty()) {
|
||||
msg.mAttachments = atts;
|
||||
}
|
||||
// Save it
|
||||
msg.save(context);
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user