Merge "DO NOT MERGE: Send intro text with SmartForward" into gingerbread
This commit is contained in:
commit
ef70c9872b
@ -70,17 +70,16 @@ public class Rfc822Output {
|
||||
int flags = message.mFlags;
|
||||
boolean isReply = (flags & Message.FLAG_TYPE_REPLY) != 0;
|
||||
boolean isForward = (flags & Message.FLAG_TYPE_FORWARD) != 0;
|
||||
// For all forwards/replies, we add the intro text
|
||||
if (isReply || isForward) {
|
||||
String intro = body.mIntroText == null ? "" : body.mIntroText;
|
||||
text += intro;
|
||||
}
|
||||
if (!appendQuotedText) {
|
||||
// appendQuotedText is set to false for use by SmartReply/SmartForward in EAS.
|
||||
// SmartReply doesn't appear to work properly, so we will still add the header into
|
||||
// the original message.
|
||||
// SmartForward doesn't put any kind of break between the original and the new text,
|
||||
// so we add a CRLF
|
||||
if (isReply) {
|
||||
text += intro;
|
||||
} else if (isForward) {
|
||||
text += "\r\n";
|
||||
// SmartForward doesn't put a break between the original and new text, so we add an LF
|
||||
if (isForward) {
|
||||
text += "\n";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
@ -92,13 +91,11 @@ public class Rfc822Output {
|
||||
quotedText = matcher.replaceAll("\n");
|
||||
}
|
||||
if (isReply) {
|
||||
text += intro;
|
||||
if (quotedText != null) {
|
||||
Matcher matcher = PATTERN_START_OF_LINE.matcher(quotedText);
|
||||
text += matcher.replaceAll(">");
|
||||
}
|
||||
} else if (isForward) {
|
||||
text += intro;
|
||||
if (quotedText != null) {
|
||||
text += quotedText;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.email.mail.transport;
|
||||
|
||||
import com.android.email.R;
|
||||
import com.android.email.mail.MessagingException;
|
||||
import com.android.email.provider.EmailProvider;
|
||||
import com.android.email.provider.EmailContent.Attachment;
|
||||
@ -52,10 +53,11 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
|
||||
private static final String SUBJECT = "This is the subject";
|
||||
private static final String BODY = "This is the body. This is also the body.";
|
||||
private static final String TEXT = "Here is some new text.";
|
||||
private static final String REPLY_BODY_SHORT = "\n\n" + SENDER + " wrote:\n\n";
|
||||
private static final String REPLY_BODY = REPLY_BODY_SHORT + ">" + BODY;
|
||||
|
||||
private Context mMockContext;
|
||||
private String mForwardIntro;
|
||||
private String mReplyIntro;
|
||||
private String mReplyBody;
|
||||
|
||||
public Rfc822OutputTests () {
|
||||
super(EmailProvider.class, EmailProvider.EMAIL_AUTHORITY);
|
||||
@ -65,6 +67,10 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
mMockContext = getMockContext();
|
||||
mForwardIntro = mMockContext.getString(R.string.message_compose_fwd_header_fmt, SUBJECT,
|
||||
SENDER, RECIPIENT_TO, RECIPIENT_CC);
|
||||
mReplyIntro = mMockContext.getString(R.string.message_compose_reply_header_fmt, SENDER);
|
||||
mReplyBody = mReplyIntro + ">" + BODY;
|
||||
}
|
||||
|
||||
// TODO Create more tests here. Specifically, we should test to make sure that forward works
|
||||
@ -73,16 +79,10 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
|
||||
// TODO Write test that ensures that bcc is handled properly (i.e. sent/not send depending
|
||||
// on the flag passed to writeTo
|
||||
|
||||
// TODO Localize the following test, which will not work properly in other than English
|
||||
// speaking locales!
|
||||
|
||||
/**
|
||||
* Test for buildBodyText().
|
||||
* Compare with expected values.
|
||||
* Also test the situation where the message has no body.
|
||||
*
|
||||
* WARNING: This test is NOT localized, so it will fail if run on a device in a
|
||||
* non-English speaking locale!
|
||||
*/
|
||||
public void testBuildBodyTextWithReply() {
|
||||
// Create the least necessary; sender, flags, and the body of the reply
|
||||
@ -91,18 +91,18 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
|
||||
msg.mFrom = SENDER;
|
||||
msg.mFlags = Message.FLAG_TYPE_REPLY;
|
||||
msg.mTextReply = BODY;
|
||||
msg.mIntroText = REPLY_BODY_SHORT;
|
||||
msg.mIntroText = mReplyIntro;
|
||||
msg.save(mMockContext);
|
||||
|
||||
String body = Rfc822Output.buildBodyText(mMockContext, msg, true);
|
||||
assertEquals(REPLY_BODY, body);
|
||||
assertEquals(mReplyBody, body);
|
||||
|
||||
// Save a different message with no reply body (so we reset the id)
|
||||
msg.mId = -1;
|
||||
msg.mTextReply = null;
|
||||
msg.save(mMockContext);
|
||||
body = Rfc822Output.buildBodyText(mMockContext, msg, true);
|
||||
assertEquals(REPLY_BODY_SHORT, body);
|
||||
assertEquals(mReplyIntro, body);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,18 +117,37 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
|
||||
msg.mFrom = SENDER;
|
||||
msg.mFlags = Message.FLAG_TYPE_REPLY;
|
||||
msg.mTextReply = BODY;
|
||||
msg.mIntroText = REPLY_BODY_SHORT;
|
||||
msg.mIntroText = mReplyIntro;
|
||||
msg.save(mMockContext);
|
||||
|
||||
String body = Rfc822Output.buildBodyText(mMockContext, msg, false);
|
||||
assertEquals(TEXT + REPLY_BODY_SHORT, body);
|
||||
assertEquals(TEXT + mReplyIntro, body);
|
||||
|
||||
// Save a different message with no reply body (so we reset the id)
|
||||
msg.mId = -1;
|
||||
msg.mTextReply = null;
|
||||
msg.save(mMockContext);
|
||||
body = Rfc822Output.buildBodyText(mMockContext, msg, false);
|
||||
assertEquals(TEXT + REPLY_BODY_SHORT, body);
|
||||
assertEquals(TEXT + mReplyIntro, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for buildBodyText().
|
||||
* Compare with expected values.
|
||||
*/
|
||||
public void testBuildBodyTextWithForward() {
|
||||
Message msg = new Message();
|
||||
msg.mText = TEXT;
|
||||
msg.mFrom = SENDER;
|
||||
msg.mTo = RECIPIENT_TO;
|
||||
msg.mCc = RECIPIENT_CC;
|
||||
msg.mSubject = SUBJECT;
|
||||
msg.mFlags = Message.FLAG_TYPE_FORWARD;
|
||||
msg.mTextReply = BODY;
|
||||
msg.mIntroText = mForwardIntro;
|
||||
msg.save(mMockContext);
|
||||
String body = Rfc822Output.buildBodyText(mMockContext, msg, true);
|
||||
assertEquals(TEXT + mForwardIntro + BODY, body);
|
||||
}
|
||||
|
||||
public void testWriteToText() throws IOException, MessagingException {
|
||||
@ -201,6 +220,7 @@ public class Rfc822OutputTests extends ProviderTestCase2<EmailProvider> {
|
||||
assertNull(header.getField("content-disposition"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testWriteToMixedPart() throws IOException, MessagingException {
|
||||
// Create a message with a mixed part
|
||||
Message msg = new Message();
|
||||
|
Loading…
Reference in New Issue
Block a user