new option: just show notification for contacts
This commit is contained in:
parent
2ccbf581ab
commit
e2e3da262c
6 changed files with 54 additions and 0 deletions
|
@ -181,6 +181,7 @@ public class Account implements BaseAccount, StoreConfig {
|
||||||
private boolean mNotifyNewMail;
|
private boolean mNotifyNewMail;
|
||||||
private FolderMode mFolderNotifyNewMailMode;
|
private FolderMode mFolderNotifyNewMailMode;
|
||||||
private boolean mNotifySelfNewMail;
|
private boolean mNotifySelfNewMail;
|
||||||
|
private boolean mNotifyContactsMailOnly;
|
||||||
private String mInboxFolderName;
|
private String mInboxFolderName;
|
||||||
private String mDraftsFolderName;
|
private String mDraftsFolderName;
|
||||||
private String mSentFolderName;
|
private String mSentFolderName;
|
||||||
|
@ -289,6 +290,7 @@ public class Account implements BaseAccount, StoreConfig {
|
||||||
mFolderNotifyNewMailMode = FolderMode.ALL;
|
mFolderNotifyNewMailMode = FolderMode.ALL;
|
||||||
mNotifySync = true;
|
mNotifySync = true;
|
||||||
mNotifySelfNewMail = true;
|
mNotifySelfNewMail = true;
|
||||||
|
mNotifyContactsMailOnly = false;
|
||||||
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
||||||
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
mFolderSyncMode = FolderMode.FIRST_CLASS;
|
||||||
mFolderPushMode = FolderMode.FIRST_CLASS;
|
mFolderPushMode = FolderMode.FIRST_CLASS;
|
||||||
|
@ -397,6 +399,7 @@ public class Account implements BaseAccount, StoreConfig {
|
||||||
|
|
||||||
mFolderNotifyNewMailMode = getEnumStringPref(storage, mUuid + ".folderNotifyNewMailMode", FolderMode.ALL);
|
mFolderNotifyNewMailMode = getEnumStringPref(storage, mUuid + ".folderNotifyNewMailMode", FolderMode.ALL);
|
||||||
mNotifySelfNewMail = storage.getBoolean(mUuid + ".notifySelfNewMail", true);
|
mNotifySelfNewMail = storage.getBoolean(mUuid + ".notifySelfNewMail", true);
|
||||||
|
mNotifyContactsMailOnly = storage.getBoolean(mUuid + ".notifyContactsMailOnly", false);
|
||||||
mNotifySync = storage.getBoolean(mUuid + ".notifyMailCheck", false);
|
mNotifySync = storage.getBoolean(mUuid + ".notifyMailCheck", false);
|
||||||
mDeletePolicy = DeletePolicy.fromInt(storage.getInt(mUuid + ".deletePolicy", DeletePolicy.NEVER.setting));
|
mDeletePolicy = DeletePolicy.fromInt(storage.getInt(mUuid + ".deletePolicy", DeletePolicy.NEVER.setting));
|
||||||
mInboxFolderName = storage.getString(mUuid + ".inboxFolderName", INBOX);
|
mInboxFolderName = storage.getString(mUuid + ".inboxFolderName", INBOX);
|
||||||
|
@ -684,6 +687,7 @@ public class Account implements BaseAccount, StoreConfig {
|
||||||
editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail);
|
editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail);
|
||||||
editor.putString(mUuid + ".folderNotifyNewMailMode", mFolderNotifyNewMailMode.name());
|
editor.putString(mUuid + ".folderNotifyNewMailMode", mFolderNotifyNewMailMode.name());
|
||||||
editor.putBoolean(mUuid + ".notifySelfNewMail", mNotifySelfNewMail);
|
editor.putBoolean(mUuid + ".notifySelfNewMail", mNotifySelfNewMail);
|
||||||
|
editor.putBoolean(mUuid + ".notifyContactsMailOnly", mNotifyContactsMailOnly);
|
||||||
editor.putBoolean(mUuid + ".notifyMailCheck", mNotifySync);
|
editor.putBoolean(mUuid + ".notifyMailCheck", mNotifySync);
|
||||||
editor.putInt(mUuid + ".deletePolicy", mDeletePolicy.setting);
|
editor.putInt(mUuid + ".deletePolicy", mDeletePolicy.setting);
|
||||||
editor.putString(mUuid + ".inboxFolderName", mInboxFolderName);
|
editor.putString(mUuid + ".inboxFolderName", mInboxFolderName);
|
||||||
|
@ -1252,6 +1256,14 @@ public class Account implements BaseAccount, StoreConfig {
|
||||||
mNotifySelfNewMail = notifySelfNewMail;
|
mNotifySelfNewMail = notifySelfNewMail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isNotifyContactsMailOnly() {
|
||||||
|
return mNotifyContactsMailOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void setNotifyContactsMailOnly(boolean notifyContactsMailOnly) {
|
||||||
|
this.mNotifyContactsMailOnly = notifyContactsMailOnly;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized Expunge getExpungePolicy() {
|
public synchronized Expunge getExpungePolicy() {
|
||||||
return mExpungePolicy;
|
return mExpungePolicy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||||
private static final String PREFERENCE_NOTIFY = "account_notify";
|
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_NEW_MAIL_MODE = "folder_notify_new_mail_mode";
|
||||||
private static final String PREFERENCE_NOTIFY_SELF = "account_notify_self";
|
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_NOTIFY_SYNC = "account_notify_sync";
|
||||||
private static final String PREFERENCE_VIBRATE = "account_vibrate";
|
private static final String PREFERENCE_VIBRATE = "account_vibrate";
|
||||||
private static final String PREFERENCE_VIBRATE_PATTERN = "account_vibrate_pattern";
|
private static final String PREFERENCE_VIBRATE_PATTERN = "account_vibrate_pattern";
|
||||||
|
@ -146,6 +147,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||||
private CheckBoxPreference mAccountNotify;
|
private CheckBoxPreference mAccountNotify;
|
||||||
private ListPreference mAccountNotifyNewMailMode;
|
private ListPreference mAccountNotifyNewMailMode;
|
||||||
private CheckBoxPreference mAccountNotifySelf;
|
private CheckBoxPreference mAccountNotifySelf;
|
||||||
|
private CheckBoxPreference mAccountNotifyContactsMailOnly;
|
||||||
private ListPreference mAccountShowPictures;
|
private ListPreference mAccountShowPictures;
|
||||||
private CheckBoxPreference mAccountNotifySync;
|
private CheckBoxPreference mAccountNotifySync;
|
||||||
private CheckBoxPreference mAccountVibrate;
|
private CheckBoxPreference mAccountVibrate;
|
||||||
|
@ -590,6 +592,9 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||||
mAccountNotifySelf = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_SELF);
|
mAccountNotifySelf = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_SELF);
|
||||||
mAccountNotifySelf.setChecked(mAccount.isNotifySelfNewMail());
|
mAccountNotifySelf.setChecked(mAccount.isNotifySelfNewMail());
|
||||||
|
|
||||||
|
mAccountNotifyContactsMailOnly = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_CONTACTS_MAIL_ONLY);
|
||||||
|
mAccountNotifyContactsMailOnly.setChecked(mAccount.isNotifyContactsMailOnly());
|
||||||
|
|
||||||
mAccountNotifySync = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_SYNC);
|
mAccountNotifySync = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_SYNC);
|
||||||
mAccountNotifySync.setChecked(mAccount.isShowOngoing());
|
mAccountNotifySync.setChecked(mAccount.isShowOngoing());
|
||||||
|
|
||||||
|
@ -753,6 +758,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
||||||
mAccount.setNotifyNewMail(mAccountNotify.isChecked());
|
mAccount.setNotifyNewMail(mAccountNotify.isChecked());
|
||||||
mAccount.setFolderNotifyNewMailMode(FolderMode.valueOf(mAccountNotifyNewMailMode.getValue()));
|
mAccount.setFolderNotifyNewMailMode(FolderMode.valueOf(mAccountNotifyNewMailMode.getValue()));
|
||||||
mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked());
|
mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked());
|
||||||
|
mAccount.setNotifyContactsMailOnly(mAccountNotifyContactsMailOnly.isChecked());
|
||||||
mAccount.setShowOngoing(mAccountNotifySync.isChecked());
|
mAccount.setShowOngoing(mAccountNotifySync.isChecked());
|
||||||
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
|
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
|
||||||
mAccount.setMaximumAutoDownloadMessageSize(Integer.parseInt(mMessageSize.getValue()));
|
mAccount.setMaximumAutoDownloadMessageSize(Integer.parseInt(mMessageSize.getValue()));
|
||||||
|
|
|
@ -40,6 +40,7 @@ import android.os.Build;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
import android.provider.ContactsContract;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import android.support.annotation.VisibleForTesting;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ import com.fsck.k9.R;
|
||||||
import com.fsck.k9.activity.MessageReference;
|
import com.fsck.k9.activity.MessageReference;
|
||||||
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
||||||
import com.fsck.k9.cache.EmailProviderCache;
|
import com.fsck.k9.cache.EmailProviderCache;
|
||||||
|
import com.fsck.k9.helper.Contacts;
|
||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
import com.fsck.k9.mail.AuthenticationFailedException;
|
import com.fsck.k9.mail.AuthenticationFailedException;
|
||||||
import com.fsck.k9.mail.CertificateValidationException;
|
import com.fsck.k9.mail.CertificateValidationException;
|
||||||
|
@ -4313,6 +4315,10 @@ public class MessagingController implements Runnable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (account.isNotifyContactsMailOnly() && !Contacts.getInstance(context).containsContact(message.getFrom())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,26 @@ public class Contacts {
|
||||||
return result;
|
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.
|
* Get the name of the contact an email address belongs to.
|
||||||
*
|
*
|
||||||
|
|
|
@ -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_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_label">Include outgoing mail</string>
|
||||||
<string name="account_settings_notify_self_summary">Show a notification for messages I sent</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_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_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>
|
<string name="account_settings_mark_message_as_read_on_view_label">Mark as read when opened</string>
|
||||||
|
|
|
@ -360,6 +360,14 @@
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:summary="@string/account_settings_notify_self_summary" />
|
android:summary="@string/account_settings_notify_self_summary" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:persistent="false"
|
||||||
|
android:key="account_notify_contacts_mail_only"
|
||||||
|
android:dependency="account_notify"
|
||||||
|
android:title="@string/account_notify_contacts_mail_only_label"
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:summary="@string/account_notify_contacts_mail_only_summary" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
We can't disable persisting the ringtone value to SharedPreferences
|
We can't disable persisting the ringtone value to SharedPreferences
|
||||||
because it's needed to actually access the value.
|
because it's needed to actually access the value.
|
||||||
|
|
Loading…
Reference in a new issue