Remove the bodyId column in the message base for consistency

Foreign keys belong in the child, not the parent, as is done with other
EmailContent classes.  Therefore, Body has a messageKey, and Message has
no bodyKey.

Updated MessageView to use the proper query for retrieving a message body.
This commit is contained in:
Marc Blank 2009-06-21 16:37:35 -05:00
parent 07871c4ce7
commit 33e176f491
3 changed files with 26 additions and 30 deletions

View File

@ -985,13 +985,13 @@ public class MessageView extends Activity
*/
private class LoadBodyTask extends AsyncTask<Void, Void, Cursor> {
private long mBodyId;
private long mMessageId;
/**
* Special constructor to cache some local info
*/
public LoadBodyTask(long bodyId) {
mBodyId = bodyId;
public LoadBodyTask(long messageId) {
mMessageId = messageId;
}
@Override
@ -999,9 +999,9 @@ public class MessageView extends Activity
return MessageView.this.managedQuery(
EmailContent.Body.CONTENT_URI,
BODY_CONTENT_PROJECTION,
EmailContent.RECORD_ID + "=?",
EmailContent.Body.MESSAGE_KEY + "=?",
new String[] {
String.valueOf(mBodyId)
String.valueOf(mMessageId)
},
null);
}
@ -1042,7 +1042,7 @@ public class MessageView extends Activity
mAttachmentIcon.setVisibility(message.mAttachments != null ? View.VISIBLE : View.GONE);
// Ask for body
mLoadBodyTask = new LoadBodyTask(message.mBodyKey);
mLoadBodyTask = new LoadBodyTask(message.mId);
mLoadBodyTask.execute();
}

View File

@ -327,8 +327,6 @@ public abstract class EmailContent {
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";
// Foreign key to the Body content of this message (text and/or html)
public static final String BODY_ID = "bodyId";
// Sync related identifiers
// Any client-required identifier
@ -371,27 +369,26 @@ public abstract class EmailContent {
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_BODY_ID_COLUMN = 12;
public static final int CONTENT_SERVER_ID_COLUMN = 13;
public static final int CONTENT_CLIENT_ID_COLUMN = 14;
public static final int CONTENT_MESSAGE_ID_COLUMN = 15;
public static final int CONTENT_THREAD_ID_COLUMN = 16;
public static final int CONTENT_MAILBOX_KEY_COLUMN = 17;
public static final int CONTENT_ACCOUNT_KEY_COLUMN = 18;
public static final int CONTENT_REFERENCE_KEY_COLUMN = 19;
public static final int CONTENT_SENDER_LIST_COLUMN = 20;
public static final int CONTENT_FROM_LIST_COLUMN = 21;
public static final int CONTENT_TO_LIST_COLUMN = 22;
public static final int CONTENT_CC_LIST_COLUMN = 23;
public static final int CONTENT_BCC_LIST_COLUMN = 24;
public static final int CONTENT_REPLY_TO_COLUMN = 25;
public static final int CONTENT_SERVER_VERSION_COLUMN = 26;
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 String[] CONTENT_PROJECTION = new String[] {
RECORD_ID, MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
MessageColumns.SUBJECT, MessageColumns.PREVIEW, MessageColumns.FLAG_READ,
MessageColumns.FLAG_LOADED, MessageColumns.FLAG_FAVORITE,
MessageColumns.FLAG_ATTACHMENT, MessageColumns.FLAGS, MessageColumns.TEXT_INFO,
MessageColumns.HTML_INFO, MessageColumns.BODY_ID, SyncColumns.SERVER_ID,
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,
@ -458,7 +455,6 @@ public abstract class EmailContent {
public String mMessageId;
public String mThreadId;
public long mBodyKey;
public long mMailboxKey;
public long mAccountKey;
public long mReferenceKey;
@ -528,7 +524,6 @@ public abstract class EmailContent {
values.put(MessageColumns.CLIENT_ID, mClientId);
values.put(MessageColumns.MESSAGE_ID, mMessageId);
values.put(MessageColumns.BODY_ID, mBodyKey);
values.put(MessageColumns.MAILBOX_KEY, mMailboxKey);
values.put(MessageColumns.ACCOUNT_KEY, mAccountKey);
values.put(MessageColumns.REFERENCE_KEY, mReferenceKey);
@ -581,7 +576,6 @@ public abstract class EmailContent {
mClientId = c.getString(CONTENT_CLIENT_ID_COLUMN);
mMessageId = c.getString(CONTENT_MESSAGE_ID_COLUMN);
mThreadId = c.getString(CONTENT_THREAD_ID_COLUMN);
mBodyKey = c.getLong(CONTENT_BODY_ID_COLUMN);
mMailboxKey = c.getLong(CONTENT_MAILBOX_KEY_COLUMN);
mAccountKey = c.getLong(CONTENT_ACCOUNT_KEY_COLUMN);
mReferenceKey = c.getLong(CONTENT_REFERENCE_KEY_COLUMN);

View File

@ -64,7 +64,7 @@ public class EmailProvider extends ContentProvider {
// In these early versions, updating the database version will cause all tables to be deleted
// Obviously, we'll handle upgrades differently once things are a bit stable
public static final int DATABASE_VERSION = 12;
public static final int DATABASE_VERSION = 13;
public static final int BODY_DATABASE_VERSION = 1;
public static final String EMAIL_AUTHORITY = "com.android.email.provider";
@ -103,7 +103,8 @@ public class EmailProvider extends ContentProvider {
private static final int BODY_BASE = 0x6000;
private static final int BODY = BODY_BASE;
private static final int BODY_ID = BODY_BASE + 1;
private static final int BODY_HTML = BODY_BASE + 2;
private static final int BODY_MESSAGE_ID = BODY_BASE + 2;
private static final int BODY_HTML = BODY_BASE + 3;
private static final int BODY_TEXT = BODY_BASE + 4;
@ -163,6 +164,8 @@ public class EmailProvider extends ContentProvider {
matcher.addURI(EMAIL_AUTHORITY, "body", BODY);
// A specific mail body
matcher.addURI(EMAIL_AUTHORITY, "body/#", BODY_ID);
// The body for a specific message
matcher.addURI(EMAIL_AUTHORITY, "body/message/#", BODY_MESSAGE_ID);
// The HTML part of a specific mail body
matcher.addURI(EMAIL_AUTHORITY, "body/#/html", BODY_HTML);
// The plain text part of a specific mail body
@ -196,7 +199,6 @@ public class EmailProvider extends ContentProvider {
+ MessageColumns.CLIENT_ID + " integer, "
+ MessageColumns.MESSAGE_ID + " text, "
+ MessageColumns.THREAD_ID + " text, "
+ MessageColumns.BODY_ID + " integer, "
+ MessageColumns.MAILBOX_KEY + " integer, "
+ MessageColumns.ACCOUNT_KEY + " integer, "
+ MessageColumns.REFERENCE_KEY + " integer, "