From 5520221f60e6ef2739a1898e24e0ef9d26a2c94f Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 24 Jan 2012 14:23:38 -0800 Subject: [PATCH] Handle insert instead of update for "send mail" * Return proper Uri from insert Change-Id: I5439fff9872a14c63504a17a2bfef34ff19f99c6 --- src/com/android/email/provider/EmailProvider.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index d80a3696e..6924a71eb 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -1653,6 +1653,8 @@ public class EmailProvider extends ContentProvider { try { switch (match) { + case UI_SENDMAIL: + return uiSendmail(uri, values); // NOTE: It is NOT legal for production code to insert directly into UPDATED_MESSAGE // or DELETED_MESSAGE; see the comment below for details case UPDATED_MESSAGE: @@ -2202,8 +2204,6 @@ public class EmailProvider extends ContentProvider { } outer: switch (match) { - case UI_SENDMAIL: - return uiSendmail(uri, values); case UI_MESSAGE: return uiUpdateMessage(uri, values); case MAILBOX_ID_ADD_TO_FIELD: @@ -3037,13 +3037,13 @@ outer: return att; } - private int uiSendmail(Uri uri, ContentValues values) { + private Uri uiSendmail(Uri uri, ContentValues values) { Context context = getContext(); String accountName = uri.getPathSegments().get(1); long acctId = findAccountIdByName(accountName); - if (acctId == Account.NO_ACCOUNT) return 0; + if (acctId == Account.NO_ACCOUNT) return null; Mailbox mailbox = Mailbox.restoreMailboxOfType(context, acctId, Mailbox.TYPE_OUTBOX); - if (mailbox == null) return 0; + if (mailbox == null) return null; Message msg = new Message(); // Fill in the message msg.mTo = values.getAsString(UIProvider.MessageColumns.TO); @@ -3068,7 +3068,7 @@ outer: } // Save it msg.save(context); - return 1; + return Uri.parse("'content://" + EmailContent.AUTHORITY + "/uimessage/" + msg.mId); } private void putIntegerOrBoolean(ContentValues values, String columnName, Object value) {