mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-15 14:05:05 -05:00
simplify MessageView's setHeaders
This commit is contained in:
parent
8b52aac135
commit
8e2e4e515f
@ -471,22 +471,21 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setHeaders(
|
public void setHeaders(
|
||||||
final String subject,
|
final Message message) throws MessagingException
|
||||||
final CharSequence from,
|
|
||||||
final String date,
|
|
||||||
final String time,
|
|
||||||
final CharSequence to,
|
|
||||||
final CharSequence cc,
|
|
||||||
final int accountColor,
|
|
||||||
final boolean unread,
|
|
||||||
final boolean hasAttachments,
|
|
||||||
final boolean flagged,
|
|
||||||
final boolean answered)
|
|
||||||
{
|
{
|
||||||
|
final Contacts contacts = K9.showContactName() ? mContacts : null;
|
||||||
|
final CharSequence from = Address.toFriendly(message.getFrom(), contacts);
|
||||||
|
final String date = getDateFormat().format(message.getSentDate());
|
||||||
|
final String time = getTimeFormat().format(message.getSentDate());
|
||||||
|
final CharSequence to = Address.toFriendly(message.getRecipients(RecipientType.TO), contacts);
|
||||||
|
final CharSequence cc = Address.toFriendly(message.getRecipients(RecipientType.CC), contacts);
|
||||||
|
|
||||||
|
|
||||||
runOnUiThread(new Runnable()
|
runOnUiThread(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
String subject = message.getSubject();
|
||||||
setTitle(subject);
|
setTitle(subject);
|
||||||
if (subject == null || subject.equals(""))
|
if (subject == null || subject.equals(""))
|
||||||
{
|
{
|
||||||
@ -515,20 +514,14 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
mCcContainerView.setVisibility((cc != null && cc.length() > 0)? View.VISIBLE : View.GONE);
|
mCcContainerView.setVisibility((cc != null && cc.length() > 0)? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
mCcView.setText(cc);
|
mCcView.setText(cc);
|
||||||
mAttachmentIcon.setVisibility(hasAttachments ? View.VISIBLE : View.GONE);
|
mAttachmentIcon.setVisibility(((LocalMessage) message).hasAttachments() ? View.VISIBLE : View.GONE);
|
||||||
mFlagged.setChecked(flagged);
|
mFlagged.setChecked(message.isSet(Flag.FLAGGED));
|
||||||
|
|
||||||
mSubjectView.setTextColor(0xff000000 | defaultSubjectColor);
|
mSubjectView.setTextColor(0xff000000 | defaultSubjectColor);
|
||||||
|
chip.setBackgroundColor(mAccount.getChipColor());
|
||||||
chip.setBackgroundColor(accountColor);
|
chip.getBackground().setAlpha(!message.isSet(Flag.SEEN) ? 255 : 127);
|
||||||
chip.getBackground().setAlpha(unread ? 255 : 127);
|
if (message.isSet(Flag.ANSWERED)) {
|
||||||
|
|
||||||
if (answered)
|
|
||||||
{
|
|
||||||
mSubjectView.setCompoundDrawablesWithIntrinsicBounds(answeredIcon, null, null, null);
|
mSubjectView.setCompoundDrawablesWithIntrinsicBounds(answeredIcon, null, null, null);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
mSubjectView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
mSubjectView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1527,7 +1520,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
mMessage.setFlag(Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
|
mMessage.setFlag(Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED));
|
||||||
setHeaders(mAccount, mMessage.getFolder().getName(), mMessage.getUid(), mMessage);
|
setHeaders(mMessage.getFolder().getName(), mMessage.getUid(), mMessage);
|
||||||
prepareMenuItems();
|
prepareMenuItems();
|
||||||
}
|
}
|
||||||
catch (MessagingException me)
|
catch (MessagingException me)
|
||||||
@ -1730,7 +1723,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
mMessage.setFlag(Flag.SEEN, false);
|
mMessage.setFlag(Flag.SEEN, false);
|
||||||
setHeaders(mAccount, mMessage.getFolder().getName(), mMessage.getUid(), mMessage);
|
setHeaders(mMessage.getFolder().getName(), mMessage.getUid(), mMessage);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -2163,32 +2156,12 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHeaders(Account account, String folder, String uid,
|
private void setHeaders(String folder, String uid,
|
||||||
final Message message) throws MessagingException
|
final Message message) throws MessagingException
|
||||||
{
|
{
|
||||||
String subjectText = message.getSubject();
|
|
||||||
final Contacts contacts = K9.showContactName() ? mContacts : null;
|
|
||||||
CharSequence fromText = Address.toFriendly(message.getFrom(), contacts);
|
|
||||||
String dateText = getDateFormat().format(message.getSentDate());
|
|
||||||
String timeText = getTimeFormat().format(message.getSentDate());
|
|
||||||
CharSequence toText = Address.toFriendly(message.getRecipients(RecipientType.TO), contacts);
|
|
||||||
CharSequence ccText = Address.toFriendly(message.getRecipients(RecipientType.CC), contacts);
|
|
||||||
|
|
||||||
int color = mAccount.getChipColor();
|
|
||||||
boolean hasAttachments = ((LocalMessage) message).hasAttachments();
|
|
||||||
boolean unread = !message.isSet(Flag.SEEN);
|
|
||||||
|
|
||||||
mHandler.setHeaders(subjectText,
|
mHandler.setHeaders(message);
|
||||||
fromText,
|
|
||||||
dateText,
|
|
||||||
timeText,
|
|
||||||
toText,
|
|
||||||
ccText,
|
|
||||||
color,
|
|
||||||
unread,
|
|
||||||
hasAttachments,
|
|
||||||
message.isSet(Flag.FLAGGED),
|
|
||||||
message.isSet(Flag.ANSWERED));
|
|
||||||
|
|
||||||
// Update additional headers display, if visible
|
// Update additional headers display, if visible
|
||||||
if (mAdditionalHeadersView.getVisibility() == View.VISIBLE)
|
if (mAdditionalHeadersView.getVisibility() == View.VISIBLE)
|
||||||
@ -2227,7 +2200,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
setHeaders(account, folder, uid, message);
|
setHeaders(folder, uid, message);
|
||||||
mHandler.showHeaderContainer();
|
mHandler.showHeaderContainer();
|
||||||
}
|
}
|
||||||
catch (MessagingException me)
|
catch (MessagingException me)
|
||||||
@ -2253,7 +2226,7 @@ public class MessageView extends K9Activity implements OnClickListener
|
|||||||
&& message.isSet(Flag.X_DOWNLOADED_FULL))
|
&& message.isSet(Flag.X_DOWNLOADED_FULL))
|
||||||
{
|
{
|
||||||
|
|
||||||
setHeaders(account, folder, uid, message);
|
setHeaders(folder, uid, message);
|
||||||
mHandler.showHeaderContainer();
|
mHandler.showHeaderContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user