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

option to put the sender of a message above the subject

This commit is contained in:
Jesse Vincent 2012-09-24 19:11:21 -04:00
parent 83c5783442
commit 2c486e31b6
5 changed files with 103 additions and 41 deletions

View File

@ -313,6 +313,10 @@ http://k9mail.googlecode.com/
<string name="global_settings_preview_lines_label">Preview lines</string> <string name="global_settings_preview_lines_label">Preview lines</string>
<string name="global_settings_show_correspondent_names_label">Show correspondent names</string> <string name="global_settings_show_correspondent_names_label">Show correspondent names</string>
<string name="global_settings_show_correspondent_names_summary">Show correspondent names rather than their email addresses</string> <string name="global_settings_show_correspondent_names_summary">Show correspondent names rather than their email addresses</string>
<string name="global_settings_sender_above_subject_label">Correspondent above subject</string>
<string name="global_settings_sender_above_subject_summary">Show correspondent names above the subject line, rather than below it</string>
<string name="global_settings_show_contact_name_label">Show contact names</string> <string name="global_settings_show_contact_name_label">Show contact names</string>
<string name="global_settings_show_contact_name_summary">Use recipient names from Contacts when available</string> <string name="global_settings_show_contact_name_summary">Use recipient names from Contacts when available</string>
<string name="global_settings_registered_name_color_label">Colorize contacts</string> <string name="global_settings_registered_name_color_label">Colorize contacts</string>

View File

@ -116,7 +116,11 @@
android:summary="@string/global_settings_show_correspondent_names_summary" android:summary="@string/global_settings_show_correspondent_names_summary"
/> />
<CheckBoxPreference
android:persistent="false"
android:key="messagelist_sender_above_subject"
android:title="@string/global_settings_sender_above_subject_label"
android:summary="@string/global_settings_sender_above_subject_summary" />
<CheckBoxPreference <CheckBoxPreference
android:persistent="false" android:persistent="false"
android:key="messagelist_show_contact_name" android:key="messagelist_show_contact_name"

View File

@ -170,6 +170,7 @@ public class K9 extends Application {
private static int mMessageListPreviewLines = 2; private static int mMessageListPreviewLines = 2;
private static boolean mShowCorrespondentNames = true; private static boolean mShowCorrespondentNames = true;
private static boolean mMessageListSenderAboveSubject = false;
private static boolean mShowContactName = false; private static boolean mShowContactName = false;
private static boolean mChangeContactNameColor = false; private static boolean mChangeContactNameColor = false;
private static int mContactNameColor = 0xff00008f; private static int mContactNameColor = 0xff00008f;
@ -434,6 +435,7 @@ public class K9 extends Application {
editor.putBoolean("startIntegratedInbox", mStartIntegratedInbox); editor.putBoolean("startIntegratedInbox", mStartIntegratedInbox);
editor.putBoolean("measureAccounts", mMeasureAccounts); editor.putBoolean("measureAccounts", mMeasureAccounts);
editor.putBoolean("countSearchMessages", mCountSearchMessages); editor.putBoolean("countSearchMessages", mCountSearchMessages);
editor.putBoolean("messageListSenderAboveSubject", mMessageListSenderAboveSubject);
editor.putBoolean("hideSpecialAccounts", mHideSpecialAccounts); editor.putBoolean("hideSpecialAccounts", mHideSpecialAccounts);
editor.putInt("messageListPreviewLines", mMessageListPreviewLines); editor.putInt("messageListPreviewLines", mMessageListPreviewLines);
@ -584,6 +586,7 @@ public class K9 extends Application {
mMeasureAccounts = sprefs.getBoolean("measureAccounts", true); mMeasureAccounts = sprefs.getBoolean("measureAccounts", true);
mCountSearchMessages = sprefs.getBoolean("countSearchMessages", true); mCountSearchMessages = sprefs.getBoolean("countSearchMessages", true);
mHideSpecialAccounts = sprefs.getBoolean("hideSpecialAccounts", false); mHideSpecialAccounts = sprefs.getBoolean("hideSpecialAccounts", false);
mMessageListSenderAboveSubject = sprefs.getBoolean("messageListSenderAboveSubject", false);
mMessageListPreviewLines = sprefs.getInt("messageListPreviewLines", 2); mMessageListPreviewLines = sprefs.getInt("messageListPreviewLines", 2);
mMobileOptimizedLayout = sprefs.getBoolean("mobileOptimizedLayout", false); mMobileOptimizedLayout = sprefs.getBoolean("mobileOptimizedLayout", false);
@ -881,6 +884,13 @@ public class K9 extends Application {
return mShowCorrespondentNames; return mShowCorrespondentNames;
} }
public static boolean messageListSenderAboveSubject() {
return mMessageListSenderAboveSubject;
}
public static void setMessageListSenderAboveSubject(boolean sender) {
mMessageListSenderAboveSubject = sender;
}
public static void setShowCorrespondentNames(boolean showCorrespondentNames) { public static void setShowCorrespondentNames(boolean showCorrespondentNames) {
mShowCorrespondentNames = showCorrespondentNames; mShowCorrespondentNames = showCorrespondentNames;
} }

View File

@ -297,6 +297,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener,
private SortType mSortType = SortType.SORT_DATE; private SortType mSortType = SortType.SORT_DATE;
private boolean mSortAscending = true; private boolean mSortAscending = true;
private boolean mSortDateAscending = false; private boolean mSortDateAscending = false;
private boolean mSenderAboveSubject = false;
private int mSelectedCount = 0; private int mSelectedCount = 0;
@ -806,6 +807,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener,
return; return;
} }
StorageManager.getInstance(getApplication()).addListener(mStorageListener); StorageManager.getInstance(getApplication()).addListener(mStorageListener);
mSenderAboveSubject = K9.messageListSenderAboveSubject();
// TODO Add support for pull to fresh on searches. // TODO Add support for pull to fresh on searches.
if(mQueryString == null) { if(mQueryString == null) {
@ -2125,13 +2127,18 @@ public class MessageList extends K9ListActivity implements OnItemClickListener,
if (holder == null) { if (holder == null) {
holder = new MessageViewHolder(); holder = new MessageViewHolder();
holder.subject = (TextView) view.findViewById(R.id.subject);
holder.from = (TextView) view.findViewById(R.id.from);
holder.date = (TextView) view.findViewById(R.id.date); holder.date = (TextView) view.findViewById(R.id.date);
holder.chip = view.findViewById(R.id.chip); holder.chip = view.findViewById(R.id.chip);
holder.preview = (TextView) view.findViewById(R.id.preview); holder.preview = (TextView) view.findViewById(R.id.preview);
if (mSenderAboveSubject) {
holder.from = (TextView) view.findViewById(R.id.subject);
holder.from.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageListSender());
} else {
holder.subject = (TextView) view.findViewById(R.id.subject);
holder.subject.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageListSubject()); holder.subject.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageListSubject());
}
holder.date.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageListDate()); holder.date.setTextSize(TypedValue.COMPLEX_UNIT_SP, mFontSizes.getMessageListDate());
holder.preview.setLines(mPreviewLines); holder.preview.setLines(mPreviewLines);
@ -2147,9 +2154,13 @@ public class MessageList extends K9ListActivity implements OnItemClickListener,
// hands us an invalid message // hands us an invalid message
holder.chip.getBackground().setAlpha(0); holder.chip.getBackground().setAlpha(0);
if (holder.subject != null) {
holder.subject.setText(getString(R.string.general_no_subject)); holder.subject.setText(getString(R.string.general_no_subject));
holder.subject.setTypeface(null, Typeface.NORMAL); holder.subject.setTypeface(null, Typeface.NORMAL);
}
String noSender = getString(R.string.general_no_sender); String noSender = getString(R.string.general_no_sender);
if (holder.preview != null) { if (holder.preview != null) {
holder.preview.setText(noSender, TextView.BufferType.SPANNABLE); holder.preview.setText(noSender, TextView.BufferType.SPANNABLE);
Spannable str = (Spannable) holder.preview.getText(); Spannable str = (Spannable) holder.preview.getText();
@ -2192,16 +2203,18 @@ public class MessageList extends K9ListActivity implements OnItemClickListener,
* @param message * @param message
* Never <code>null</code>. * Never <code>null</code>.
*/ */
private void bindView(final int position, final View view, final MessageViewHolder holder, private void bindView(final int position, final View view, final MessageViewHolder holder,
final MessageInfoHolder message) { final MessageInfoHolder message) {
holder.subject.setTypeface(null, message.read ? Typeface.NORMAL : Typeface.BOLD);
int maybeBoldTypeface = message.read ? Typeface.NORMAL : Typeface.BOLD;
// So that the mSelectedCount is only incremented/decremented // So that the mSelectedCount is only incremented/decremented
// when a user checks the checkbox (vs code) // when a user checks the checkbox (vs code)
holder.position = -1; holder.position = -1;
if (message.selected) { if (message.selected) {
holder.chip.setBackgroundDrawable(message.message.getFolder().getAccount().getCheckmarkChip().drawable()); holder.chip.setBackgroundDrawable(message.message.getFolder().getAccount().getCheckmarkChip().drawable());
@ -2211,78 +2224,103 @@ public class MessageList extends K9ListActivity implements OnItemClickListener,
holder.chip.setBackgroundDrawable(message.message.getFolder().getAccount().generateColorChip(message.read,message.message.toMe(), false, message.flagged).drawable()); holder.chip.setBackgroundDrawable(message.message.getFolder().getAccount().generateColorChip(message.read,message.message.toMe(), false, message.flagged).drawable());
} }
// TODO: Make these colors part of the theme
// if (K9.getK9Theme() == K9.THEME_LIGHT) { // if (K9.getK9Theme() == K9.THEME_LIGHT) {
// // Light theme: light grey background for read messages // // Light theme: light grey background for read messages
// view.setBackgroundColor(message.read ? Color.rgb(229, 229, 229) : Color.rgb(255, 255, 255)); // view.setBackgroundColor(message.read ?
// Color.rgb(230, 230, 230) : Color.rgb(255, 255, 255));
// } else { // } else {
// // Dark theme: dark grey background for unread messages // // Dark theme: dark grey background for unread messages
// view.setBackgroundColor(message.read ? 0 : Color.rgb(45, 45, 45)); // view.setBackgroundColor(message.read ? 0 : Color.rgb(45, 45, 45));
// } // }
String subject = null;
if ((message.message.getSubject() == null) || message.message.getSubject().equals("")) { if ((message.message.getSubject() == null) || message.message.getSubject().equals("")) {
holder.subject.setText(getText(R.string.general_no_subject)); subject = (String) getText(R.string.general_no_subject);
} else { } else {
holder.subject.setText(message.message.getSubject()); subject = message.message.getSubject();
} }
int senderTypeface = message.read ? Typeface.NORMAL : Typeface.BOLD; // We'll get badge support soon --jrv
// if (holder.badge != null) {
// String email = message.counterpartyAddress;
// holder.badge.assignContactFromEmail(email, true);
// if (email != null) {
// mContactsPictureLoader.loadContactPicture(email, holder.badge);
// }
// }
if (holder.preview != null) { if (holder.preview != null) {
/* /*
* In the touchable UI, we have previews. Otherwise, we
* have just a "from" line.
* Because text views can't wrap around each other(?) we * Because text views can't wrap around each other(?) we
* compose a custom view containing the preview and the * compose a custom view containing the preview and the
* from. * from.
*/ */
CharSequence beforePreviewText = null;
if (mSenderAboveSubject) {
beforePreviewText = subject;
} else {
beforePreviewText = message.sender;
}
holder.preview.setText(new SpannableStringBuilder(recipientSigil(message)) holder.preview.setText(new SpannableStringBuilder(recipientSigil(message))
.append(message.sender).append(" ").append(message.message.getPreview()), .append(beforePreviewText).append(" ").append(message.message.getPreview()),
TextView.BufferType.SPANNABLE); TextView.BufferType.SPANNABLE);
Spannable str = (Spannable)holder.preview.getText(); Spannable str = (Spannable)holder.preview.getText();
// Create a span section for the sender, and assign the correct font size and weight. // Create a span section for the sender, and assign the correct font size and weight.
str.setSpan(new StyleSpan(senderTypeface), str.setSpan(new AbsoluteSizeSpan((mSenderAboveSubject ? mFontSizes.getMessageListSubject(): mFontSizes.getMessageListSender()), true),
0, 0, beforePreviewText.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
message.sender.length() + 1,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
str.setSpan(new AbsoluteSizeSpan(mFontSizes.getMessageListSender(), true),
0,
message.sender.length() + 1,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// TODO: Make these colors part of the theme
int color = (K9.getK9Theme() == K9.THEME_LIGHT) ? int color = (K9.getK9Theme() == K9.THEME_LIGHT) ?
Color.rgb(105, 105, 105) : Color.rgb(105, 105, 105) :
Color.rgb(160, 160, 160); Color.rgb(160, 160, 160);
// set span for preview message. // set span for preview message.
str.setSpan(new ForegroundColorSpan(color), // How do I can specify the android.R.attr.textColorTertiary str.setSpan(new ForegroundColorSpan(color), // How do I can specify the android.R.attr.textColorTertiary
message.sender.length() + 1, beforePreviewText.length() + 1,
str.length(), str.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} else {
holder.from.setText(new SpannableStringBuilder(recipientSigil(message)).append(message.sender));
holder.from.setTypeface(null, senderTypeface);
} }
holder.date.setText(message.getDate(mMessageHelper));
Drawable statusHolder = null; if (holder.from != null ) {
if (message.forwarded && message.answered) { holder.from.setTypeface(null, maybeBoldTypeface);
statusHolder = mForwardedAnsweredIcon; if (mSenderAboveSubject) {
} else if (message.answered) { holder.from.setCompoundDrawablesWithIntrinsicBounds(
statusHolder = mAnsweredIcon; message.answered ? mAnsweredIcon : null, // left
} else if (message.forwarded) {
statusHolder = mForwardedIcon;
}
holder.subject.setCompoundDrawablesWithIntrinsicBounds(statusHolder, // left
null, // top null, // top
message.message.hasAttachments() ? mAttachmentIcon : null, // right message.message.hasAttachments() ? mAttachmentIcon : null, // right
null); // bottom null); // bottom
holder.from.setText(message.sender);
} else {
holder.from.setText(new SpannableStringBuilder(recipientSigil(message)).append(message.sender));
}
}
if (holder.subject != null ) {
if (!mSenderAboveSubject) {
holder.subject.setCompoundDrawablesWithIntrinsicBounds(
message.answered ? mAnsweredIcon : null, // left
null, // top
message.message.hasAttachments() ? mAttachmentIcon : null, // right
null); // bottom
}
holder.subject.setTypeface(null, maybeBoldTypeface);
holder.subject.setText(subject);
}
holder.date.setText(message.getDate(mMessageHelper));
holder.position = position; holder.position = position;
} }
private String recipientSigil(MessageInfoHolder message) { private String recipientSigil(MessageInfoHolder message) {
if (message.message.toMe()) { if (message.message.toMe()) {
return getString(R.string.messagelist_sent_to_me_sigil); return getString(R.string.messagelist_sent_to_me_sigil);

View File

@ -60,6 +60,7 @@ public class Prefs extends K9PreferenceActivity {
private static final String PREFERENCE_COUNT_SEARCH = "count_search"; private static final String PREFERENCE_COUNT_SEARCH = "count_search";
private static final String PREFERENCE_HIDE_SPECIAL_ACCOUNTS = "hide_special_accounts"; private static final String PREFERENCE_HIDE_SPECIAL_ACCOUNTS = "hide_special_accounts";
private static final String PREFERENCE_MESSAGELIST_PREVIEW_LINES = "messagelist_preview_lines"; private static final String PREFERENCE_MESSAGELIST_PREVIEW_LINES = "messagelist_preview_lines";
private static final String PREFERENCE_MESSAGELIST_SENDER_ABOVE_SUBJECT = "messagelist_sender_above_subject";
private static final String PREFERENCE_MESSAGELIST_SHOW_CORRESPONDENT_NAMES = "messagelist_show_correspondent_names"; private static final String PREFERENCE_MESSAGELIST_SHOW_CORRESPONDENT_NAMES = "messagelist_show_correspondent_names";
private static final String PREFERENCE_MESSAGELIST_SHOW_CONTACT_NAME = "messagelist_show_contact_name"; private static final String PREFERENCE_MESSAGELIST_SHOW_CONTACT_NAME = "messagelist_show_contact_name";
private static final String PREFERENCE_MESSAGELIST_CONTACT_NAME_COLOR = "messagelist_contact_name_color"; private static final String PREFERENCE_MESSAGELIST_CONTACT_NAME_COLOR = "messagelist_contact_name_color";
@ -99,6 +100,7 @@ public class Prefs extends K9PreferenceActivity {
private CheckBoxPreference mCountSearch; private CheckBoxPreference mCountSearch;
private CheckBoxPreference mHideSpecialAccounts; private CheckBoxPreference mHideSpecialAccounts;
private ListPreference mPreviewLines; private ListPreference mPreviewLines;
private CheckBoxPreference mSenderAboveSubject;
private CheckBoxPreference mShowCorrespondentNames; private CheckBoxPreference mShowCorrespondentNames;
private CheckBoxPreference mShowContactName; private CheckBoxPreference mShowContactName;
private CheckBoxPreference mChangeContactNameColor; private CheckBoxPreference mChangeContactNameColor;
@ -212,6 +214,9 @@ public class Prefs extends K9PreferenceActivity {
mPreviewLines = setupListPreference(PREFERENCE_MESSAGELIST_PREVIEW_LINES, mPreviewLines = setupListPreference(PREFERENCE_MESSAGELIST_PREVIEW_LINES,
Integer.toString(K9.messageListPreviewLines())); Integer.toString(K9.messageListPreviewLines()));
mSenderAboveSubject = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_SENDER_ABOVE_SUBJECT);
mSenderAboveSubject.setChecked(K9.messageListSenderAboveSubject());
mShowCorrespondentNames = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_SHOW_CORRESPONDENT_NAMES); mShowCorrespondentNames = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGELIST_SHOW_CORRESPONDENT_NAMES);
mShowCorrespondentNames.setChecked(K9.showCorrespondentNames()); mShowCorrespondentNames.setChecked(K9.showCorrespondentNames());
@ -399,6 +404,7 @@ public class Prefs extends K9PreferenceActivity {
K9.setHideSpecialAccounts(mHideSpecialAccounts.isChecked()); K9.setHideSpecialAccounts(mHideSpecialAccounts.isChecked());
K9.setMessageListPreviewLines(Integer.parseInt(mPreviewLines.getValue())); K9.setMessageListPreviewLines(Integer.parseInt(mPreviewLines.getValue()));
K9.setShowCorrespondentNames(mShowCorrespondentNames.isChecked()); K9.setShowCorrespondentNames(mShowCorrespondentNames.isChecked());
K9.setMessageListSenderAboveSubject(mSenderAboveSubject.isChecked());
K9.setShowContactName(mShowContactName.isChecked()); K9.setShowContactName(mShowContactName.isChecked());
K9.setChangeContactNameColor(mChangeContactNameColor.isChecked()); K9.setChangeContactNameColor(mChangeContactNameColor.isChecked());
K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked()); K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked());