Merge "Fix behavior if replying to own sent message"
This commit is contained in:
commit
f1d9367909
@ -1068,6 +1068,16 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addAddresses(MultiAutoCompleteTextView view, String addresses) {
|
||||||
|
if (addresses == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Address[] unpackedAddresses = Address.unpack(addresses);
|
||||||
|
for (Address address : unpackedAddresses) {
|
||||||
|
addAddress(view, address.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void addAddress(MultiAutoCompleteTextView view, String address) {
|
private static void addAddress(MultiAutoCompleteTextView view, String address) {
|
||||||
view.append(address + ", ");
|
view.append(address + ", ");
|
||||||
}
|
}
|
||||||
@ -2027,26 +2037,39 @@ public class MessageCompose extends Activity implements OnClickListener, OnFocus
|
|||||||
// Start clean.
|
// Start clean.
|
||||||
clearAddressViews();
|
clearAddressViews();
|
||||||
|
|
||||||
/*
|
// If Reply-to: addresses are included, use those; otherwise, use the From: address.
|
||||||
* If a reply-to was included with the message use that, otherwise use the from
|
|
||||||
* or sender address.
|
|
||||||
*/
|
|
||||||
Address[] replyToAddresses = Address.unpack(message.mReplyTo);
|
Address[] replyToAddresses = Address.unpack(message.mReplyTo);
|
||||||
if (replyToAddresses.length == 0) {
|
if (replyToAddresses.length == 0) {
|
||||||
replyToAddresses = Address.unpack(message.mFrom);
|
replyToAddresses = Address.unpack(message.mFrom);
|
||||||
}
|
}
|
||||||
addAddresses(mToView, replyToAddresses);
|
|
||||||
|
// Check if ourAddress is one of the replyToAddresses to decide how to populate To: field
|
||||||
|
String ourAddress = account.mEmailAddress;
|
||||||
|
boolean containsOurAddress = false;
|
||||||
|
for (Address address : replyToAddresses) {
|
||||||
|
if (ourAddress.equalsIgnoreCase(address.getAddress())) {
|
||||||
|
containsOurAddress = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (containsOurAddress) {
|
||||||
|
addAddresses(mToView, message.mTo);
|
||||||
|
} else {
|
||||||
|
addAddresses(mToView, replyToAddresses);
|
||||||
|
}
|
||||||
|
|
||||||
if (replyAll) {
|
if (replyAll) {
|
||||||
// Keep a running list of addresses we're sending to
|
// Keep a running list of addresses we're sending to
|
||||||
ArrayList<Address> allAddresses = new ArrayList<Address>();
|
ArrayList<Address> allAddresses = new ArrayList<Address>();
|
||||||
String ourAddress = account.mEmailAddress;
|
|
||||||
|
|
||||||
for (Address address: replyToAddresses) {
|
for (Address address: replyToAddresses) {
|
||||||
allAddresses.add(address);
|
allAddresses.add(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
safeAddAddresses(message.mTo, ourAddress, mCcView, allAddresses);
|
if (!containsOurAddress) {
|
||||||
|
safeAddAddresses(message.mTo, ourAddress, mCcView, allAddresses);
|
||||||
|
}
|
||||||
|
|
||||||
safeAddAddresses(message.mCc, ourAddress, mCcView, allAddresses);
|
safeAddAddresses(message.mCc, ourAddress, mCcView, allAddresses);
|
||||||
}
|
}
|
||||||
showCcBccFieldsIfFilled();
|
showCcBccFieldsIfFilled();
|
||||||
|
@ -66,6 +66,7 @@ public class MessageComposeTests
|
|||||||
private long mCreatedAccountId = -1;
|
private long mCreatedAccountId = -1;
|
||||||
private String mSignature;
|
private String mSignature;
|
||||||
|
|
||||||
|
private static final String ACCOUNT = "account@android.com";
|
||||||
private static final String SENDER = "sender@android.com";
|
private static final String SENDER = "sender@android.com";
|
||||||
private static final String REPLYTO = "replyto@android.com";
|
private static final String REPLYTO = "replyto@android.com";
|
||||||
private static final String RECIPIENT_TO = "recipient-to@android.com";
|
private static final String RECIPIENT_TO = "recipient-to@android.com";
|
||||||
@ -190,9 +191,9 @@ public class MessageComposeTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a couple of variations of processSourceMessage() for REPLY
|
* Test a couple of variations of processSourceMessage() for REPLY.
|
||||||
* To = Reply-To or From: (if REPLY)
|
* To = Reply-To or From: (if REPLY)
|
||||||
* To = (Reply-To or From:) + To: + Cc: (if REPLY_ALL)
|
* To = (Reply-To or From:), Cc = + To: + Cc: (if REPLY_ALL)
|
||||||
* Subject = Re: Subject
|
* Subject = Re: Subject
|
||||||
* Body = empty (and has cursor)
|
* Body = empty (and has cursor)
|
||||||
*
|
*
|
||||||
@ -203,10 +204,12 @@ public class MessageComposeTests
|
|||||||
Intent intent = new Intent(ACTION_REPLY);
|
Intent intent = new Intent(ACTION_REPLY);
|
||||||
final MessageCompose a = getActivity();
|
final MessageCompose a = getActivity();
|
||||||
a.setIntent(intent);
|
a.setIntent(intent);
|
||||||
|
final Account account = new Account();
|
||||||
|
account.mEmailAddress = ACCOUNT;
|
||||||
|
|
||||||
runTestOnUiThread(new Runnable() {
|
runTestOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
a.processSourceMessage(message, null);
|
a.processSourceMessage(message, account);
|
||||||
a.setInitialComposeText(null, null);
|
a.setInitialComposeText(null, null);
|
||||||
checkFields(SENDER + ", ", null, null, "Re: " + SUBJECT, null, null);
|
checkFields(SENDER + ", ", null, null, "Re: " + SUBJECT, null, null);
|
||||||
checkFocused(mMessageView);
|
checkFocused(mMessageView);
|
||||||
@ -219,7 +222,7 @@ public class MessageComposeTests
|
|||||||
runTestOnUiThread(new Runnable() {
|
runTestOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
resetViews();
|
resetViews();
|
||||||
a.processSourceMessage(message, null);
|
a.processSourceMessage(message, account);
|
||||||
a.setInitialComposeText(null, null);
|
a.setInitialComposeText(null, null);
|
||||||
checkFields(REPLYTO + ", ", null, null, "Re: " + SUBJECT, null, null);
|
checkFields(REPLYTO + ", ", null, null, "Re: " + SUBJECT, null, null);
|
||||||
checkFocused(mMessageView);
|
checkFocused(mMessageView);
|
||||||
@ -227,12 +230,69 @@ public class MessageComposeTests
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests similar cases as testProcessSourceMessageReply, but when sender is in From: (or
|
||||||
|
* Reply-to: if applicable) field.
|
||||||
|
*
|
||||||
|
* To = To (if REPLY)
|
||||||
|
* To = To, Cc = Cc (if REPLY_ALL)
|
||||||
|
* Subject = Re: Subject
|
||||||
|
* Body = empty (and has cursor)
|
||||||
|
*
|
||||||
|
* @throws MessagingException
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
public void testRepliesWithREplyToFields() throws MessagingException, Throwable {
|
||||||
|
final Message message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY);
|
||||||
|
message.mCc = RECIPIENT_CC;
|
||||||
|
Intent intent = new Intent(ACTION_REPLY);
|
||||||
|
final MessageCompose a = getActivity();
|
||||||
|
a.setIntent(intent);
|
||||||
|
final Account account = new Account();
|
||||||
|
account.mEmailAddress = SENDER;
|
||||||
|
|
||||||
|
runTestOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
a.processSourceMessage(message, account);
|
||||||
|
a.setInitialComposeText(null, null);
|
||||||
|
checkFields(RECIPIENT_TO + ", ", null, null, "Re: " + SUBJECT, null, null);
|
||||||
|
checkFocused(mMessageView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
message.mFrom = null;
|
||||||
|
message.mReplyTo = Address.parseAndPack(SENDER);
|
||||||
|
|
||||||
|
runTestOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
resetViews();
|
||||||
|
a.processSourceMessage(message, account);
|
||||||
|
a.setInitialComposeText(null, null);
|
||||||
|
checkFields(RECIPIENT_TO + ", ", null, null, "Re: " + SUBJECT, null, null);
|
||||||
|
checkFocused(mMessageView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
a.setIntent(new Intent(ACTION_REPLY_ALL));
|
||||||
|
runTestOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
resetViews();
|
||||||
|
a.processSourceMessage(message, account);
|
||||||
|
a.setInitialComposeText(null, null);
|
||||||
|
checkFields(RECIPIENT_TO + ", ", RECIPIENT_CC + ", ", null,
|
||||||
|
"Re: " + SUBJECT, null, null);
|
||||||
|
checkFocused(mMessageView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void testProcessSourceMessageReplyWithSignature() throws MessagingException, Throwable {
|
public void testProcessSourceMessageReplyWithSignature() throws MessagingException, Throwable {
|
||||||
final Message message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY);
|
final Message message = buildTestMessage(RECIPIENT_TO, SENDER, SUBJECT, BODY);
|
||||||
Intent intent = new Intent(ACTION_REPLY);
|
Intent intent = new Intent(ACTION_REPLY);
|
||||||
final MessageCompose a = getActivity();
|
final MessageCompose a = getActivity();
|
||||||
a.setIntent(intent);
|
a.setIntent(intent);
|
||||||
final Account account = new Account();
|
final Account account = new Account();
|
||||||
|
account.mEmailAddress = ACCOUNT;
|
||||||
account.mSignature = SIGNATURE;
|
account.mSignature = SIGNATURE;
|
||||||
runTestOnUiThread(new Runnable() {
|
runTestOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -284,10 +344,12 @@ public class MessageComposeTests
|
|||||||
Intent intent = new Intent(ACTION_REPLY);
|
Intent intent = new Intent(ACTION_REPLY);
|
||||||
final MessageCompose a = getActivity();
|
final MessageCompose a = getActivity();
|
||||||
a.setIntent(intent);
|
a.setIntent(intent);
|
||||||
|
final Account account = new Account();
|
||||||
|
account.mEmailAddress = ACCOUNT;
|
||||||
|
|
||||||
runTestOnUiThread(new Runnable() {
|
runTestOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
a.processSourceMessage(message, null);
|
a.processSourceMessage(message, account);
|
||||||
a.setInitialComposeText(null, null);
|
a.setInitialComposeText(null, null);
|
||||||
checkFields(UTF16_SENDER + ", ", null, null, "Re: " + UTF16_SUBJECT, null, null);
|
checkFields(UTF16_SENDER + ", ", null, null, "Re: " + UTF16_SUBJECT, null, null);
|
||||||
checkFocused(mMessageView);
|
checkFocused(mMessageView);
|
||||||
@ -300,7 +362,7 @@ public class MessageComposeTests
|
|||||||
runTestOnUiThread(new Runnable() {
|
runTestOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
resetViews();
|
resetViews();
|
||||||
a.processSourceMessage(message, null);
|
a.processSourceMessage(message, account);
|
||||||
a.setInitialComposeText(null, null);
|
a.setInitialComposeText(null, null);
|
||||||
checkFields(UTF16_REPLYTO + ", ", null, null, "Re: " + UTF16_SUBJECT, null, null);
|
checkFields(UTF16_REPLYTO + ", ", null, null, "Re: " + UTF16_SUBJECT, null, null);
|
||||||
checkFocused(mMessageView);
|
checkFocused(mMessageView);
|
||||||
@ -317,10 +379,12 @@ public class MessageComposeTests
|
|||||||
Intent intent = new Intent(ACTION_REPLY);
|
Intent intent = new Intent(ACTION_REPLY);
|
||||||
final MessageCompose a = getActivity();
|
final MessageCompose a = getActivity();
|
||||||
a.setIntent(intent);
|
a.setIntent(intent);
|
||||||
|
final Account account = new Account();
|
||||||
|
account.mEmailAddress = ACCOUNT;
|
||||||
|
|
||||||
runTestOnUiThread(new Runnable() {
|
runTestOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
a.processSourceMessage(message, null);
|
a.processSourceMessage(message, account);
|
||||||
a.setInitialComposeText(null, null);
|
a.setInitialComposeText(null, null);
|
||||||
checkFields(UTF32_SENDER + ", ", null, null, "Re: " + UTF32_SUBJECT, null, null);
|
checkFields(UTF32_SENDER + ", ", null, null, "Re: " + UTF32_SUBJECT, null, null);
|
||||||
checkFocused(mMessageView);
|
checkFocused(mMessageView);
|
||||||
@ -333,7 +397,7 @@ public class MessageComposeTests
|
|||||||
runTestOnUiThread(new Runnable() {
|
runTestOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
resetViews();
|
resetViews();
|
||||||
a.processSourceMessage(message, null);
|
a.processSourceMessage(message, account);
|
||||||
a.setInitialComposeText(null, null);
|
a.setInitialComposeText(null, null);
|
||||||
checkFields(UTF32_REPLYTO + ", ", null, null, "Re: " + UTF32_SUBJECT, null, null);
|
checkFields(UTF32_REPLYTO + ", ", null, null, "Re: " + UTF32_SUBJECT, null, null);
|
||||||
checkFocused(mMessageView);
|
checkFocused(mMessageView);
|
||||||
@ -590,8 +654,9 @@ public class MessageComposeTests
|
|||||||
*
|
*
|
||||||
* In this case, we're doing a "reply all"
|
* In this case, we're doing a "reply all"
|
||||||
* The user is CC2 (a "cc" recipient)
|
* The user is CC2 (a "cc" recipient)
|
||||||
* The to should be: FROM, TO1, TO2, and TO3
|
* The to should be: FROM
|
||||||
* The cc should be: CC3 (CC1/CC4 are duplicates; CC2 is the our account's email address)
|
* The cc should be: TO1, TO2, ,TO3, and CC3 (CC1/CC4 are duplicates; CC2 is the our
|
||||||
|
* account's email address)
|
||||||
*/
|
*/
|
||||||
public void testReplyAllAddresses3() throws Throwable {
|
public void testReplyAllAddresses3() throws Throwable {
|
||||||
final MessageCompose a = getActivity();
|
final MessageCompose a = getActivity();
|
||||||
|
Loading…
Reference in New Issue
Block a user