Merge "Add quoted text start pos to Body table" into jb-dev

This commit is contained in:
Marc Blank 2012-04-27 13:54:55 -07:00 committed by Android (Google) Code Review
commit f05dba090c
4 changed files with 37 additions and 12 deletions

View File

@ -16,14 +16,6 @@
package com.android.emailcommon.internet;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.Body;
import com.android.emailcommon.provider.EmailContent.Message;
import org.apache.commons.io.IOUtils;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
@ -33,6 +25,14 @@ import android.text.TextUtils;
import android.util.Base64;
import android.util.Base64OutputStream;
import com.android.emailcommon.mail.Address;
import com.android.emailcommon.mail.MessagingException;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.Body;
import com.android.emailcommon.provider.EmailContent.Message;
import org.apache.commons.io.IOUtils;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;

View File

@ -269,6 +269,8 @@ public abstract class EmailContent {
public static final String SOURCE_MESSAGE_KEY = "sourceMessageKey";
// The text to be placed between a reply/forward response and the original message
public static final String INTRO_TEXT = "introText";
// The start of quoted text within our text content
public static final String QUOTED_TEXT_START_POS = "quotedTextStartPos";
}
public static final class Body extends EmailContent implements BodyColumns {
@ -285,10 +287,12 @@ public abstract class EmailContent {
public static final int CONTENT_TEXT_REPLY_COLUMN = 5;
public static final int CONTENT_SOURCE_KEY_COLUMN = 6;
public static final int CONTENT_INTRO_TEXT_COLUMN = 7;
public static final int CONTENT_QUOTED_TEXT_START_POS_COLUMN = 8;
public static final String[] CONTENT_PROJECTION = new String[] {
RECORD_ID, BodyColumns.MESSAGE_KEY, BodyColumns.HTML_CONTENT, BodyColumns.TEXT_CONTENT,
BodyColumns.HTML_REPLY, BodyColumns.TEXT_REPLY, BodyColumns.SOURCE_MESSAGE_KEY,
BodyColumns.INTRO_TEXT
BodyColumns.INTRO_TEXT, BodyColumns.QUOTED_TEXT_START_POS
};
public static final String[] COMMON_PROJECTION_TEXT = new String[] {
@ -319,6 +323,7 @@ public abstract class EmailContent {
public String mTextContent;
public String mHtmlReply;
public String mTextReply;
public int mQuotedTextStartPos;
/**
* Points to the ID of the message being replied to or forwarded. Will always be set,
@ -462,6 +467,7 @@ public abstract class EmailContent {
mTextReply = cursor.getString(CONTENT_TEXT_REPLY_COLUMN);
mSourceKey = cursor.getLong(CONTENT_SOURCE_KEY_COLUMN);
mIntroText = cursor.getString(CONTENT_INTRO_TEXT_COLUMN);
mQuotedTextStartPos = cursor.getInt(CONTENT_QUOTED_TEXT_START_POS_COLUMN);
}
public boolean update() {
@ -732,6 +738,7 @@ public abstract class EmailContent {
transient public long mSourceKey;
transient public ArrayList<Attachment> mAttachments = null;
transient public String mIntroText;
transient public int mQuotedTextStartPos;
// Values used in mFlagRead
@ -968,6 +975,9 @@ public abstract class EmailContent {
if (mIntroText != null) {
cv.put(Body.INTRO_TEXT, mIntroText);
}
if (mQuotedTextStartPos != 0) {
cv.put(Body.QUOTED_TEXT_START_POS, mQuotedTextStartPos);
}
b = ContentProviderOperation.newInsert(Body.CONTENT_URI);
// Put our message id in the Body
if (!isNew) {

View File

@ -131,7 +131,8 @@ public final class DBHelper {
// Version 4: Database wipe required; changing AccountManager interface w/Exchange
// Version 5: Database wipe required; changing AccountManager interface w/Exchange
// Version 6: Adding Body.mIntroText column
public static final int BODY_DATABASE_VERSION = 6;
// Version 7: Adding quoted text start pos
public static final int BODY_DATABASE_VERSION = 8;
/*
* Internal helper method for index creation.
@ -467,7 +468,8 @@ public final class DBHelper {
+ BodyColumns.HTML_REPLY + " text, "
+ BodyColumns.TEXT_REPLY + " text, "
+ BodyColumns.SOURCE_MESSAGE_KEY + " text, "
+ BodyColumns.INTRO_TEXT + " text"
+ BodyColumns.INTRO_TEXT + " text, "
+ BodyColumns.QUOTED_TEXT_START_POS + " integer"
+ ");";
db.execSQL("create table " + Body.TABLE_NAME + s);
db.execSQL(createIndex(Body.TABLE_NAME, BodyColumns.MESSAGE_KEY));
@ -478,9 +480,11 @@ public final class DBHelper {
try {
db.execSQL("drop table " + Body.TABLE_NAME);
createBodyTable(db);
oldVersion = 5;
} catch (SQLException e) {
}
} else if (oldVersion == 5) {
}
if (oldVersion == 5) {
try {
db.execSQL("alter table " + Body.TABLE_NAME
+ " add " + BodyColumns.INTRO_TEXT + " text");
@ -490,6 +494,16 @@ public final class DBHelper {
}
oldVersion = 6;
}
if (oldVersion == 6 || oldVersion ==7) {
try {
db.execSQL("alter table " + Body.TABLE_NAME
+ " add " + BodyColumns.QUOTED_TEXT_START_POS + " integer");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
Log.w(TAG, "Exception upgrading EmailProviderBody.db from v6 to v8", e);
}
oldVersion = 8;
}
}
protected static class BodyDatabaseHelper extends SQLiteOpenHelper {

View File

@ -3043,6 +3043,7 @@ outer:
msg.mDisplayName = msg.mTo;
msg.mFlagLoaded = Message.FLAG_LOADED_COMPLETE;
msg.mFlagRead = true;
msg.mQuotedTextStartPos = values.getAsInteger(UIProvider.MessageColumns.QUOTE_START_POS);
int flags = 0;
int draftType = values.getAsInteger(UIProvider.MessageColumns.DRAFT_TYPE);
switch(draftType) {