Merge "Don't use SYNCED_MESSAGE_URI for POP3/Drafts/Outbox/Search"

This commit is contained in:
Marc Blank 2012-04-16 15:37:12 -07:00 committed by Android (Google) Code Review
commit 65381f907b
2 changed files with 16 additions and 3 deletions

View File

@ -518,6 +518,14 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns
return false;
}
public boolean uploadsToServer(Context context) {
if (mType == TYPE_DRAFTS || mType == TYPE_OUTBOX || mType == TYPE_SEARCH) {
return false;
}
String protocol = Account.getProtocol(context, mAccountKey);
return (!protocol.equals(HostAuth.SCHEME_POP3));
}
/**
* @return true if messages in a mailbox of a type can be replied/forwarded.
*/

View File

@ -3332,10 +3332,15 @@ outer:
}
private int uiUpdateMessage(Uri uri, ContentValues values) {
Uri ourUri = convertToEmailProviderUri(uri, Message.SYNCED_CONTENT_URI, true);
if (ourUri == null) return 0;
Context context = getContext();
Message msg = getMessageFromLastSegment(uri);
if (msg == null) return 0;
Mailbox mailbox = Mailbox.restoreMailboxWithId(context, msg.mMailboxKey);
if (mailbox == null) return 0;
Uri ourBaseUri =
mailbox.uploadsToServer(context) ? Message.SYNCED_CONTENT_URI : Message.CONTENT_URI;
Uri ourUri = convertToEmailProviderUri(uri, ourBaseUri, true);
if (ourUri == null) return 0;
ContentValues undoValues = new ContentValues();
ContentValues ourValues = convertUiMessageValues(msg, values);
for (String columnName: ourValues.keySet()) {
@ -3352,7 +3357,7 @@ outer:
}
ContentProviderOperation op =
ContentProviderOperation.newUpdate(convertToEmailProviderUri(
uri,Message.SYNCED_CONTENT_URI, false))
uri, ourBaseUri, false))
.withValues(undoValues)
.build();
addToSequence(uri, op);