Loading k9mail/src/main/java/com/fsck/k9/Account.java +12 −0 Original line number Diff line number Diff line Loading @@ -181,6 +181,7 @@ public class Account implements BaseAccount, StoreConfig { private boolean mNotifyNewMail; private FolderMode mFolderNotifyNewMailMode; private boolean mNotifySelfNewMail; private boolean mNotifyContactsMailOnly; private String mInboxFolderName; private String mDraftsFolderName; private String mSentFolderName; Loading Loading @@ -289,6 +290,7 @@ public class Account implements BaseAccount, StoreConfig { mFolderNotifyNewMailMode = FolderMode.ALL; mNotifySync = true; mNotifySelfNewMail = true; mNotifyContactsMailOnly = false; mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS; mFolderSyncMode = FolderMode.FIRST_CLASS; mFolderPushMode = FolderMode.FIRST_CLASS; Loading Loading @@ -397,6 +399,7 @@ public class Account implements BaseAccount, StoreConfig { mFolderNotifyNewMailMode = getEnumStringPref(storage, mUuid + ".folderNotifyNewMailMode", FolderMode.ALL); mNotifySelfNewMail = storage.getBoolean(mUuid + ".notifySelfNewMail", true); mNotifyContactsMailOnly = storage.getBoolean(mUuid + ".notifyContactsMailOnly", false); mNotifySync = storage.getBoolean(mUuid + ".notifyMailCheck", false); mDeletePolicy = DeletePolicy.fromInt(storage.getInt(mUuid + ".deletePolicy", DeletePolicy.NEVER.setting)); mInboxFolderName = storage.getString(mUuid + ".inboxFolderName", INBOX); Loading Loading @@ -684,6 +687,7 @@ public class Account implements BaseAccount, StoreConfig { editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail); editor.putString(mUuid + ".folderNotifyNewMailMode", mFolderNotifyNewMailMode.name()); editor.putBoolean(mUuid + ".notifySelfNewMail", mNotifySelfNewMail); editor.putBoolean(mUuid + ".notifyContactsMailOnly", mNotifyContactsMailOnly); editor.putBoolean(mUuid + ".notifyMailCheck", mNotifySync); editor.putInt(mUuid + ".deletePolicy", mDeletePolicy.setting); editor.putString(mUuid + ".inboxFolderName", mInboxFolderName); Loading Loading @@ -1252,6 +1256,14 @@ public class Account implements BaseAccount, StoreConfig { mNotifySelfNewMail = notifySelfNewMail; } public synchronized boolean isNotifyContactsMailOnly() { return mNotifyContactsMailOnly; } public synchronized void setNotifyContactsMailOnly(boolean notifyContactsMailOnly) { this.mNotifyContactsMailOnly = notifyContactsMailOnly; } public synchronized Expunge getExpungePolicy() { return mExpungePolicy; } Loading k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java +6 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ public class AccountSettings extends K9PreferenceActivity { private static final String PREFERENCE_NOTIFY = "account_notify"; private static final String PREFERENCE_NOTIFY_NEW_MAIL_MODE = "folder_notify_new_mail_mode"; private static final String PREFERENCE_NOTIFY_SELF = "account_notify_self"; private static final String PREFERENCE_NOTIFY_CONTACTS_MAIL_ONLY = "account_notify_contacts_mail_only"; private static final String PREFERENCE_NOTIFY_SYNC = "account_notify_sync"; private static final String PREFERENCE_VIBRATE = "account_vibrate"; private static final String PREFERENCE_VIBRATE_PATTERN = "account_vibrate_pattern"; Loading Loading @@ -146,6 +147,7 @@ public class AccountSettings extends K9PreferenceActivity { private CheckBoxPreference mAccountNotify; private ListPreference mAccountNotifyNewMailMode; private CheckBoxPreference mAccountNotifySelf; private CheckBoxPreference mAccountNotifyContactsMailOnly; private ListPreference mAccountShowPictures; private CheckBoxPreference mAccountNotifySync; private CheckBoxPreference mAccountVibrate; Loading Loading @@ -590,6 +592,9 @@ public class AccountSettings extends K9PreferenceActivity { mAccountNotifySelf = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_SELF); mAccountNotifySelf.setChecked(mAccount.isNotifySelfNewMail()); mAccountNotifyContactsMailOnly = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_CONTACTS_MAIL_ONLY); mAccountNotifyContactsMailOnly.setChecked(mAccount.isNotifyContactsMailOnly()); mAccountNotifySync = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_SYNC); mAccountNotifySync.setChecked(mAccount.isShowOngoing()); Loading Loading @@ -753,6 +758,7 @@ public class AccountSettings extends K9PreferenceActivity { mAccount.setNotifyNewMail(mAccountNotify.isChecked()); mAccount.setFolderNotifyNewMailMode(FolderMode.valueOf(mAccountNotifyNewMailMode.getValue())); mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked()); mAccount.setNotifyContactsMailOnly(mAccountNotifyContactsMailOnly.isChecked()); mAccount.setShowOngoing(mAccountNotifySync.isChecked()); mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue())); mAccount.setMaximumAutoDownloadMessageSize(Integer.parseInt(mMessageSize.getValue())); Loading k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +6 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.Build; import android.os.PowerManager; import android.os.Process; import android.os.SystemClock; import android.provider.ContactsContract; import android.support.annotation.VisibleForTesting; import android.util.Log; Loading @@ -55,6 +56,7 @@ import com.fsck.k9.R; import com.fsck.k9.activity.MessageReference; import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection; import com.fsck.k9.cache.EmailProviderCache; import com.fsck.k9.helper.Contacts; import com.fsck.k9.mail.Address; import com.fsck.k9.mail.AuthenticationFailedException; import com.fsck.k9.mail.CertificateValidationException; Loading Loading @@ -4313,6 +4315,10 @@ public class MessagingController implements Runnable { return false; } if (account.isNotifyContactsMailOnly() && !Contacts.getInstance(context).containsContact(message.getFrom())) { return false; } return true; } Loading k9mail/src/main/java/com/fsck/k9/helper/Contacts.java +20 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,26 @@ public class Contacts { return result; } /** * Check whether one of the provided addresses belongs to one of the contacts. * * @param addresses The addresses to search in contacts * @return <tt>true</tt>, if one address belongs to a contact. * <tt>false</tt>, otherwise. */ public boolean containsContact(final Address[] addresses) { if (addresses == null) { return false; } for (Address addr : addresses) { if (isInContacts(addr.getAddress())) { return true; } } return false; } /** * Get the name of the contact an email address belongs to. * Loading k9mail/src/main/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -532,6 +532,8 @@ Please submit bug reports, contribute new features and ask questions at <string name="account_settings_notify_sync_summary">Notify in status bar while mail is checked</string> <string name="account_settings_notify_self_label">Include outgoing mail</string> <string name="account_settings_notify_self_summary">Show a notification for messages I sent</string> <string name="account_notify_contacts_mail_only_label">Contacts only</string> <string name="account_notify_contacts_mail_only_summary">Show a notification only for messages of known contacts</string> <string name="account_settings_notification_opens_unread_label">Notification opens unread messages</string> <string name="account_settings_notification_opens_unread_summary">Searches for unread messages when Notification is opened</string> <string name="account_settings_mark_message_as_read_on_view_label">Mark as read when opened</string> Loading Loading
k9mail/src/main/java/com/fsck/k9/Account.java +12 −0 Original line number Diff line number Diff line Loading @@ -181,6 +181,7 @@ public class Account implements BaseAccount, StoreConfig { private boolean mNotifyNewMail; private FolderMode mFolderNotifyNewMailMode; private boolean mNotifySelfNewMail; private boolean mNotifyContactsMailOnly; private String mInboxFolderName; private String mDraftsFolderName; private String mSentFolderName; Loading Loading @@ -289,6 +290,7 @@ public class Account implements BaseAccount, StoreConfig { mFolderNotifyNewMailMode = FolderMode.ALL; mNotifySync = true; mNotifySelfNewMail = true; mNotifyContactsMailOnly = false; mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS; mFolderSyncMode = FolderMode.FIRST_CLASS; mFolderPushMode = FolderMode.FIRST_CLASS; Loading Loading @@ -397,6 +399,7 @@ public class Account implements BaseAccount, StoreConfig { mFolderNotifyNewMailMode = getEnumStringPref(storage, mUuid + ".folderNotifyNewMailMode", FolderMode.ALL); mNotifySelfNewMail = storage.getBoolean(mUuid + ".notifySelfNewMail", true); mNotifyContactsMailOnly = storage.getBoolean(mUuid + ".notifyContactsMailOnly", false); mNotifySync = storage.getBoolean(mUuid + ".notifyMailCheck", false); mDeletePolicy = DeletePolicy.fromInt(storage.getInt(mUuid + ".deletePolicy", DeletePolicy.NEVER.setting)); mInboxFolderName = storage.getString(mUuid + ".inboxFolderName", INBOX); Loading Loading @@ -684,6 +687,7 @@ public class Account implements BaseAccount, StoreConfig { editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail); editor.putString(mUuid + ".folderNotifyNewMailMode", mFolderNotifyNewMailMode.name()); editor.putBoolean(mUuid + ".notifySelfNewMail", mNotifySelfNewMail); editor.putBoolean(mUuid + ".notifyContactsMailOnly", mNotifyContactsMailOnly); editor.putBoolean(mUuid + ".notifyMailCheck", mNotifySync); editor.putInt(mUuid + ".deletePolicy", mDeletePolicy.setting); editor.putString(mUuid + ".inboxFolderName", mInboxFolderName); Loading Loading @@ -1252,6 +1256,14 @@ public class Account implements BaseAccount, StoreConfig { mNotifySelfNewMail = notifySelfNewMail; } public synchronized boolean isNotifyContactsMailOnly() { return mNotifyContactsMailOnly; } public synchronized void setNotifyContactsMailOnly(boolean notifyContactsMailOnly) { this.mNotifyContactsMailOnly = notifyContactsMailOnly; } public synchronized Expunge getExpungePolicy() { return mExpungePolicy; } Loading
k9mail/src/main/java/com/fsck/k9/activity/setup/AccountSettings.java +6 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ public class AccountSettings extends K9PreferenceActivity { private static final String PREFERENCE_NOTIFY = "account_notify"; private static final String PREFERENCE_NOTIFY_NEW_MAIL_MODE = "folder_notify_new_mail_mode"; private static final String PREFERENCE_NOTIFY_SELF = "account_notify_self"; private static final String PREFERENCE_NOTIFY_CONTACTS_MAIL_ONLY = "account_notify_contacts_mail_only"; private static final String PREFERENCE_NOTIFY_SYNC = "account_notify_sync"; private static final String PREFERENCE_VIBRATE = "account_vibrate"; private static final String PREFERENCE_VIBRATE_PATTERN = "account_vibrate_pattern"; Loading Loading @@ -146,6 +147,7 @@ public class AccountSettings extends K9PreferenceActivity { private CheckBoxPreference mAccountNotify; private ListPreference mAccountNotifyNewMailMode; private CheckBoxPreference mAccountNotifySelf; private CheckBoxPreference mAccountNotifyContactsMailOnly; private ListPreference mAccountShowPictures; private CheckBoxPreference mAccountNotifySync; private CheckBoxPreference mAccountVibrate; Loading Loading @@ -590,6 +592,9 @@ public class AccountSettings extends K9PreferenceActivity { mAccountNotifySelf = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_SELF); mAccountNotifySelf.setChecked(mAccount.isNotifySelfNewMail()); mAccountNotifyContactsMailOnly = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_CONTACTS_MAIL_ONLY); mAccountNotifyContactsMailOnly.setChecked(mAccount.isNotifyContactsMailOnly()); mAccountNotifySync = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_SYNC); mAccountNotifySync.setChecked(mAccount.isShowOngoing()); Loading Loading @@ -753,6 +758,7 @@ public class AccountSettings extends K9PreferenceActivity { mAccount.setNotifyNewMail(mAccountNotify.isChecked()); mAccount.setFolderNotifyNewMailMode(FolderMode.valueOf(mAccountNotifyNewMailMode.getValue())); mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked()); mAccount.setNotifyContactsMailOnly(mAccountNotifyContactsMailOnly.isChecked()); mAccount.setShowOngoing(mAccountNotifySync.isChecked()); mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue())); mAccount.setMaximumAutoDownloadMessageSize(Integer.parseInt(mMessageSize.getValue())); Loading
k9mail/src/main/java/com/fsck/k9/controller/MessagingController.java +6 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.os.Build; import android.os.PowerManager; import android.os.Process; import android.os.SystemClock; import android.provider.ContactsContract; import android.support.annotation.VisibleForTesting; import android.util.Log; Loading @@ -55,6 +56,7 @@ import com.fsck.k9.R; import com.fsck.k9.activity.MessageReference; import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection; import com.fsck.k9.cache.EmailProviderCache; import com.fsck.k9.helper.Contacts; import com.fsck.k9.mail.Address; import com.fsck.k9.mail.AuthenticationFailedException; import com.fsck.k9.mail.CertificateValidationException; Loading Loading @@ -4313,6 +4315,10 @@ public class MessagingController implements Runnable { return false; } if (account.isNotifyContactsMailOnly() && !Contacts.getInstance(context).containsContact(message.getFrom())) { return false; } return true; } Loading
k9mail/src/main/java/com/fsck/k9/helper/Contacts.java +20 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,26 @@ public class Contacts { return result; } /** * Check whether one of the provided addresses belongs to one of the contacts. * * @param addresses The addresses to search in contacts * @return <tt>true</tt>, if one address belongs to a contact. * <tt>false</tt>, otherwise. */ public boolean containsContact(final Address[] addresses) { if (addresses == null) { return false; } for (Address addr : addresses) { if (isInContacts(addr.getAddress())) { return true; } } return false; } /** * Get the name of the contact an email address belongs to. * Loading
k9mail/src/main/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -532,6 +532,8 @@ Please submit bug reports, contribute new features and ask questions at <string name="account_settings_notify_sync_summary">Notify in status bar while mail is checked</string> <string name="account_settings_notify_self_label">Include outgoing mail</string> <string name="account_settings_notify_self_summary">Show a notification for messages I sent</string> <string name="account_notify_contacts_mail_only_label">Contacts only</string> <string name="account_notify_contacts_mail_only_summary">Show a notification only for messages of known contacts</string> <string name="account_settings_notification_opens_unread_label">Notification opens unread messages</string> <string name="account_settings_notification_opens_unread_summary">Searches for unread messages when Notification is opened</string> <string name="account_settings_mark_message_as_read_on_view_label">Mark as read when opened</string> Loading