From 1575e7860d2259f1aed201ab23d526cddf787365 Mon Sep 17 00:00:00 2001 From: Mihai Preda Date: Mon, 15 Feb 2010 14:56:40 +0100 Subject: [PATCH] MessageCompose: fix delete quoted on reply/forward for EAS. Also fix display of quoted html text for a draft (Exchange 2007). Bug 2363249 Bug 2444496 --- .../android/email/activity/MessageCompose.java | 7 +++++-- .../android/email/provider/EmailContent.java | 18 ++++++++++++++++++ .../android/email/provider/ProviderTests.java | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/com/android/email/activity/MessageCompose.java b/src/com/android/email/activity/MessageCompose.java index f78a51368..7ccd9df9f 100644 --- a/src/com/android/email/activity/MessageCompose.java +++ b/src/com/android/email/activity/MessageCompose.java @@ -577,6 +577,8 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus Body.restoreReplyTextWithMessageId(MessageCompose.this, message.mId); message.mIntroText = Body.restoreIntroTextWithMessageId(MessageCompose.this, message.mId); + message.mSourceKey = Body.restoreBodySourceKey(MessageCompose.this, + message.mId); } else { message.mHtmlReply = null; message.mTextReply = null; @@ -759,8 +761,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus || ACTION_FORWARD.equals(mAction)) { message.mSourceKey = mSource.mId; // Get the body of the source message here - // Note that the following commented line will be useful when we use HTML in replies - //message.mHtmlReply = mSource.mHtml; + message.mHtmlReply = mSource.mHtml; message.mTextReply = mSource.mText; } @@ -842,6 +843,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus values.put(BodyColumns.TEXT_REPLY, mDraft.mTextReply); values.put(BodyColumns.HTML_REPLY, mDraft.mHtmlReply); values.put(BodyColumns.INTRO_TEXT, mDraft.mIntroText); + values.put(BodyColumns.SOURCE_MESSAGE_KEY, mDraft.mSourceKey); Body.updateBodyWithMessageId(MessageCompose.this, mDraft.mId, values); } else { // mDraft.mId is set upon return of saveToMailbox() @@ -1031,6 +1033,7 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus mDraft.mIntroText = null; mDraft.mTextReply = null; mDraft.mHtmlReply = null; + mDraft.mSourceKey = 0; setDraftNeedsSaving(true); break; } diff --git a/src/com/android/email/provider/EmailContent.java b/src/com/android/email/provider/EmailContent.java index a6dc08c57..39fb190b9 100644 --- a/src/com/android/email/provider/EmailContent.java +++ b/src/com/android/email/provider/EmailContent.java @@ -228,6 +228,9 @@ public abstract class EmailContent { }; public static final int COMMON_PROJECTION_COLUMN_TEXT = 1; + private static final String[] PROJECTION_SOURCE_KEY = + new String[] { BodyColumns.SOURCE_MESSAGE_KEY }; + public long mMessageKey; public String mHtmlContent; public String mTextContent; @@ -313,6 +316,21 @@ public abstract class EmailContent { } } + public static long restoreBodySourceKey(Context context, long messageId) { + Cursor c = context.getContentResolver().query(Body.CONTENT_URI, + Body.PROJECTION_SOURCE_KEY, + Body.MESSAGE_KEY + "=?", new String[] {Long.toString(messageId)}, null); + try { + if (c.moveToFirst()) { + return c.getLong(0); + } else { + return 0; + } + } finally { + c.close(); + } + } + private static String restoreTextWithMessageId(Context context, long messageId, String[] projection) { Cursor c = context.getContentResolver().query(Body.CONTENT_URI, projection, diff --git a/tests/src/com/android/email/provider/ProviderTests.java b/tests/src/com/android/email/provider/ProviderTests.java index ee5850a83..a4001f3ec 100644 --- a/tests/src/com/android/email/provider/ProviderTests.java +++ b/tests/src/com/android/email/provider/ProviderTests.java @@ -605,6 +605,8 @@ public class ProviderTests extends ProviderTestCase2 { Body.restoreReplyHtmlWithMessageId(mMockContext, messageId)); assertEquals(message1.mIntroText, Body.restoreIntroTextWithMessageId(mMockContext, messageId)); + assertEquals(message1.mSourceKey, + Body.restoreBodySourceKey(mMockContext, messageId)); } /**