Added option to disable auto blocking junk senders

pull/212/head
M66B 2 years ago
parent b93b192762
commit ffcfb16227

@ -211,6 +211,7 @@ public class EntityOperation {
boolean autounflag = prefs.getBoolean("autounflag", false); boolean autounflag = prefs.getBoolean("autounflag", false);
boolean reset_importance = prefs.getBoolean("reset_importance", false); boolean reset_importance = prefs.getBoolean("reset_importance", false);
boolean reset_snooze = prefs.getBoolean("reset_snooze", true); boolean reset_snooze = prefs.getBoolean("reset_snooze", true);
boolean auto_block_sender = prefs.getBoolean("auto_block_sender", true);
if (jargs.opt(1) != null) { if (jargs.opt(1) != null) {
// rules, classify // rules, classify
@ -230,16 +231,19 @@ public class EntityOperation {
return; return;
if (EntityFolder.JUNK.equals(target.type) && if (EntityFolder.JUNK.equals(target.type) &&
Objects.equals(source.account, target.account) && Objects.equals(source.account, target.account)) {
(jargs.opt(3) == null || !jargs.optBoolean(3))) { Boolean noblock = (Boolean) jargs.opt(3);
jargs.remove(3); jargs.remove(3);
// Prevent blocking self boolean block = (noblock == null ? auto_block_sender : !noblock);
List<TupleIdentityEx> identities = db.identity().getComposableIdentities(null); if (block) {
if (!message.fromSelf(identities)) { // Prevent blocking self
EntityLog.log(context, "Auto block sender=" + MessageHelper.formatAddresses(message.from)); List<TupleIdentityEx> identities = db.identity().getComposableIdentities(null);
EntityContact.update(context, if (!message.fromSelf(identities)) {
message.account, message.identity, message.from, EntityLog.log(context, "Auto block sender=" + MessageHelper.formatAddresses(message.from));
EntityContact.TYPE_JUNK, message.received); EntityContact.update(context,
message.account, message.identity, message.from,
EntityContact.TYPE_JUNK, message.received);
}
} }
} }

@ -100,6 +100,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swAutoImportant; private SwitchCompat swAutoImportant;
private SwitchCompat swResetImportance; private SwitchCompat swResetImportance;
private SwitchCompat swResetSnooze; private SwitchCompat swResetSnooze;
private SwitchCompat swAutoBlockSender;
private SwitchCompat swSwipeReply; private SwitchCompat swSwipeReply;
final static int MAX_SWIPE_SENSITIVITY = 10; final static int MAX_SWIPE_SENSITIVITY = 10;
@ -113,7 +114,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
"autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple", "autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple",
"autoclose", "onclose", "autoclose_unseen", "collapse_marked", "autoclose", "onclose", "autoclose_unseen", "collapse_marked",
"undo_timeout", "undo_timeout",
"autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance", "reset_snooze", "autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance", "reset_snooze", "auto_block_sender",
"swipe_reply" "swipe_reply"
}; };
@ -169,6 +170,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoImportant = view.findViewById(R.id.swAutoImportant); swAutoImportant = view.findViewById(R.id.swAutoImportant);
swResetImportance = view.findViewById(R.id.swResetImportance); swResetImportance = view.findViewById(R.id.swResetImportance);
swResetSnooze = view.findViewById(R.id.swResetSnooze); swResetSnooze = view.findViewById(R.id.swResetSnooze);
swAutoBlockSender = view.findViewById(R.id.swAutoBlockSender);
swSwipeReply = view.findViewById(R.id.swSwipeReply); swSwipeReply = view.findViewById(R.id.swSwipeReply);
setOptions(); setOptions();
@ -514,6 +516,12 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
} }
}); });
swAutoBlockSender.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("auto_block_sender", checked).apply();
}
});
swSwipeReply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swSwipeReply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
@ -635,6 +643,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoImportant.setChecked(prefs.getBoolean("auto_important", false)); swAutoImportant.setChecked(prefs.getBoolean("auto_important", false));
swResetImportance.setChecked(prefs.getBoolean("reset_importance", false)); swResetImportance.setChecked(prefs.getBoolean("reset_importance", false));
swResetSnooze.setChecked(prefs.getBoolean("reset_snooze", true)); swResetSnooze.setChecked(prefs.getBoolean("reset_snooze", true));
swAutoBlockSender.setChecked(prefs.getBoolean("auto_block_sender", true));
swSwipeReply.setChecked(prefs.getBoolean("swipe_reply", false)); swSwipeReply.setChecked(prefs.getBoolean("swipe_reply", false));
} }

@ -723,6 +723,18 @@
app:layout_constraintTop_toBottomOf="@id/swResetImportance" app:layout_constraintTop_toBottomOf="@id/swResetImportance"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoBlockSender"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_auto_block_sender"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swResetSnooze"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSwipeReply" android:id="@+id/swSwipeReply"
android:layout_width="0dp" android:layout_width="0dp"
@ -731,7 +743,7 @@
android:text="@string/title_advanced_swipe_reply" android:text="@string/title_advanced_swipe_reply"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swResetSnooze" app:layout_constraintTop_toBottomOf="@id/swAutoBlockSender"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

@ -650,6 +650,7 @@
<string name="title_advanced_auto_important">Automatically make starred messages important</string> <string name="title_advanced_auto_important">Automatically make starred messages important</string>
<string name="title_advanced_reset_importance">Reset importance on moving messages</string> <string name="title_advanced_reset_importance">Reset importance on moving messages</string>
<string name="title_advanced_cancel_snooze">Cancel snooze on moving messages</string> <string name="title_advanced_cancel_snooze">Cancel snooze on moving messages</string>
<string name="title_advanced_auto_block_sender">Automatically block the sender when reporting spam</string>
<string name="title_advanced_swipe_reply">Swipe expanded messages to the right to reply</string> <string name="title_advanced_swipe_reply">Swipe expanded messages to the right to reply</string>
<string name="title_advanced_default_snooze">Default snooze/delay time</string> <string name="title_advanced_default_snooze">Default snooze/delay time</string>

Loading…
Cancel
Save