Merge all cases of getting email address from a raw string.
Use the Rfc822Tokenizer in Address.java instead of pattern
matchers.
Change-Id: I7c99e5bbb5ebdc57a480ea112d1c9fc460ed2303
diff --git a/src/com/android/email/compose/ComposeActivity.java b/src/com/android/email/compose/ComposeActivity.java
index 0c7c948..2568435 100644
--- a/src/com/android/email/compose/ComposeActivity.java
+++ b/src/com/android/email/compose/ComposeActivity.java
@@ -479,7 +479,7 @@
private void initReplyRecipients(String account, Cursor refMessage, int action) {
// This is the email address of the current user, i.e. the one composing
// the reply.
- final String accountEmail = Utils.getEmailFromAddressString(account);
+ final String accountEmail = Address.getEmailAddress(account).getAddress();
String fromAddress = refMessage.getString(UIProvider.MESSAGE_FROM_COLUMN);
String[] sentToAddresses = Utils.splitCommaSeparatedString(refMessage
.getString(UIProvider.MESSAGE_TO_COLUMN));
@@ -595,7 +595,8 @@
// it's the To recipient list of the original message.
// OR missing, in which case use the sender of the original message
Set<String> toAddresses = Sets.newHashSet();
- if (Utils.getEmailFromAddressString(senderAddress).equalsIgnoreCase(account)) {
+ Address sender = Address.getEmailAddress(senderAddress);
+ if (sender != null && sender.getAddress().equalsIgnoreCase(account)) {
// The sender address is this account, so reply acts like reply all.
toAddresses.addAll(Arrays.asList(inToAddresses));
} else if (replyToAddresses != null && replyToAddresses.length != 0) {
@@ -603,9 +604,8 @@
} else {
// Check to see if the sender address is one of the user's custom
// from addresses.
- if (senderAddress != null
- && !accountEmail.equalsIgnoreCase(Utils
- .getEmailFromAddressString(senderAddress))) {
+ if (senderAddress != null && sender != null
+ && !accountEmail.equalsIgnoreCase(sender.getAddress())) {
// Replying to the sender of the original message is the most
// common case.
toAddresses.add(senderAddress);
@@ -624,7 +624,7 @@
for (String email : addresses) {
// Do not add this account, or any of the custom froms, to the list
// of recipients.
- final String recipientAddress = Utils.getEmailFromAddressString(email);
+ final String recipientAddress = Address.getEmailAddress(email).getAddress();
if (!account.equalsIgnoreCase(recipientAddress)) {
recipients.add(email.replace("\"\"", ""));
}