Added option to show notifications for contacts only

pull/180/head
M66B 4 years ago
parent 1a175f5040
commit be8bc359a2

@ -1501,6 +1501,8 @@ class Core {
EntityAccount account, final EntityFolder folder,
POP3Folder ifolder, POP3Store istore, State state) throws MessagingException {
DB db = DB.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean notify_known = prefs.getBoolean("notify_known", false);
Log.i(folder.name + " POP sync type=" + folder.type + " connected=" + (ifolder != null));
@ -1641,6 +1643,8 @@ class Core {
message.sender = MessageHelper.getSortKey(message.from);
Uri lookupUri = ContactInfo.getLookupUri(message.from);
message.avatar = (lookupUri == null ? null : lookupUri.toString());
if (message.avatar == null && notify_known)
message.ui_ignored = true;
// No MX check
@ -2142,6 +2146,7 @@ class Core {
DB db = DB.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean notify_known = prefs.getBoolean("notify_known", false);
// Find message by uid (fast, no headers required)
EntityMessage message = db.message().getMessageByUid(folder.id, uid);
@ -2276,6 +2281,8 @@ class Core {
message.sender = MessageHelper.getSortKey(message.from);
Uri lookupUri = ContactInfo.getLookupUri(message.from);
message.avatar = (lookupUri == null ? null : lookupUri.toString());
if (message.avatar == null && notify_known)
message.ui_ignored = true;
boolean check_mx = prefs.getBoolean("check_mx", false);
if (check_mx)

@ -70,6 +70,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private SwitchCompat swBadge;
private SwitchCompat swUnseenIgnored;
private SwitchCompat swNotifyKnown;
private SwitchCompat swNotifySummary;
private SwitchCompat swNotifyRemove;
private SwitchCompat swNotifyClear;
@ -90,7 +91,8 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
"notify_flag", "notify_seen", "notify_snooze",
"light", "sound",
"badge", "unseen_ignored",
"notify_summary", "notify_remove", "notify_clear", "notify_preview", "notify_preview_all", "wearable_preview",
"notify_known", "notify_summary", "notify_remove", "notify_clear",
"notify_preview", "notify_preview_all", "wearable_preview",
"biometrics_notify",
"alert_once"
};
@ -126,6 +128,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swBadge = view.findViewById(R.id.swBadge);
swUnseenIgnored = view.findViewById(R.id.swUnseenIgnored);
swNotifyKnown = view.findViewById(R.id.swNotifyKnown);
swNotifySummary = view.findViewById(R.id.swNotifySummary);
swNotifyRemove = view.findViewById(R.id.swNotifyRemove);
swNotifyClear = view.findViewById(R.id.swNotifyClear);
@ -300,6 +303,14 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
swNotifyKnown.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_known", checked).apply();
enableOptions();
}
});
swNotifySummary.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -434,6 +445,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swBadge.setChecked(prefs.getBoolean("badge", true));
swUnseenIgnored.setChecked(prefs.getBoolean("unseen_ignored", false));
swNotifyKnown.setChecked(prefs.getBoolean("notify_known", false));
swNotifySummary.setChecked(prefs.getBoolean("notify_summary", false));
swNotifyRemove.setChecked(prefs.getBoolean("notify_remove", true));
swNotifyClear.setChecked(prefs.getBoolean("notify_clear", false));

@ -327,6 +327,17 @@
app:layout_constraintTop_toBottomOf="@id/tvBadgeHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyKnown"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_notify_known"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swUnseenIgnored"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifySummary"
android:layout_width="0dp"
@ -335,7 +346,7 @@
android:text="@string/title_advanced_notify_summary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swUnseenIgnored"
app:layout_constraintTop_toBottomOf="@id/swNotifyKnown"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -394,6 +394,7 @@
<string name="title_advanced_badge">Show launcher icon with number of new messages</string>
<string name="title_advanced_unseen_ignored">Let the number of new messages match the number of notifications</string>
<string name="title_advanced_notify_known">Show notifications for contacts only</string>
<string name="title_advanced_notify_summary">Show summary notification only</string>
<string name="title_advanced_notify_preview">Show message preview in notifications</string>
<string name="title_advanced_notify_preview_all">Preview all text</string>

Loading…
Cancel
Save