Eliminate redundant methods in Address class
THIS DOES NOT CHANGE ANY EXISTING FUNCTIONALITY. Address.pack() has been removed and all calls replaced with its synonym Address.toHeader(). Address.unpack() has been renamed to Address.fromHeader() to follow the new naming convention. In days of yore, pack() and toHeader() used to do different things. Now they are identical and thus one is superfluous. We have standardized on toHeader() and fromHeader(). Change-Id: Iac91c966eb6c1477f8dba0dd2ae01c84b359e539
This commit is contained in:
parent
7e4daecc9a
commit
1fa303478c
@ -330,7 +330,7 @@ public class Rfc822Output {
|
||||
if (value != null && value.length() > 0) {
|
||||
writer.append(name);
|
||||
writer.append(": ");
|
||||
writer.append(MimeUtility.fold(Address.packedToHeader(value), name.length() + 2));
|
||||
writer.append(MimeUtility.fold(Address.reformatToHeader(value), name.length() + 2));
|
||||
writer.append("\r\n");
|
||||
}
|
||||
}
|
||||
|
@ -135,13 +135,13 @@ public class LegacyConversions {
|
||||
localMessage.mAccountKey = accountId;
|
||||
|
||||
if (from != null && from.length > 0) {
|
||||
localMessage.mFrom = Address.pack(from);
|
||||
localMessage.mFrom = Address.toHeader(from);
|
||||
}
|
||||
|
||||
localMessage.mTo = Address.pack(to);
|
||||
localMessage.mCc = Address.pack(cc);
|
||||
localMessage.mBcc = Address.pack(bcc);
|
||||
localMessage.mReplyTo = Address.pack(replyTo);
|
||||
localMessage.mTo = Address.toHeader(to);
|
||||
localMessage.mCc = Address.toHeader(cc);
|
||||
localMessage.mBcc = Address.toHeader(bcc);
|
||||
localMessage.mReplyTo = Address.toHeader(replyTo);
|
||||
|
||||
// public String mText;
|
||||
// public String mHtml;
|
||||
@ -339,7 +339,7 @@ public class LegacyConversions {
|
||||
|
||||
// LocalFolder.getMessages() equivalent: Copy message fields
|
||||
message.setSubject(localMessage.mSubject == null ? "" : localMessage.mSubject);
|
||||
Address[] from = Address.unpack(localMessage.mFrom);
|
||||
Address[] from = Address.fromHeader(localMessage.mFrom);
|
||||
if (from.length > 0) {
|
||||
message.setFrom(from[0]);
|
||||
}
|
||||
@ -350,10 +350,10 @@ public class LegacyConversions {
|
||||
message.setFlag(Flag.SEEN, localMessage.mFlagRead);
|
||||
message.setFlag(Flag.FLAGGED, localMessage.mFlagFavorite);
|
||||
// message.setFlag(Flag.DRAFT, localMessage.mMailboxKey == draftMailboxKey);
|
||||
message.setRecipients(RecipientType.TO, Address.unpack(localMessage.mTo));
|
||||
message.setRecipients(RecipientType.CC, Address.unpack(localMessage.mCc));
|
||||
message.setRecipients(RecipientType.BCC, Address.unpack(localMessage.mBcc));
|
||||
message.setReplyTo(Address.unpack(localMessage.mReplyTo));
|
||||
message.setRecipients(RecipientType.TO, Address.fromHeader(localMessage.mTo));
|
||||
message.setRecipients(RecipientType.CC, Address.fromHeader(localMessage.mCc));
|
||||
message.setRecipients(RecipientType.BCC, Address.fromHeader(localMessage.mBcc));
|
||||
message.setReplyTo(Address.fromHeader(localMessage.mReplyTo));
|
||||
message.setInternalDate(new Date(localMessage.mServerTimeStamp));
|
||||
message.setMessageId(localMessage.mMessageId);
|
||||
|
||||
|
@ -21,7 +21,6 @@ import android.util.Base64;
|
||||
|
||||
import com.android.email.mail.Sender;
|
||||
import com.android.email.mail.internet.AuthenticationCache;
|
||||
import com.android.email.mail.store.imap.ImapConstants;
|
||||
import com.android.email2.ui.MailActivityEmail;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.internet.Rfc822Output;
|
||||
@ -193,10 +192,10 @@ public class SmtpSender extends Sender {
|
||||
throw new MessagingException("Trying to send non-existent message id="
|
||||
+ Long.toString(messageId));
|
||||
}
|
||||
Address from = Address.unpackFirst(message.mFrom);
|
||||
Address[] to = Address.unpack(message.mTo);
|
||||
Address[] cc = Address.unpack(message.mCc);
|
||||
Address[] bcc = Address.unpack(message.mBcc);
|
||||
Address from = Address.firstAddress(message.mFrom);
|
||||
Address[] to = Address.fromHeader(message.mTo);
|
||||
Address[] cc = Address.fromHeader(message.mCc);
|
||||
Address[] bcc = Address.fromHeader(message.mBcc);
|
||||
|
||||
try {
|
||||
executeSimpleCommand("MAIL FROM:" + "<" + from.getAddress() + ">");
|
||||
|
@ -1645,8 +1645,8 @@ public final class DBHelper {
|
||||
while (messageCursor.moveToNext()) {
|
||||
for (int i = 0; i < ADDRESS_COLUMN_INDICES.length; i++) {
|
||||
Address[] addrs =
|
||||
Address.unpack(messageCursor.getString(ADDRESS_COLUMN_INDICES[i]));
|
||||
cv.put(ADDRESS_COLUMN_NAMES[i], Address.pack(addrs));
|
||||
Address.fromHeader(messageCursor.getString(ADDRESS_COLUMN_INDICES[i]));
|
||||
cv.put(ADDRESS_COLUMN_NAMES[i], Address.toHeader(addrs));
|
||||
}
|
||||
whereArgs[0] = messageCursor.getString(Message.CONTENT_ID_COLUMN);
|
||||
db.update(Message.TABLE_NAME, cv, WHERE_ID, whereArgs);
|
||||
|
@ -2687,7 +2687,7 @@ public class EmailProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
Address[] fromList = Address.unpack(msg.mFrom);
|
||||
Address[] fromList = Address.fromHeader(msg.mFrom);
|
||||
int autoShowImages = 0;
|
||||
final MailPrefs mailPrefs = MailPrefs.get(context);
|
||||
for (Address sender : fromList) {
|
||||
@ -4859,7 +4859,7 @@ public class EmailProvider extends ContentProvider {
|
||||
putIntegerLongOrBoolean(ourValues, MessageColumns.MAILBOX_KEY, mailboxId);
|
||||
}
|
||||
} else if (columnName.equals(UIProvider.MessageColumns.ALWAYS_SHOW_IMAGES)) {
|
||||
Address[] fromList = Address.unpack(message.mFrom);
|
||||
Address[] fromList = Address.fromHeader(message.mFrom);
|
||||
final MailPrefs mailPrefs = MailPrefs.get(getContext());
|
||||
for (Address sender : fromList) {
|
||||
final String email = sender.getAddress();
|
||||
|
@ -504,11 +504,11 @@ public class LegacyConversionsTests extends ProviderTestCase2<EmailProvider> {
|
||||
throws MessagingException {
|
||||
assertEquals(tag, expect.getUid(), actual.mServerId);
|
||||
assertEquals(tag, expect.getSubject(), actual.mSubject);
|
||||
assertEquals(tag, Address.pack(expect.getFrom()), actual.mFrom);
|
||||
assertEquals(tag, Address.toHeader(expect.getFrom()), actual.mFrom);
|
||||
assertEquals(tag, expect.getSentDate().getTime(), actual.mTimeStamp);
|
||||
assertEquals(tag, Address.pack(expect.getRecipients(RecipientType.TO)), actual.mTo);
|
||||
assertEquals(tag, Address.pack(expect.getRecipients(RecipientType.CC)), actual.mCc);
|
||||
assertEquals(tag, ((MimeMessage)expect).getMessageId(), actual.mMessageId);
|
||||
assertEquals(tag, Address.toHeader(expect.getRecipients(RecipientType.TO)), actual.mTo);
|
||||
assertEquals(tag, Address.toHeader(expect.getRecipients(RecipientType.CC)), actual.mCc);
|
||||
assertEquals(tag, expect.getMessageId(), actual.mMessageId);
|
||||
assertEquals(tag, expect.isSet(Flag.SEEN), actual.mFlagRead);
|
||||
assertEquals(tag, expect.isSet(Flag.FLAGGED), actual.mFlagFavorite);
|
||||
}
|
||||
@ -521,13 +521,13 @@ public class LegacyConversionsTests extends ProviderTestCase2<EmailProvider> {
|
||||
assertEquals(tag, expect.mServerId, actual.getUid());
|
||||
assertEquals(tag, expect.mServerTimeStamp, actual.getInternalDate().getTime());
|
||||
assertEquals(tag, expect.mSubject, actual.getSubject());
|
||||
assertEquals(tag, expect.mFrom, Address.pack(actual.getFrom()));
|
||||
assertEquals(tag, expect.mFrom, Address.toHeader(actual.getFrom()));
|
||||
assertEquals(tag, expect.mTimeStamp, actual.getSentDate().getTime());
|
||||
assertEquals(tag, expect.mTo, Address.pack(actual.getRecipients(RecipientType.TO)));
|
||||
assertEquals(tag, expect.mCc, Address.pack(actual.getRecipients(RecipientType.CC)));
|
||||
assertEquals(tag, expect.mBcc, Address.pack(actual.getRecipients(RecipientType.BCC)));
|
||||
assertEquals(tag, expect.mReplyTo, Address.pack(actual.getReplyTo()));
|
||||
assertEquals(tag, expect.mMessageId, ((MimeMessage)actual).getMessageId());
|
||||
assertEquals(tag, expect.mTo, Address.toHeader(actual.getRecipients(RecipientType.TO)));
|
||||
assertEquals(tag, expect.mCc, Address.toHeader(actual.getRecipients(RecipientType.CC)));
|
||||
assertEquals(tag, expect.mBcc, Address.toHeader(actual.getRecipients(RecipientType.BCC)));
|
||||
assertEquals(tag, expect.mReplyTo, Address.toHeader(actual.getReplyTo()));
|
||||
assertEquals(tag, expect.mMessageId, actual.getMessageId());
|
||||
// check flags
|
||||
assertEquals(tag, expect.mFlagRead, actual.isSet(Flag.SEEN));
|
||||
assertEquals(tag, expect.mFlagFavorite, actual.isSet(Flag.FLAGGED));
|
||||
|
@ -166,8 +166,8 @@ public class SmtpSenderUnitTests extends AndroidTestCase {
|
||||
private Message setupSimpleMessage() {
|
||||
Message message = new Message();
|
||||
message.mTimeStamp = System.currentTimeMillis();
|
||||
message.mFrom = Address.parseAndPack("Jones@Registry.Org");
|
||||
message.mTo = Address.parseAndPack("Smith@Registry.Org");
|
||||
message.mFrom = Address.parseToHeader("Jones@Registry.Org");
|
||||
message.mTo = Address.parseToHeader("Smith@Registry.Org");
|
||||
message.mMessageId = "1234567890";
|
||||
return message;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user