From c6f104f2a7eb7d8f196360a2aa96a863fcfc12db Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Fri, 27 Apr 2012 13:09:02 -0700 Subject: [PATCH] Add quoted text start pos to Body table Change-Id: Ie80fbb686382a8d38ea09d05b4757a82169be3fc --- .../emailcommon/internet/Rfc822Output.java | 16 +++++++-------- .../emailcommon/provider/EmailContent.java | 12 ++++++++++- .../com/android/email/provider/DBHelper.java | 20 ++++++++++++++++--- .../android/email/provider/EmailProvider.java | 1 + 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/email2/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java b/email2/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java index e03a92694..51a62fd1b 100644 --- a/email2/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java +++ b/email2/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java @@ -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; diff --git a/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java b/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java index 9265de7a0..a0a6e48cf 100755 --- a/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java +++ b/email2/emailcommon/src/com/android/emailcommon/provider/EmailContent.java @@ -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 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) { diff --git a/email2/src/com/android/email/provider/DBHelper.java b/email2/src/com/android/email/provider/DBHelper.java index 796086ba7..727f6c37f 100644 --- a/email2/src/com/android/email/provider/DBHelper.java +++ b/email2/src/com/android/email/provider/DBHelper.java @@ -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 { diff --git a/email2/src/com/android/email/provider/EmailProvider.java b/email2/src/com/android/email/provider/EmailProvider.java index 69c0f59df..d6d1ac384 100644 --- a/email2/src/com/android/email/provider/EmailProvider.java +++ b/email2/src/com/android/email/provider/EmailProvider.java @@ -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) {