1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

move the To and Cc labels into their own Views; stop playing span games to style them

This commit is contained in:
Jesse Vincent 2013-02-08 21:24:36 -05:00
parent 14b4b28fa0
commit 648a6eed86

View File

@ -22,6 +22,7 @@ import android.widget.Toast;
import com.fsck.k9.FontSizes; import com.fsck.k9.FontSizes;
import com.fsck.k9.K9; import com.fsck.k9.K9;
import com.fsck.k9.R; import com.fsck.k9.R;
import com.fsck.k9.activity.misc.ContactPictureLoader;
import com.fsck.k9.helper.Contacts; import com.fsck.k9.helper.Contacts;
import com.fsck.k9.Account; import com.fsck.k9.Account;
import com.fsck.k9.helper.DateFormatter; import com.fsck.k9.helper.DateFormatter;
@ -44,7 +45,9 @@ public class MessageHeader extends ScrollView implements OnClickListener {
private TextView mDateView; private TextView mDateView;
private TextView mTimeView; private TextView mTimeView;
private TextView mToView; private TextView mToView;
private TextView mToLabel;
private TextView mCcView; private TextView mCcView;
private TextView mCcLabel;
private TextView mSubjectView; private TextView mSubjectView;
private DateFormat mDateFormat; private DateFormat mDateFormat;
private DateFormat mTimeFormat; private DateFormat mTimeFormat;
@ -61,6 +64,9 @@ public class MessageHeader extends ScrollView implements OnClickListener {
private Contacts mContacts; private Contacts mContacts;
private SavedState mSavedState; private SavedState mSavedState;
private ContactPictureLoader mContactsPictureLoader;
private QuickContactBadge mContactBadge;
private OnLayoutChangedListener mOnLayoutChangedListener; private OnLayoutChangedListener mOnLayoutChangedListener;
/** /**
@ -91,7 +97,9 @@ public class MessageHeader extends ScrollView implements OnClickListener {
mForwardedIcon = findViewById(R.id.forwarded); mForwardedIcon = findViewById(R.id.forwarded);
mFromView = (TextView) findViewById(R.id.from); mFromView = (TextView) findViewById(R.id.from);
mToView = (TextView) findViewById(R.id.to); mToView = (TextView) findViewById(R.id.to);
mToLabel = (TextView) findViewById(R.id.to_label);
mCcView = (TextView) findViewById(R.id.cc); mCcView = (TextView) findViewById(R.id.cc);
mCcLabel = (TextView) findViewById(R.id.cc_label);
mSubjectView = (TextView) findViewById(R.id.subject); mSubjectView = (TextView) findViewById(R.id.subject);
mAdditionalHeadersView = (TextView) findViewById(R.id.additional_headers_view); mAdditionalHeadersView = (TextView) findViewById(R.id.additional_headers_view);
mChip = findViewById(R.id.chip); mChip = findViewById(R.id.chip);
@ -107,7 +115,9 @@ public class MessageHeader extends ScrollView implements OnClickListener {
mFontSizes.setViewTextSize(mFromView, mFontSizes.getMessageViewSender()); mFontSizes.setViewTextSize(mFromView, mFontSizes.getMessageViewSender());
mFontSizes.setViewTextSize(mToView, mFontSizes.getMessageViewTo()); mFontSizes.setViewTextSize(mToView, mFontSizes.getMessageViewTo());
mFontSizes.setViewTextSize(mToLabel, mFontSizes.getMessageViewTo());
mFontSizes.setViewTextSize(mCcView, mFontSizes.getMessageViewCC()); mFontSizes.setViewTextSize(mCcView, mFontSizes.getMessageViewCC());
mFontSizes.setViewTextSize(mCcLabel, mFontSizes.getMessageViewCC());
mFromView.setOnClickListener(this); mFromView.setOnClickListener(this);
mToView.setOnClickListener(this); mToView.setOnClickListener(this);
@ -240,8 +250,8 @@ public class MessageHeader extends ScrollView implements OnClickListener {
mDateView.setVisibility(View.GONE); mDateView.setVisibility(View.GONE);
} }
mTimeView.setText(time); mTimeView.setText(time);
updateAddressField(mToView, to, R.string.message_to_label); updateAddressField(mToView, to, mToLabel);
updateAddressField(mCcView, cc, R.string.message_view_cc_label); updateAddressField(mCcView, cc, mCcLabel);
mAnsweredIcon.setVisibility(message.isSet(Flag.ANSWERED) ? View.VISIBLE : View.GONE); mAnsweredIcon.setVisibility(message.isSet(Flag.ANSWERED) ? View.VISIBLE : View.GONE);
mForwardedIcon.setVisibility(message.isSet(Flag.FORWARDED) ? View.VISIBLE : View.GONE); mForwardedIcon.setVisibility(message.isSet(Flag.FORWARDED) ? View.VISIBLE : View.GONE);
mFlagged.setChecked(message.isSet(Flag.FLAGGED)); mFlagged.setChecked(message.isSet(Flag.FLAGGED));
@ -277,24 +287,20 @@ public class MessageHeader extends ScrollView implements OnClickListener {
layoutChanged(); layoutChanged();
} }
private static final StyleSpan sBoldSpan = new StyleSpan(Typeface.BOLD);
private void updateAddressField(TextView v, CharSequence address, int prefixId) { private void updateAddressField(TextView v, CharSequence text, View label) {
if (TextUtils.isEmpty(address)) { if (TextUtils.isEmpty(text)) {
v.setVisibility(View.GONE); v.setVisibility(View.GONE);
label.setVisibility(View.GONE);
return; return;
} }
final SpannableStringBuilder text = new SpannableStringBuilder();
final String prefix = mContext.getString(prefixId);
text.append(prefix);
text.append(" ");
text.append(address);
text.setSpan(sBoldSpan, 0, prefix.length(), 0);
v.setText(text); v.setText(text);
v.setVisibility(View.VISIBLE); v.setVisibility(View.VISIBLE);
label.setVisibility(View.VISIBLE);
} }
/** /**