From d731127c05fe6da6d1b82f79a515d3c47d9401c5 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 3 Apr 2012 15:36:11 -0700 Subject: [PATCH] Set draftType in outgoing messages and return it Change-Id: Ie95d04b5da8125f846e40c3d703655f35d599cd1 --- .../emailcommon/provider/EmailContent.java | 7 ++++- .../android/email/provider/EmailProvider.java | 26 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java b/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java index eb229be2c..d253f9442 100755 --- a/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java +++ b/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java @@ -741,7 +741,6 @@ public abstract class EmailContent { // Bits used in mFlags // The following three states are mutually exclusive, and indicate whether the message is an // original, a reply, or a forward - public static final int FLAG_TYPE_ORIGINAL = 0; public static final int FLAG_TYPE_REPLY = 1<<0; public static final int FLAG_TYPE_FORWARD = 1<<1; public static final int FLAG_TYPE_MASK = FLAG_TYPE_REPLY | FLAG_TYPE_FORWARD; @@ -772,6 +771,12 @@ public abstract class EmailContent { public static final int FLAG_REPLIED_TO = 1 << 18; public static final int FLAG_FORWARDED = 1 << 19; + // Outgoing, original message + public static final int FLAG_TYPE_ORIGINAL = 1 << 20; + // Outgoing, reply all message; note, FLAG_TYPE_REPLY should also be set for backward + // compatibility + public static final int FLAG_TYPE_REPLY_ALL = 1 << 21; + /** a pseudo ID for "no message". */ public static final long NO_MESSAGE = -1L; diff --git a/email2/src/com/android/email/provider/EmailProvider.java b/email2/src/com/android/email/provider/EmailProvider.java index d3fb0eb7e..32c0418e8 100644 --- a/email2/src/com/android/email/provider/EmailProvider.java +++ b/email2/src/com/android/email/provider/EmailProvider.java @@ -1985,6 +1985,21 @@ outer: .add(UIProvider.ConversationColumns.FLAGS, getConversationFlags()) .build(); + + /** + * Generate UIProvider draft type; note the test for "reply all" must come before "reply" + */ + private static final String MESSAGE_DRAFT_TYPE = + "CASE WHEN (" + MessageColumns.FLAGS + "&" + Message.FLAG_TYPE_ORIGINAL + + ") !=0 THEN " + UIProvider.DraftType.COMPOSE + + " WHEN (" + MessageColumns.FLAGS + "&" + (1<<20) + + ") !=0 THEN " + UIProvider.DraftType.REPLY_ALL + + " WHEN (" + MessageColumns.FLAGS + "&" + Message.FLAG_TYPE_REPLY + + ") !=0 THEN " + UIProvider.DraftType.REPLY + + " WHEN (" + MessageColumns.FLAGS + "&" + Message.FLAG_TYPE_FORWARD + + ") !=0 THEN " + UIProvider.DraftType.FORWARD + + " ELSE " + UIProvider.DraftType.NOT_A_DRAFT + " END"; + /** * Mapping of UIProvider columns to EmailProvider columns for a detailed message view in * UnifiedEmail @@ -2010,7 +2025,8 @@ outer: .add(UIProvider.MessageColumns.DRAFT_TYPE, NOT_A_DRAFT_STRING) .add(UIProvider.MessageColumns.APPEND_REF_MESSAGE_CONTENT, "0") .add(UIProvider.MessageColumns.HAS_ATTACHMENTS, EmailContent.MessageColumns.FLAG_ATTACHMENT) - .add(UIProvider.MessageColumns.ATTACHMENT_LIST_URI, uriWithFQId("uiattachments", Message.TABLE_NAME)) + .add(UIProvider.MessageColumns.ATTACHMENT_LIST_URI, + uriWithFQId("uiattachments", Message.TABLE_NAME)) .add(UIProvider.MessageColumns.MESSAGE_FLAGS, "0") .add(UIProvider.MessageColumns.SAVE_MESSAGE_URI, uriWithFQId("uiupdatedraft", Message.TABLE_NAME)) @@ -2018,6 +2034,7 @@ outer: uriWithFQId("uisenddraft", Message.TABLE_NAME)) // TODO(pwestbro): make this actually return valid results. .add(UIProvider.MessageColumns.ALWAYS_SHOW_IMAGES, "0") + .add(UIProvider.MessageColumns.DRAFT_TYPE, MESSAGE_DRAFT_TYPE) .build(); /** @@ -2809,10 +2826,15 @@ outer: case DraftType.FORWARD: flags |= Message.FLAG_TYPE_FORWARD; break; - case DraftType.REPLY: case DraftType.REPLY_ALL: + flags |= Message.FLAG_TYPE_REPLY_ALL; + // Fall through + case DraftType.REPLY: flags |= Message.FLAG_TYPE_REPLY; break; + case DraftType.COMPOSE: + flags |= Message.FLAG_TYPE_ORIGINAL; + break; } msg.mFlags = flags; String ref = values.getAsString(UIProvider.MessageColumns.REF_MESSAGE_ID);