diff --git a/src/com/android/email/activity/MessageView.java b/src/com/android/email/activity/MessageView.java
index 4b862554d..4ebe2dd23 100644
--- a/src/com/android/email/activity/MessageView.java
+++ b/src/com/android/email/activity/MessageView.java
@@ -141,9 +141,6 @@ public class MessageView extends Activity
private String mMessageUid;
private Cursor mMessageListCursor;
- // TODO all uses of this need to be converted to "mMessage". Then mOldMessage goes away.
- private com.android.email.mail.Message mOldMessage;
-
private java.text.DateFormat mDateFormat;
private java.text.DateFormat mTimeFormat;
@@ -479,7 +476,7 @@ public class MessageView extends Activity
super.onResume();
Controller.getInstance(getApplication()).addResultCallback(mControllerCallback);
MessagingController.getInstance(getApplication()).addListener(mListener);
- if (mOldMessage != null) {
+ if (mMessage != null) {
startPresenceCheck();
}
}
@@ -539,29 +536,25 @@ public class MessageView extends Activity
}
private void onClickSender() {
- if (mOldMessage != null) {
- try {
- Address senderEmail = mOldMessage.getFrom()[0];
+ if (mMessage != null) {
+ Address senderEmail = Address.unpackFirst(mMessage.mFrom);
+ if (senderEmail != null) {
Uri contactUri = Uri.fromParts("mailto", senderEmail.getAddress(), null);
-
+
Intent contactIntent = new Intent(Contacts.Intents.SHOW_OR_CREATE_CONTACT);
contactIntent.setData(contactUri);
-
+
// Pass along full E-mail string for possible create dialog
contactIntent.putExtra(Contacts.Intents.EXTRA_CREATE_DESCRIPTION,
- senderEmail.toString());
-
+ senderEmail.toString());
+
// Only provide personal name hint if we have one
String senderPersonal = senderEmail.getPersonal();
if (senderPersonal != null) {
contactIntent.putExtra(Intents.Insert.NAME, senderPersonal);
}
-
+
startActivity(contactIntent);
- } catch (MessagingException me) {
- // this will happen if message has illegal From:, ignore
- } catch (ArrayIndexOutOfBoundsException e) {
- // this will happen if message has no or illegal From:, ignore
}
}
}
@@ -582,21 +575,21 @@ public class MessageView extends Activity
}
private void onReply() {
- if (mOldMessage != null) {
+ if (mMessage != null) {
MessageCompose.actionReply(this, mMessage.mId, false);
finish();
}
}
private void onReplyAll() {
- if (mOldMessage != null) {
+ if (mMessage != null) {
MessageCompose.actionReply(this, mMessage.mId, true);
finish();
}
}
private void onForward() {
- if (mOldMessage != null) {
+ if (mMessage != null) {
MessageCompose.actionForward(this, mMessage.mId);
finish();
}
@@ -687,7 +680,7 @@ public class MessageView extends Activity
}
private void onShowPictures() {
- if (mOldMessage != null) {
+ if (mMessage != null) {
mMessageContentView.getSettings().setBlockNetworkImage(false);
mShowPicturesSection.setVisibility(View.GONE);
}
@@ -910,16 +903,11 @@ public class MessageView extends Activity
*/
private void startPresenceCheck() {
String email = null;
- try {
- if (mOldMessage != null) {
- Address sender = mOldMessage.getFrom()[0];
- email = sender.getAddress();
- }
- } catch (MessagingException me) {
- // this will happen if message has illegal From:, ignore
- } catch (ArrayIndexOutOfBoundsException e) {
- // this will happen if message has no or illegal From:, ignore
+ if (mMessage != null) {
+ Address sender = Address.unpackFirst(mMessage.mFrom);
+ email = sender != null ? sender.getAddress() : null;
}
+
if (email == null) {
mHandler.setSenderPresence(0);
return;
@@ -1265,114 +1253,114 @@ public class MessageView extends Activity
@Override
public void loadMessageForViewHeadersAvailable(Account account, String folder,
String uid, final com.android.email.mail.Message message) {
- MessageView.this.mOldMessage = message;
- try {
- String subjectText = message.getSubject();
- String fromText = Address.toFriendly(message.getFrom());
- Date sentDate = message.getSentDate();
- String timeText = mTimeFormat.format(sentDate);
- String dateText = Utility.isDateToday(sentDate) ? null :
- mDateFormat.format(sentDate);
- String toText = Address.toFriendly(message.getRecipients(RecipientType.TO));
- String ccText = Address.toFriendly(message.getRecipients(RecipientType.CC));
- boolean hasAttachments = ((LocalMessage) message).getAttachmentCount() > 0;
- mHandler.setHeaders(subjectText,
- fromText,
- timeText,
- dateText,
- toText,
- ccText,
- hasAttachments);
- startPresenceCheck();
- }
- catch (MessagingException me) {
- if (Email.LOGD) {
- Log.v(Email.LOG_TAG, "loadMessageForViewHeadersAvailable", me);
- }
- }
+// MessageView.this.mOldMessage = message;
+// try {
+// String subjectText = message.getSubject();
+// String fromText = Address.toFriendly(message.getFrom());
+// Date sentDate = message.getSentDate();
+// String timeText = mTimeFormat.format(sentDate);
+// String dateText = Utility.isDateToday(sentDate) ? null :
+// mDateFormat.format(sentDate);
+// String toText = Address.toFriendly(message.getRecipients(RecipientType.TO));
+// String ccText = Address.toFriendly(message.getRecipients(RecipientType.CC));
+// boolean hasAttachments = ((LocalMessage) message).getAttachmentCount() > 0;
+// mHandler.setHeaders(subjectText,
+// fromText,
+// timeText,
+// dateText,
+// toText,
+// ccText,
+// hasAttachments);
+// startPresenceCheck();
+// }
+// catch (MessagingException me) {
+// if (Email.LOGD) {
+// Log.v(Email.LOG_TAG, "loadMessageForViewHeadersAvailable", me);
+// }
+// }
}
@Override
public void loadMessageForViewBodyAvailable(Account account, String folder,
String uid, com.android.email.mail.Message message) {
- MessageView.this.mOldMessage = message;
- try {
- Part part = MimeUtility.findFirstPartByMimeType(mOldMessage, "text/html");
- if (part == null) {
- part = MimeUtility.findFirstPartByMimeType(mOldMessage, "text/plain");
- }
- if (part != null) {
- String text = MimeUtility.getTextFromPart(part);
- if (part.getMimeType().equalsIgnoreCase("text/html")) {
- text = EmailHtmlUtil.resolveInlineImage(
- getContentResolver(), mAccount.mId, text, mOldMessage, 0);
- } else {
- // And also escape special character, such as "<>&",
- // to HTML escape sequence.
- text = EmailHtmlUtil.escapeCharacterToDisplay(text);
+// MessageView.this.mOldMessage = message;
+// try {
+// Part part = MimeUtility.findFirstPartByMimeType(mOldMessage, "text/html");
+// if (part == null) {
+// part = MimeUtility.findFirstPartByMimeType(mOldMessage, "text/plain");
+// }
+// if (part != null) {
+// String text = MimeUtility.getTextFromPart(part);
+// if (part.getMimeType().equalsIgnoreCase("text/html")) {
+// text = EmailHtmlUtil.resolveInlineImage(
+// getContentResolver(), mAccount.mId, text, mOldMessage, 0);
+// } else {
+// // And also escape special character, such as "<>&",
+// // to HTML escape sequence.
+// text = EmailHtmlUtil.escapeCharacterToDisplay(text);
- /*
- * Linkify the plain text and convert it to HTML by replacing
- * \r?\n with
and adding a html/body wrapper.
- */
- StringBuffer sb = new StringBuffer("