Bulk change of columns, LAST TIME.
* Add reply columns to Body * Remove a bunch of unused columns from Message * Update SQL tables, content read/write, etc. * Small tweaks to app code that was not-really-using the old columns. * Update existing unit tests for new/changed columns * Disable TagsTests to solve a tests failure (prexisting, not caused by this CL) Change-Id: Ief493796dfe219669755170d76786f91570cbb9b
This commit is contained in:
parent
4bc201d9d0
commit
936babc145
@ -70,7 +70,6 @@ public class LegacyConversions {
|
||||
if (subject != null) {
|
||||
localMessage.mSubject = subject;
|
||||
}
|
||||
// public String mPreview;
|
||||
localMessage.mFlagRead = message.isSet(Flag.SEEN);
|
||||
|
||||
// Keep the message in the "unloaded" state until it has (at least) a display name.
|
||||
@ -85,22 +84,16 @@ public class LegacyConversions {
|
||||
localMessage.mFlagFavorite = message.isSet(Flag.FLAGGED);
|
||||
// public boolean mFlagAttachment = false;
|
||||
// public int mFlags = 0;
|
||||
//
|
||||
// public String mTextInfo;
|
||||
// public String mHtmlInfo;
|
||||
//
|
||||
|
||||
localMessage.mServerId = message.getUid();
|
||||
// public int mServerIntId;
|
||||
// public String mClientId;
|
||||
// public String mMessageId;
|
||||
// public String mThreadId;
|
||||
//
|
||||
|
||||
// public long mBodyKey;
|
||||
localMessage.mMailboxKey = mailboxId;
|
||||
localMessage.mAccountKey = accountId;
|
||||
// public long mReferenceKey;
|
||||
//
|
||||
// public String mSender;
|
||||
|
||||
if (from != null && from.length > 0) {
|
||||
localMessage.mFrom = Address.pack(from);
|
||||
}
|
||||
@ -110,11 +103,11 @@ public class LegacyConversions {
|
||||
localMessage.mBcc = Address.pack(bcc);
|
||||
localMessage.mReplyTo = Address.pack(replyTo);
|
||||
|
||||
// public String mServerVersion;
|
||||
//
|
||||
// public String mText;
|
||||
// public String mHtml;
|
||||
//
|
||||
// public String mTextReply;
|
||||
// public String mHtmlReply;
|
||||
|
||||
// // Can be used while building messages, but is NOT saved by the Provider
|
||||
// transient public ArrayList<Attachment> mAttachments = null;
|
||||
|
||||
@ -123,8 +116,6 @@ public class LegacyConversions {
|
||||
|
||||
/**
|
||||
* Copy body text (plain and/or HTML) from MimeMessage to provider Message
|
||||
*
|
||||
* TODO: Take a closer look at textInfo and deal with it if necessary.
|
||||
*/
|
||||
public static boolean updateBodyFields(EmailContent.Body body,
|
||||
EmailContent.Message localMessage, ArrayList<Part> viewables)
|
||||
@ -151,11 +142,9 @@ public class LegacyConversions {
|
||||
|
||||
// write the combined data to the body part
|
||||
if (sbText.length() != 0) {
|
||||
localMessage.mTextInfo = "X;X;8;" + sbText.length()*2;
|
||||
body.mTextContent = sbText.toString();
|
||||
}
|
||||
if (sbHtml.length() != 0) {
|
||||
localMessage.mHtmlInfo = "X;X;8;" + sbHtml.length()*2;
|
||||
body.mHtmlContent = sbHtml.toString();
|
||||
}
|
||||
return true;
|
||||
@ -166,8 +155,7 @@ public class LegacyConversions {
|
||||
*
|
||||
* @param context a context for file operations
|
||||
* @param localMessage the attachments will be built against this message
|
||||
* @param message the original message from POP or IMAP, that may have attachments
|
||||
* @return true if it succeeded
|
||||
* @param attachments the attachments to add
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void updateAttachments(Context context, EmailContent.Message localMessage,
|
||||
@ -188,7 +176,6 @@ public class LegacyConversions {
|
||||
* @param context a context for file operations
|
||||
* @param localMessage the attachments will be built against this message
|
||||
* @param part a single attachment part from POP or IMAP
|
||||
* @return true if it succeeded
|
||||
* @throws IOException
|
||||
*/
|
||||
private static void addOneAttachment(Context context, EmailContent.Message localMessage,
|
||||
@ -217,7 +204,7 @@ public class LegacyConversions {
|
||||
// Get partId for unloaded IMAP attachments (if any)
|
||||
// This is only provided (and used) when we have structure but not the actual attachment
|
||||
String[] partIds = part.getHeader(MimeHeader.HEADER_ANDROID_ATTACHMENT_STORE_DATA);
|
||||
String partId = partIds != null ? partIds[0] : null;;
|
||||
String partId = partIds != null ? partIds[0] : null;
|
||||
|
||||
localAttachment.mFileName = MimeUtility.getHeaderParameter(contentType, "name");
|
||||
localAttachment.mMimeType = part.getMimeType();
|
||||
|
@ -169,17 +169,8 @@ public abstract class EmailContent {
|
||||
|
||||
public interface SyncColumns {
|
||||
public static final String ID = "_id";
|
||||
// source (account name and type) : foreign key into the AccountsProvider
|
||||
public static final String ACCOUNT_KEY = "syncAccountKey";
|
||||
// source id (string) : the source's name of this item
|
||||
public static final String SERVER_ID = "syncServerId";
|
||||
// source version (string) : the source's concept of the version of this item
|
||||
public static final String SERVER_VERSION = "syncServerVersion";
|
||||
// source sync data (string) : any other data needed to sync this item back to the source
|
||||
public static final String DATA = "syncData";
|
||||
// dirty count (boolean) : the number of times this item has changed since the last time it
|
||||
// was synced to the server
|
||||
public static final String DIRTY_COUNT = "syncDirtyCount";
|
||||
}
|
||||
|
||||
public interface BodyColumns {
|
||||
@ -190,6 +181,10 @@ public abstract class EmailContent {
|
||||
public static final String HTML_CONTENT = "htmlContent";
|
||||
// The plain text content itself
|
||||
public static final String TEXT_CONTENT = "textContent";
|
||||
// Replied-to or forwarded body (in html form)
|
||||
public static final String HTML_REPLY = "htmlReply";
|
||||
// Replied-to or forwarded body (in text form)
|
||||
public static final String TEXT_REPLY = "textReply";
|
||||
}
|
||||
|
||||
public static final class Body extends EmailContent implements BodyColumns {
|
||||
@ -201,8 +196,11 @@ public abstract class EmailContent {
|
||||
public static final int CONTENT_MESSAGE_KEY_COLUMN = 1;
|
||||
public static final int CONTENT_HTML_CONTENT_COLUMN = 2;
|
||||
public static final int CONTENT_TEXT_CONTENT_COLUMN = 3;
|
||||
public static final int CONTENT_HTML_REPLY_COLUMN = 4;
|
||||
public static final int CONTENT_TEXT_REPLY_COLUMN = 5;
|
||||
public static final String[] CONTENT_PROJECTION = new String[] {
|
||||
RECORD_ID, BodyColumns.MESSAGE_KEY, BodyColumns.HTML_CONTENT, BodyColumns.TEXT_CONTENT
|
||||
RECORD_ID, BodyColumns.MESSAGE_KEY, BodyColumns.HTML_CONTENT, BodyColumns.TEXT_CONTENT,
|
||||
BodyColumns.HTML_REPLY, BodyColumns.TEXT_REPLY
|
||||
};
|
||||
|
||||
public static final int TEXT_TEXT_COLUMN = 1;
|
||||
@ -220,6 +218,8 @@ public abstract class EmailContent {
|
||||
public long mMessageKey;
|
||||
public String mHtmlContent;
|
||||
public String mTextContent;
|
||||
public String mHtmlReply;
|
||||
public String mTextReply;
|
||||
|
||||
public Body() {
|
||||
mBaseUri = CONTENT_URI;
|
||||
@ -233,6 +233,8 @@ public abstract class EmailContent {
|
||||
values.put(BodyColumns.MESSAGE_KEY, mMessageKey);
|
||||
values.put(BodyColumns.HTML_CONTENT, mHtmlContent);
|
||||
values.put(BodyColumns.TEXT_CONTENT, mTextContent);
|
||||
values.put(BodyColumns.HTML_REPLY, mHtmlReply);
|
||||
values.put(BodyColumns.TEXT_REPLY, mTextReply);
|
||||
|
||||
return values;
|
||||
}
|
||||
@ -326,6 +328,8 @@ public abstract class EmailContent {
|
||||
mMessageKey = c.getLong(CONTENT_MESSAGE_KEY_COLUMN);
|
||||
mHtmlContent = c.getString(CONTENT_HTML_CONTENT_COLUMN);
|
||||
mTextContent = c.getString(CONTENT_TEXT_CONTENT_COLUMN);
|
||||
mHtmlReply = c.getString(CONTENT_HTML_REPLY_COLUMN);
|
||||
mTextReply = c.getString(CONTENT_TEXT_REPLY_COLUMN);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -344,8 +348,6 @@ public abstract class EmailContent {
|
||||
public static final String TIMESTAMP = "timeStamp";
|
||||
// Message subject
|
||||
public static final String SUBJECT = "subject";
|
||||
// A preview, as might be shown to the user in a message list
|
||||
public static final String PREVIEW = "preview";
|
||||
// Boolean, unread = 0, read = 1 [INDEX]
|
||||
public static final String FLAG_READ = "flagRead";
|
||||
// Three state, unloaded = 0, loaded = 1, partially loaded (optional) = 2 [INDEX]
|
||||
@ -354,35 +356,22 @@ public abstract class EmailContent {
|
||||
public static final String FLAG_FAVORITE = "flagFavorite";
|
||||
// Boolean, no attachment = 0, attachment = 1
|
||||
public static final String FLAG_ATTACHMENT = "flagAttachment";
|
||||
// Bit field, e.g. replied, deleted
|
||||
// Bit field for flags which we'll not be selecting on
|
||||
public static final String FLAGS = "flags";
|
||||
|
||||
// Body related
|
||||
// charset: U = us-ascii; 8 = utf-8; I = iso-8559-1; others literally (e.g. KOI8-R)
|
||||
// encodings: B = base64; Q = quoted printable; X = none
|
||||
// Information about the text part (if any) in form <location>;<encoding>;<charset>;<length>
|
||||
public static final String TEXT_INFO = "textInfo";
|
||||
// Information about the html part (if any) in form <location>;<encoding>;<charset>;<length>
|
||||
public static final String HTML_INFO = "htmlInfo";
|
||||
|
||||
// Sync related identifiers
|
||||
// Any client-required identifier
|
||||
public static final String CLIENT_ID = "clientId";
|
||||
// The message-id in the message's header
|
||||
public static final String MESSAGE_ID = "messageId";
|
||||
// Thread identifier
|
||||
public static final String THREAD_ID = "threadId";
|
||||
|
||||
// References to other Email objects in the database
|
||||
// Foreign key to the Mailbox holding this message [INDEX]
|
||||
public static final String MAILBOX_KEY = "mailboxKey";
|
||||
// Foreign key to the Account holding this message
|
||||
public static final String ACCOUNT_KEY = "accountKey";
|
||||
// Foreign key to a referenced Message (e.g. for a reply/forward)
|
||||
public static final String REFERENCE_KEY = "referenceKey";
|
||||
|
||||
// Address lists, packed with Address.pack()
|
||||
public static final String SENDER_LIST = "senderList";
|
||||
public static final String FROM_LIST = "fromList";
|
||||
public static final String TO_LIST = "toList";
|
||||
public static final String CC_LIST = "ccList";
|
||||
@ -410,70 +399,57 @@ public abstract class EmailContent {
|
||||
public static final int CONTENT_DISPLAY_NAME_COLUMN = 1;
|
||||
public static final int CONTENT_TIMESTAMP_COLUMN = 2;
|
||||
public static final int CONTENT_SUBJECT_COLUMN = 3;
|
||||
public static final int CONTENT_PREVIEW_COLUMN = 4;
|
||||
public static final int CONTENT_FLAG_READ_COLUMN = 5;
|
||||
public static final int CONTENT_FLAG_LOADED_COLUMN = 6;
|
||||
public static final int CONTENT_FLAG_FAVORITE_COLUMN = 7;
|
||||
public static final int CONTENT_FLAG_ATTACHMENT_COLUMN = 8;
|
||||
public static final int CONTENT_FLAGS_COLUMN = 9;
|
||||
public static final int CONTENT_TEXT_INFO_COLUMN = 10;
|
||||
public static final int CONTENT_HTML_INFO_COLUMN = 11;
|
||||
public static final int CONTENT_SERVER_ID_COLUMN = 12;
|
||||
public static final int CONTENT_CLIENT_ID_COLUMN = 13;
|
||||
public static final int CONTENT_MESSAGE_ID_COLUMN = 14;
|
||||
public static final int CONTENT_THREAD_ID_COLUMN = 15;
|
||||
public static final int CONTENT_MAILBOX_KEY_COLUMN = 16;
|
||||
public static final int CONTENT_ACCOUNT_KEY_COLUMN = 17;
|
||||
public static final int CONTENT_REFERENCE_KEY_COLUMN = 18;
|
||||
public static final int CONTENT_SENDER_LIST_COLUMN = 19;
|
||||
public static final int CONTENT_FROM_LIST_COLUMN = 20;
|
||||
public static final int CONTENT_TO_LIST_COLUMN = 21;
|
||||
public static final int CONTENT_CC_LIST_COLUMN = 22;
|
||||
public static final int CONTENT_BCC_LIST_COLUMN = 23;
|
||||
public static final int CONTENT_REPLY_TO_COLUMN = 24;
|
||||
public static final int CONTENT_SERVER_VERSION_COLUMN = 25;
|
||||
public static final int CONTENT_FLAG_READ_COLUMN = 4;
|
||||
public static final int CONTENT_FLAG_LOADED_COLUMN = 5;
|
||||
public static final int CONTENT_FLAG_FAVORITE_COLUMN = 6;
|
||||
public static final int CONTENT_FLAG_ATTACHMENT_COLUMN = 7;
|
||||
public static final int CONTENT_FLAGS_COLUMN = 8;
|
||||
public static final int CONTENT_SERVER_ID_COLUMN = 9;
|
||||
public static final int CONTENT_CLIENT_ID_COLUMN = 10;
|
||||
public static final int CONTENT_MESSAGE_ID_COLUMN = 11;
|
||||
public static final int CONTENT_MAILBOX_KEY_COLUMN = 12;
|
||||
public static final int CONTENT_ACCOUNT_KEY_COLUMN = 13;
|
||||
public static final int CONTENT_FROM_LIST_COLUMN = 14;
|
||||
public static final int CONTENT_TO_LIST_COLUMN = 15;
|
||||
public static final int CONTENT_CC_LIST_COLUMN = 16;
|
||||
public static final int CONTENT_BCC_LIST_COLUMN = 17;
|
||||
public static final int CONTENT_REPLY_TO_COLUMN = 18;
|
||||
|
||||
public static final String[] CONTENT_PROJECTION = new String[] {
|
||||
RECORD_ID, MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
|
||||
MessageColumns.SUBJECT, MessageColumns.PREVIEW, MessageColumns.FLAG_READ,
|
||||
RECORD_ID,
|
||||
MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
|
||||
MessageColumns.SUBJECT, MessageColumns.FLAG_READ,
|
||||
MessageColumns.FLAG_LOADED, MessageColumns.FLAG_FAVORITE,
|
||||
MessageColumns.FLAG_ATTACHMENT, MessageColumns.FLAGS, MessageColumns.TEXT_INFO,
|
||||
MessageColumns.HTML_INFO, SyncColumns.SERVER_ID,
|
||||
MessageColumns.CLIENT_ID, MessageColumns.MESSAGE_ID, MessageColumns.THREAD_ID,
|
||||
MessageColumns.MAILBOX_KEY, MessageColumns.ACCOUNT_KEY, MessageColumns.REFERENCE_KEY,
|
||||
MessageColumns.SENDER_LIST, MessageColumns.FROM_LIST, MessageColumns.TO_LIST,
|
||||
MessageColumns.CC_LIST, MessageColumns.BCC_LIST, MessageColumns.REPLY_TO_LIST,
|
||||
SyncColumns.SERVER_VERSION
|
||||
MessageColumns.FLAG_ATTACHMENT, MessageColumns.FLAGS,
|
||||
SyncColumns.SERVER_ID, MessageColumns.CLIENT_ID,
|
||||
MessageColumns.MESSAGE_ID, MessageColumns.MAILBOX_KEY,
|
||||
MessageColumns.ACCOUNT_KEY, MessageColumns.FROM_LIST,
|
||||
MessageColumns.TO_LIST, MessageColumns.CC_LIST,
|
||||
MessageColumns.BCC_LIST, MessageColumns.REPLY_TO_LIST,
|
||||
};
|
||||
|
||||
public static final int LIST_ID_COLUMN = 0;
|
||||
public static final int LIST_DISPLAY_NAME_COLUMN = 1;
|
||||
public static final int LIST_TIMESTAMP_COLUMN = 2;
|
||||
public static final int LIST_SUBJECT_COLUMN = 3;
|
||||
public static final int LIST_PREVIEW_COLUMN = 4;
|
||||
public static final int LIST_READ_COLUMN = 5;
|
||||
public static final int LIST_LOADED_COLUMN = 6;
|
||||
public static final int LIST_FAVORITE_COLUMN = 7;
|
||||
public static final int LIST_ATTACHMENT_COLUMN = 8;
|
||||
public static final int LIST_FLAGS_COLUMN = 9;
|
||||
public static final int LIST_MAILBOX_KEY_COLUMN = 10;
|
||||
public static final int LIST_ACCOUNT_KEY_COLUMN = 11;
|
||||
public static final int LIST_SERVER_ID_COLUMN = 12;
|
||||
public static final int LIST_READ_COLUMN = 4;
|
||||
public static final int LIST_LOADED_COLUMN = 5;
|
||||
public static final int LIST_FAVORITE_COLUMN = 6;
|
||||
public static final int LIST_ATTACHMENT_COLUMN = 7;
|
||||
public static final int LIST_FLAGS_COLUMN = 8;
|
||||
public static final int LIST_MAILBOX_KEY_COLUMN = 9;
|
||||
public static final int LIST_ACCOUNT_KEY_COLUMN = 10;
|
||||
public static final int LIST_SERVER_ID_COLUMN = 11;
|
||||
|
||||
// Public projection for common list columns
|
||||
public static final String[] LIST_PROJECTION = new String[] {
|
||||
RECORD_ID, MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
|
||||
MessageColumns.SUBJECT, MessageColumns.PREVIEW, MessageColumns.FLAG_READ,
|
||||
RECORD_ID,
|
||||
MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
|
||||
MessageColumns.SUBJECT, MessageColumns.FLAG_READ,
|
||||
MessageColumns.FLAG_LOADED, MessageColumns.FLAG_FAVORITE,
|
||||
MessageColumns.FLAG_ATTACHMENT, MessageColumns.FLAGS, MessageColumns.MAILBOX_KEY,
|
||||
MessageColumns.ACCOUNT_KEY , SyncColumns.SERVER_ID
|
||||
};
|
||||
|
||||
public static final int LOAD_BODY_ID_COLUMN = 0;
|
||||
public static final int LOAD_BODY_SERVER_ID_COLUMN = 1;
|
||||
public static final int LOAD_BODY_TEXT_INFO_COLUMN = 2;
|
||||
public static final int LOAD_BODY_HTML_INFO_COLUMN = 3;
|
||||
public static final String[] LOAD_BODY_PROJECTION = new String[] {
|
||||
RECORD_ID, SyncColumns.SERVER_ID, MessageColumns.TEXT_INFO, MessageColumns.HTML_INFO
|
||||
MessageColumns.FLAG_ATTACHMENT, MessageColumns.FLAGS,
|
||||
MessageColumns.MAILBOX_KEY, MessageColumns.ACCOUNT_KEY,
|
||||
SyncColumns.SERVER_ID
|
||||
};
|
||||
|
||||
public static final int ID_COLUMNS_ID_COLUMN = 0;
|
||||
@ -488,37 +464,30 @@ public abstract class EmailContent {
|
||||
public String mDisplayName;
|
||||
public long mTimeStamp;
|
||||
public String mSubject;
|
||||
public String mPreview;
|
||||
public boolean mFlagRead = false;
|
||||
public int mFlagLoaded = 0;
|
||||
public boolean mFlagFavorite = false;
|
||||
public boolean mFlagAttachment = false;
|
||||
public int mFlags = 0;
|
||||
|
||||
public String mTextInfo;
|
||||
public String mHtmlInfo;
|
||||
|
||||
public String mServerId;
|
||||
public int mServerIntId;
|
||||
public String mClientId;
|
||||
public String mMessageId;
|
||||
public String mThreadId;
|
||||
|
||||
public long mMailboxKey;
|
||||
public long mAccountKey;
|
||||
public long mReferenceKey;
|
||||
|
||||
public String mSender;
|
||||
public String mFrom;
|
||||
public String mTo;
|
||||
public String mCc;
|
||||
public String mBcc;
|
||||
public String mReplyTo;
|
||||
|
||||
public String mServerVersion;
|
||||
|
||||
transient public String mText;
|
||||
transient public String mHtml;
|
||||
transient public String mTextReply;
|
||||
transient public String mHtmlReply;
|
||||
|
||||
// Can be used while building messages, but is NOT saved by the Provider
|
||||
transient public ArrayList<Attachment> mAttachments = null;
|
||||
@ -543,16 +512,12 @@ public abstract class EmailContent {
|
||||
values.put(MessageColumns.DISPLAY_NAME, mDisplayName);
|
||||
values.put(MessageColumns.TIMESTAMP, mTimeStamp);
|
||||
values.put(MessageColumns.SUBJECT, mSubject);
|
||||
values.put(MessageColumns.PREVIEW, mPreview);
|
||||
values.put(MessageColumns.FLAG_READ, mFlagRead);
|
||||
values.put(MessageColumns.FLAG_LOADED, mFlagLoaded);
|
||||
values.put(MessageColumns.FLAG_FAVORITE, mFlagFavorite);
|
||||
values.put(MessageColumns.FLAG_ATTACHMENT, mFlagAttachment);
|
||||
values.put(MessageColumns.FLAGS, mFlags);
|
||||
|
||||
values.put(MessageColumns.TEXT_INFO, mTextInfo);
|
||||
values.put(MessageColumns.HTML_INFO, mHtmlInfo);
|
||||
|
||||
if (mServerId != null) {
|
||||
values.put(SyncColumns.SERVER_ID, mServerId);
|
||||
} else {
|
||||
@ -561,21 +526,16 @@ public abstract class EmailContent {
|
||||
|
||||
values.put(MessageColumns.CLIENT_ID, mClientId);
|
||||
values.put(MessageColumns.MESSAGE_ID, mMessageId);
|
||||
values.put(MessageColumns.THREAD_ID, mThreadId);
|
||||
|
||||
values.put(MessageColumns.MAILBOX_KEY, mMailboxKey);
|
||||
values.put(MessageColumns.ACCOUNT_KEY, mAccountKey);
|
||||
values.put(MessageColumns.REFERENCE_KEY, mReferenceKey);
|
||||
|
||||
values.put(MessageColumns.SENDER_LIST, mSender);
|
||||
values.put(MessageColumns.FROM_LIST, mFrom);
|
||||
values.put(MessageColumns.TO_LIST, mTo);
|
||||
values.put(MessageColumns.CC_LIST, mCc);
|
||||
values.put(MessageColumns.BCC_LIST, mBcc);
|
||||
values.put(MessageColumns.REPLY_TO_LIST, mReplyTo);
|
||||
|
||||
values.put(SyncColumns.SERVER_VERSION, mServerVersion);
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
@ -603,29 +563,22 @@ public abstract class EmailContent {
|
||||
mDisplayName = c.getString(CONTENT_DISPLAY_NAME_COLUMN);
|
||||
mTimeStamp = c.getLong(CONTENT_TIMESTAMP_COLUMN);
|
||||
mSubject = c.getString(CONTENT_SUBJECT_COLUMN);
|
||||
mPreview = c.getString(CONTENT_PREVIEW_COLUMN);
|
||||
mFlagRead = c.getInt(CONTENT_FLAG_READ_COLUMN) == 1;
|
||||
mFlagLoaded = c.getInt(CONTENT_FLAG_LOADED_COLUMN);
|
||||
mFlagFavorite = c.getInt(CONTENT_FLAG_FAVORITE_COLUMN) == 1;
|
||||
mFlagAttachment = c.getInt(CONTENT_FLAG_ATTACHMENT_COLUMN) == 1;
|
||||
mFlags = c.getInt(CONTENT_FLAGS_COLUMN);
|
||||
mTextInfo = c.getString(CONTENT_TEXT_INFO_COLUMN);
|
||||
mHtmlInfo = c.getString(CONTENT_HTML_INFO_COLUMN);
|
||||
mServerId = c.getString(CONTENT_SERVER_ID_COLUMN);
|
||||
mServerIntId = c.getInt(CONTENT_SERVER_ID_COLUMN);
|
||||
mClientId = c.getString(CONTENT_CLIENT_ID_COLUMN);
|
||||
mMessageId = c.getString(CONTENT_MESSAGE_ID_COLUMN);
|
||||
mThreadId = c.getString(CONTENT_THREAD_ID_COLUMN);
|
||||
mMailboxKey = c.getLong(CONTENT_MAILBOX_KEY_COLUMN);
|
||||
mAccountKey = c.getLong(CONTENT_ACCOUNT_KEY_COLUMN);
|
||||
mReferenceKey = c.getLong(CONTENT_REFERENCE_KEY_COLUMN);
|
||||
mSender = c.getString(CONTENT_SENDER_LIST_COLUMN);
|
||||
mFrom = c.getString(CONTENT_FROM_LIST_COLUMN);
|
||||
mTo = c.getString(CONTENT_TO_LIST_COLUMN);
|
||||
mCc = c.getString(CONTENT_CC_LIST_COLUMN);
|
||||
mBcc = c.getString(CONTENT_BCC_LIST_COLUMN);
|
||||
mReplyTo = c.getString(CONTENT_REPLY_TO_COLUMN);
|
||||
mServerVersion = c.getString(CONTENT_SERVER_VERSION_COLUMN);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -648,7 +601,7 @@ public abstract class EmailContent {
|
||||
// This logic is in place so I can (a) short circuit the expensive stuff when
|
||||
// possible, and (b) override (and throw) if anyone tries to call save() or update()
|
||||
// directly for Message, which are unsupported.
|
||||
if (mText == null && mHtml == null &&
|
||||
if (mText == null && mHtml == null && mTextReply == null && mHtmlReply == null &&
|
||||
(mAttachments == null || mAttachments.isEmpty())) {
|
||||
if (doSave) {
|
||||
return super.save(context);
|
||||
@ -706,6 +659,12 @@ public abstract class EmailContent {
|
||||
if (mHtml != null) {
|
||||
cv.put(Body.HTML_CONTENT, mHtml);
|
||||
}
|
||||
if (mTextReply != null) {
|
||||
cv.put(Body.TEXT_REPLY, mTextReply);
|
||||
}
|
||||
if (mHtmlReply != null) {
|
||||
cv.put(Body.HTML_REPLY, mHtmlReply);
|
||||
}
|
||||
b = ContentProviderOperation.newInsert(Body.CONTENT_URI);
|
||||
b.withValues(cv);
|
||||
ContentValues backValues = new ContentValues();
|
||||
@ -722,49 +681,6 @@ public abstract class EmailContent {
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Text and Html information are stored as <location>;<encoding>;<charset>;<length>
|
||||
// charset: U = us-ascii; 8 = utf-8; I = iso-8559-1; others literally (e.g. KOI8-R)
|
||||
// encodings: B = base64; Q = quoted printable; X = none
|
||||
|
||||
public static final class BodyInfo {
|
||||
public String mLocation;
|
||||
public char mEncoding;
|
||||
public String mCharset;
|
||||
public long mLength;
|
||||
|
||||
static public BodyInfo expandFromTextOrHtmlInfo (String info) {
|
||||
BodyInfo b = new BodyInfo();
|
||||
int start = 0;
|
||||
int next = info.indexOf(';');
|
||||
if (next > 0) {
|
||||
b.mLocation = info.substring(start, next);
|
||||
start = next + 1;
|
||||
next = info.indexOf(';', start);
|
||||
if (next > 0) {
|
||||
b.mEncoding = info.charAt(start);
|
||||
start = next + 1;
|
||||
next = info.indexOf(';', start);
|
||||
if (next > 0) {
|
||||
String cs = info.substring(start, next);
|
||||
if (cs.equals("U")) {
|
||||
b.mCharset = "us-ascii";
|
||||
} else if (cs.equals("I")) {
|
||||
b.mCharset = "iso-8859-1";
|
||||
} else if (cs.equals("8")) {
|
||||
b.mCharset = "utf-8";
|
||||
} else {
|
||||
b.mCharset = cs;
|
||||
}
|
||||
start = next + 1;
|
||||
b.mLength = Integer.parseInt(info.substring(start));
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1146,10 +1062,11 @@ public abstract class EmailContent {
|
||||
/**
|
||||
* For compatibility while converting to provider model, set the store URI
|
||||
*
|
||||
* @param the new value
|
||||
* @param context
|
||||
* @param storeUri the new value
|
||||
*/
|
||||
@Deprecated
|
||||
public void setStoreUri(Context context, String senderUri) {
|
||||
public void setStoreUri(Context context, String storeUri) {
|
||||
// reconstitute or create if necessary
|
||||
if (mHostAuthRecv == null) {
|
||||
if (mHostAuthKeyRecv != 0) {
|
||||
@ -1160,14 +1077,15 @@ public abstract class EmailContent {
|
||||
}
|
||||
|
||||
if (mHostAuthRecv != null) {
|
||||
mHostAuthRecv.setStoreUri(senderUri);
|
||||
mHostAuthRecv.setStoreUri(storeUri);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For compatibility while converting to provider model, set the sender URI
|
||||
*
|
||||
* @param the new value
|
||||
* @param context
|
||||
* @param senderUri the new value
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSenderUri(Context context, String senderUri) {
|
||||
|
@ -57,8 +57,8 @@ public class EmailProvider extends ContentProvider {
|
||||
|
||||
// Any changes to the database format *must* include update-in-place code.
|
||||
|
||||
public static final int DATABASE_VERSION = 1;
|
||||
public static final int BODY_DATABASE_VERSION = 1;
|
||||
public static final int DATABASE_VERSION = 2;
|
||||
public static final int BODY_DATABASE_VERSION = 2;
|
||||
|
||||
public static final String EMAIL_AUTHORITY = "com.android.email.provider";
|
||||
|
||||
@ -249,21 +249,15 @@ public class EmailProvider extends ContentProvider {
|
||||
String messageColumns = MessageColumns.DISPLAY_NAME + " text, "
|
||||
+ MessageColumns.TIMESTAMP + " integer, "
|
||||
+ MessageColumns.SUBJECT + " text, "
|
||||
+ MessageColumns.PREVIEW + " text, "
|
||||
+ MessageColumns.FLAG_READ + " integer, "
|
||||
+ MessageColumns.FLAG_LOADED + " integer, "
|
||||
+ MessageColumns.FLAG_FAVORITE + " integer, "
|
||||
+ MessageColumns.FLAG_ATTACHMENT + " integer, "
|
||||
+ MessageColumns.FLAGS + " integer, "
|
||||
+ MessageColumns.TEXT_INFO + " text, "
|
||||
+ MessageColumns.HTML_INFO + " text, "
|
||||
+ MessageColumns.CLIENT_ID + " integer, "
|
||||
+ MessageColumns.MESSAGE_ID + " text, "
|
||||
+ MessageColumns.THREAD_ID + " text, "
|
||||
+ MessageColumns.MAILBOX_KEY + " integer, "
|
||||
+ MessageColumns.ACCOUNT_KEY + " integer, "
|
||||
+ MessageColumns.REFERENCE_KEY + " integer, "
|
||||
+ MessageColumns.SENDER_LIST + " text, "
|
||||
+ MessageColumns.FROM_LIST + " text, "
|
||||
+ MessageColumns.TO_LIST + " text, "
|
||||
+ MessageColumns.CC_LIST + " text, "
|
||||
@ -274,22 +268,14 @@ public class EmailProvider extends ContentProvider {
|
||||
// This String and the following String MUST have the same columns, except for the type
|
||||
// of those columns!
|
||||
String createString = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
|
||||
+ SyncColumns.ACCOUNT_KEY + " integer, "
|
||||
+ SyncColumns.SERVER_ID + " integer, "
|
||||
+ SyncColumns.SERVER_VERSION + " integer, "
|
||||
+ SyncColumns.DATA + " text, "
|
||||
+ SyncColumns.DIRTY_COUNT + " integer, "
|
||||
+ messageColumns;
|
||||
|
||||
// For the updated and deleted tables, the id is assigned, but we do want to keep track
|
||||
// of the ORDER of updates using an autoincrement primary key. We use the DATA column
|
||||
// at this point; it has no other function
|
||||
String altCreateString = " (" + EmailContent.RECORD_ID + " integer unique, "
|
||||
+ SyncColumns.ACCOUNT_KEY + " integer, "
|
||||
+ SyncColumns.SERVER_ID + " integer, "
|
||||
+ SyncColumns.SERVER_VERSION + " integer, "
|
||||
+ SyncColumns.DATA + " integer primary key autoincrement, "
|
||||
+ SyncColumns.DIRTY_COUNT + " integer, "
|
||||
+ messageColumns;
|
||||
|
||||
// The three tables have the same schema
|
||||
@ -492,7 +478,9 @@ public class EmailProvider extends ContentProvider {
|
||||
String s = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
|
||||
+ BodyColumns.MESSAGE_KEY + " integer, "
|
||||
+ BodyColumns.HTML_CONTENT + " text, "
|
||||
+ BodyColumns.TEXT_CONTENT + " text"
|
||||
+ BodyColumns.TEXT_CONTENT + " text, "
|
||||
+ BodyColumns.HTML_REPLY + " text, "
|
||||
+ BodyColumns.TEXT_REPLY + " text"
|
||||
+ ");";
|
||||
db.execSQL("create table " + Body.TABLE_NAME + s);
|
||||
db.execSQL(createIndex(Body.TABLE_NAME, BodyColumns.MESSAGE_KEY));
|
||||
@ -742,10 +730,6 @@ public class EmailProvider extends ContentProvider {
|
||||
case MAILBOX:
|
||||
case ACCOUNT:
|
||||
case HOSTAUTH:
|
||||
// Make sure all new message records have dirty count of 0
|
||||
if (match == MESSAGE) {
|
||||
values.put(SyncColumns.DIRTY_COUNT, 0);
|
||||
}
|
||||
id = db.insert(TABLE_NAMES[table], "foo", values);
|
||||
resultUri = ContentUris.withAppendedId(uri, id);
|
||||
break;
|
||||
|
@ -19,7 +19,6 @@ package com.android.exchange;
|
||||
|
||||
import com.android.email.provider.EmailContent.Message;
|
||||
import com.android.email.provider.EmailContent.MessageColumns;
|
||||
import com.android.email.provider.EmailContent.SyncColumns;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
@ -47,7 +46,7 @@ import java.util.ArrayList;
|
||||
*
|
||||
*/
|
||||
public class EmailSyncAlarmReceiver extends BroadcastReceiver {
|
||||
final String[] MAILBOX_DATA_PROJECTION = {MessageColumns.MAILBOX_KEY, SyncColumns.DATA};
|
||||
final String[] MAILBOX_DATA_PROJECTION = {MessageColumns.MAILBOX_KEY};
|
||||
private static String TAG = "EmailSyncAlarm";
|
||||
|
||||
@Override
|
||||
|
@ -496,13 +496,10 @@ public class SyncManager extends Service implements Runnable {
|
||||
}
|
||||
|
||||
class SyncedMessageObserver extends ContentObserver {
|
||||
long maxChangedId = 0;
|
||||
long maxDeletedId = 0;
|
||||
Intent syncAlarmIntent = new Intent(INSTANCE, EmailSyncAlarmReceiver.class);
|
||||
PendingIntent syncAlarmPendingIntent =
|
||||
PendingIntent.getBroadcast(INSTANCE, 0, syncAlarmIntent, 0);
|
||||
AlarmManager alarmManager = (AlarmManager)INSTANCE.getSystemService(Context.ALARM_SERVICE);
|
||||
final String[] MAILBOX_DATA_PROJECTION = {MessageColumns.MAILBOX_KEY, SyncColumns.DATA};
|
||||
|
||||
public SyncedMessageObserver(Handler handler) {
|
||||
super(handler);
|
||||
|
@ -161,7 +161,6 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
|
||||
case Tags.EMAIL_BODY:
|
||||
String text = getValue();
|
||||
msg.mText = text;
|
||||
msg.mTextInfo = "X;X;8;" + text.length(); // location;encoding;charset;size
|
||||
break;
|
||||
default:
|
||||
skipTag();
|
||||
@ -191,9 +190,6 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
|
||||
skipTag();
|
||||
}
|
||||
}
|
||||
|
||||
// Tell the provider that this is synced back
|
||||
msg.mServerVersion = mMailbox.mSyncKey;
|
||||
emails.add(msg);
|
||||
}
|
||||
|
||||
@ -228,12 +224,9 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
|
||||
}
|
||||
}
|
||||
// We always ask for TEXT or HTML; there's no third option
|
||||
String info = "X;X;8;" + body.length();
|
||||
if (bodyType.equals(Eas.BODY_PREFERENCE_HTML)) {
|
||||
msg.mHtmlInfo = info;
|
||||
msg.mHtml = body;
|
||||
} else {
|
||||
msg.mTextInfo = info;
|
||||
msg.mText = body;
|
||||
}
|
||||
}
|
||||
@ -419,11 +412,11 @@ public class EmailSyncAdapter extends AbstractSyncAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void responsesParser() throws IOException {
|
||||
public void responsesParser() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() throws IOException {
|
||||
public void commit() {
|
||||
int notifyCount = 0;
|
||||
|
||||
// Use a batch operation to handle the changes
|
||||
|
@ -102,38 +102,31 @@ public class ProviderTestUtils extends Assert {
|
||||
message.mDisplayName = name;
|
||||
message.mTimeStamp = 1;
|
||||
message.mSubject = "subject " + name;
|
||||
message.mPreview = "preview " + name;
|
||||
message.mFlagRead = true;
|
||||
message.mFlagLoaded = Message.NOT_LOADED;
|
||||
message.mFlagFavorite = true;
|
||||
message.mFlagAttachment = true;
|
||||
message.mFlags = 2;
|
||||
|
||||
message.mTextInfo = "textinfo " + name;
|
||||
message.mHtmlInfo = "htmlinfo " + name;
|
||||
|
||||
message.mServerId = "serverid " + name;
|
||||
message.mServerIntId = 0;
|
||||
message.mClientId = "clientid " + name;
|
||||
message.mMessageId = "messageid " + name;
|
||||
message.mThreadId = "threadid " + name;
|
||||
|
||||
message.mMailboxKey = mailboxId;
|
||||
message.mAccountKey = accountId;
|
||||
message.mReferenceKey = 4;
|
||||
|
||||
message.mSender = "sender " + name;
|
||||
message.mFrom = "from " + name;
|
||||
message.mTo = "to " + name;
|
||||
message.mCc = "cc " + name;
|
||||
message.mBcc = "bcc " + name;
|
||||
message.mReplyTo = "replyto " + name;
|
||||
|
||||
message.mServerVersion = "serverversion " + name;
|
||||
|
||||
if (addBody) {
|
||||
message.mText = "body text " + name;
|
||||
message.mHtml = "body html " + name;
|
||||
message.mTextReply = "reply text " + name;
|
||||
message.mHtmlReply = "reply html " + name;
|
||||
}
|
||||
|
||||
if (saveIt) {
|
||||
@ -252,37 +245,30 @@ public class ProviderTestUtils extends Assert {
|
||||
assertEquals(caller + " mDisplayName", expect.mDisplayName, actual.mDisplayName);
|
||||
assertEquals(caller + " mTimeStamp", expect.mTimeStamp, actual.mTimeStamp);
|
||||
assertEquals(caller + " mSubject", expect.mSubject, actual.mSubject);
|
||||
assertEquals(caller + " mPreview", expect.mPreview, actual.mPreview);
|
||||
assertEquals(caller + " mFlagRead = false", expect.mFlagRead, actual.mFlagRead);
|
||||
assertEquals(caller + " mFlagLoaded", expect.mFlagLoaded, actual.mFlagLoaded);
|
||||
assertEquals(caller + " mFlagFavorite", expect.mFlagFavorite, actual.mFlagFavorite);
|
||||
assertEquals(caller + " mFlagAttachment", expect.mFlagAttachment, actual.mFlagAttachment);
|
||||
assertEquals(caller + " mFlags", expect.mFlags, actual.mFlags);
|
||||
|
||||
assertEquals(caller + " mTextInfo", expect.mTextInfo, actual.mTextInfo);
|
||||
assertEquals(caller + " mHtmlInfo", expect.mHtmlInfo, actual.mHtmlInfo);
|
||||
|
||||
assertEquals(caller + " mServerId", expect.mServerId, actual.mServerId);
|
||||
assertEquals(caller + " mServerIntId", expect.mServerIntId, actual.mServerIntId);
|
||||
assertEquals(caller + " mClientId", expect.mClientId, actual.mClientId);
|
||||
assertEquals(caller + " mMessageId", expect.mMessageId, actual.mMessageId);
|
||||
assertEquals(caller + " mThreadId", expect.mThreadId, actual.mThreadId);
|
||||
|
||||
assertEquals(caller + " mMailboxKey", expect.mMailboxKey, actual.mMailboxKey);
|
||||
assertEquals(caller + " mAccountKey", expect.mAccountKey, actual.mAccountKey);
|
||||
assertEquals(caller + " mReferenceKey", expect.mReferenceKey, actual.mReferenceKey);
|
||||
|
||||
assertEquals(caller + " mSender", expect.mSender, actual.mSender);
|
||||
assertEquals(caller + " mFrom", expect.mFrom, actual.mFrom);
|
||||
assertEquals(caller + " mTo", expect.mTo, actual.mTo);
|
||||
assertEquals(caller + " mCc", expect.mCc, actual.mCc);
|
||||
assertEquals(caller + " mBcc", expect.mBcc, actual.mBcc);
|
||||
assertEquals(caller + " mReplyTo", expect.mReplyTo, actual.mReplyTo);
|
||||
|
||||
assertEquals(caller + " mServerVersion", expect.mServerVersion, actual.mServerVersion);
|
||||
|
||||
assertEquals(caller + " mText", expect.mText, actual.mText);
|
||||
assertEquals(caller + " mHtml", expect.mHtml, actual.mHtml);
|
||||
assertEquals(caller + " mTextReply", expect.mTextReply, actual.mTextReply);
|
||||
assertEquals(caller + " mHtmlReply", expect.mHtmlReply, actual.mHtmlReply);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,8 +197,12 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
long message2Id = message2.mId;
|
||||
String text2 = message2.mText;
|
||||
String html2 = message2.mHtml;
|
||||
String textReply2 = message2.mTextReply;
|
||||
String htmlReply2 = message2.mHtmlReply;
|
||||
message2.mText = null;
|
||||
message2.mHtml = null;
|
||||
message2.mTextReply = null;
|
||||
message2.mHtmlReply = null;
|
||||
Message message2get = EmailContent.Message.restoreMessageWithId(mMockContext, message2Id);
|
||||
ProviderTestUtils.assertMessageEqual("testMessageSave", message2, message2get);
|
||||
|
||||
@ -206,6 +210,8 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
Body body2 = loadBodyForMessageId(message2Id);
|
||||
assertEquals("body text", text2, body2.mTextContent);
|
||||
assertEquals("body html", html2, body2.mHtmlContent);
|
||||
assertEquals("reply text", textReply2, body2.mTextReply);
|
||||
assertEquals("reply html", htmlReply2, body2.mHtmlReply);
|
||||
|
||||
// Message with attachments and body
|
||||
Message message3 = ProviderTestUtils.setupMessage("message3", account1Id, box1Id, true,
|
||||
@ -386,9 +392,15 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
long box1Id = box1.mId;
|
||||
|
||||
final String textContent = "foobar some odd text";
|
||||
final String htmlContent = "and some html";
|
||||
final String textReply = "plain text reply";
|
||||
final String htmlReply = "or the html reply";
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(BodyColumns.TEXT_CONTENT, textContent);
|
||||
values.put(BodyColumns.HTML_CONTENT, htmlContent);
|
||||
values.put(BodyColumns.TEXT_REPLY, textReply);
|
||||
values.put(BodyColumns.HTML_REPLY, htmlReply);
|
||||
|
||||
// 1
|
||||
Message message1 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, false,
|
||||
@ -400,6 +412,9 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
body1 = loadBodyForMessageId(message1Id);
|
||||
assertNotNull(body1);
|
||||
assertEquals(body1.mTextContent, textContent);
|
||||
assertEquals(body1.mHtmlContent, htmlContent);
|
||||
assertEquals(body1.mTextReply, textReply);
|
||||
assertEquals(body1.mHtmlReply, htmlReply);
|
||||
|
||||
// 2
|
||||
Message message2 = ProviderTestUtils.setupMessage("message1", account1Id, box1Id, true,
|
||||
@ -412,6 +427,9 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
|
||||
body2 = loadBodyForMessageId(message1Id);
|
||||
assertNotNull(body2);
|
||||
assertEquals(body2.mTextContent, textContent);
|
||||
assertEquals(body2.mHtmlContent, htmlContent);
|
||||
assertEquals(body2.mTextReply, textReply);
|
||||
assertEquals(body2.mHtmlReply, htmlReply);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,12 +25,13 @@ import java.util.HashMap;
|
||||
public class TagsTests extends AndroidTestCase {
|
||||
|
||||
// Make sure there are no duplicates in the tags table
|
||||
public void testNoDuplicates() {
|
||||
// This test is no longer required - tags can be duplicated
|
||||
public void disable_testNoDuplicates() {
|
||||
String[][] allTags = Tags.pages;
|
||||
HashMap<String, Boolean> map = new HashMap<String, Boolean>();
|
||||
for (String[] page: allTags) {
|
||||
for (String tag: page) {
|
||||
assertTrue(!map.containsKey(tag));
|
||||
assertTrue(tag, !map.containsKey(tag));
|
||||
map.put(tag, true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user