Handle insert instead of update for "send mail"
* Return proper Uri from insert Change-Id: I5439fff9872a14c63504a17a2bfef34ff19f99c6
This commit is contained in:
parent
7f667159c9
commit
5520221f60
@ -1653,6 +1653,8 @@ public class EmailProvider extends ContentProvider {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
switch (match) {
|
switch (match) {
|
||||||
|
case UI_SENDMAIL:
|
||||||
|
return uiSendmail(uri, values);
|
||||||
// NOTE: It is NOT legal for production code to insert directly into UPDATED_MESSAGE
|
// NOTE: It is NOT legal for production code to insert directly into UPDATED_MESSAGE
|
||||||
// or DELETED_MESSAGE; see the comment below for details
|
// or DELETED_MESSAGE; see the comment below for details
|
||||||
case UPDATED_MESSAGE:
|
case UPDATED_MESSAGE:
|
||||||
@ -2202,8 +2204,6 @@ public class EmailProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
outer:
|
outer:
|
||||||
switch (match) {
|
switch (match) {
|
||||||
case UI_SENDMAIL:
|
|
||||||
return uiSendmail(uri, values);
|
|
||||||
case UI_MESSAGE:
|
case UI_MESSAGE:
|
||||||
return uiUpdateMessage(uri, values);
|
return uiUpdateMessage(uri, values);
|
||||||
case MAILBOX_ID_ADD_TO_FIELD:
|
case MAILBOX_ID_ADD_TO_FIELD:
|
||||||
@ -3037,13 +3037,13 @@ outer:
|
|||||||
return att;
|
return att;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int uiSendmail(Uri uri, ContentValues values) {
|
private Uri uiSendmail(Uri uri, ContentValues values) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
String accountName = uri.getPathSegments().get(1);
|
String accountName = uri.getPathSegments().get(1);
|
||||||
long acctId = findAccountIdByName(accountName);
|
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);
|
Mailbox mailbox = Mailbox.restoreMailboxOfType(context, acctId, Mailbox.TYPE_OUTBOX);
|
||||||
if (mailbox == null) return 0;
|
if (mailbox == null) return null;
|
||||||
Message msg = new Message();
|
Message msg = new Message();
|
||||||
// Fill in the message
|
// Fill in the message
|
||||||
msg.mTo = values.getAsString(UIProvider.MessageColumns.TO);
|
msg.mTo = values.getAsString(UIProvider.MessageColumns.TO);
|
||||||
@ -3068,7 +3068,7 @@ outer:
|
|||||||
}
|
}
|
||||||
// Save it
|
// Save it
|
||||||
msg.save(context);
|
msg.save(context);
|
||||||
return 1;
|
return Uri.parse("'content://" + EmailContent.AUTHORITY + "/uimessage/" + msg.mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putIntegerOrBoolean(ContentValues values, String columnName, Object value) {
|
private void putIntegerOrBoolean(ContentValues values, String columnName, Object value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user