Added auto block junk senders

This commit is contained in:
M66B
2021-09-18 18:15:44 +02:00
parent 4d4a5acb33
commit 00fad2ba34
8 changed files with 150 additions and 63 deletions

View File

@@ -64,6 +64,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
final ImageButton ibMore = view.findViewById(R.id.ibMore);
final TextView tvMore = view.findViewById(R.id.tvMore);
final Button btnEditRules = view.findViewById(R.id.btnEditRules);
final CheckBox cbJunkAuto = view.findViewById(R.id.cbJunkAuto);
final CheckBox cbJunkFilter = view.findViewById(R.id.cbJunkFilter);
final ImageButton ibInfoFilter = view.findViewById(R.id.ibInfoFilter);
final CheckBox cbBlocklist = view.findViewById(R.id.cbBlocklist);
@@ -73,6 +74,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
final Group grpMore = view.findViewById(R.id.grpMore);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean auto_junk = prefs.getBoolean("auto_junk", false);
boolean check_blocklist = prefs.getBoolean("check_blocklist", false);
boolean use_blocklist = prefs.getBoolean("use_blocklist", false);
@@ -88,7 +90,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
cbBlockSender.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cbBlockDomain.setEnabled(isChecked);
cbBlockDomain.setEnabled(isChecked && ActivityBilling.isPro(context));
}
});
@@ -156,6 +158,13 @@ public class FragmentDialogJunk extends FragmentDialogBase {
}
});
cbJunkAuto.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit().putBoolean("auto_junk", isChecked).apply();
}
});
cbJunkFilter.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -241,9 +250,10 @@ public class FragmentDialogJunk extends FragmentDialogBase {
tvMessage.setText(inJunk
? getString(R.string.title_folder_junk)
: getString(R.string.title_ask_spam_who, from));
cbBlockSender.setEnabled(canBlock && ActivityBilling.isPro(context));
cbBlockSender.setEnabled(canBlock);
cbBlockDomain.setEnabled(false);
ibMore.setImageLevel(1);
cbJunkAuto.setChecked(auto_junk);
cbBlocklist.setChecked(check_blocklist && use_blocklist);
tvBlocklist.setText(TextUtils.join(", ", DnsBlockList.getNamesEnabled(context)));
grpInJunk.setVisibility(inJunk ? View.GONE : View.VISIBLE);
@@ -256,7 +266,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
}
@Override
protected Boolean onExecute(Context context, Bundle args) throws Throwable {
protected Boolean onExecute(Context context, Bundle args) {
long aid = args.getLong("account");
long fid = args.getLong("folder");