Added option to use block list

This commit is contained in:
M66B 2021-06-20 09:04:12 +02:00
parent 44e4f0d473
commit 9ed29e58ca
6 changed files with 104 additions and 8 deletions

16
FAQ.md
View File

@ -300,6 +300,8 @@ Fonts, sizes, colors, etc should be material design whenever possible.
* [(164) Can you add customizable themes?](#user-content-faq164)
* [(165) Is Android Auto supported?](#user-content-faq165)
* [(166) Can I snooze a message across multiple devices?](#user-content-faq166)
* [(167) How can I use DeepL?](#user-content-faq168)
* [(168) What is a spam block list?](#user-content-faq167)
[I have another question.](#user-content-support)
@ -3714,6 +3716,20 @@ This feature requires an internet connection and is not available in the Play st
<br />
<a name="faq168"></a>
**(168) What is a spam block list?**
A spam block list is basically a list of domain names which have been used to send spam or to spread malware.
For more information, please see [this article](https://en.wikipedia.org/wiki/Domain_Name_System-based_blackhole_list).
FairEmail currently uses the following block lists:
* [Spamhaus zen](https://www.spamhaus.org/zen/) - [Terms of Use](https://www.spamhaus.org/organization/dnsblusage/)
* [Spamcop](https://www.spamcop.net/) - [Legal info](https://www.spamcop.net/fom-serve/cache/297.html)
<br />
<h2><a name="get-support"></a>Get support</h2>
FairEmail is supported on Android smartphones and tablets and ChromeOS only.

View File

@ -3367,6 +3367,21 @@ class Core {
}
runRules(context, imessage, account, folder, message, rules);
if (message.blocklist != null && message.blocklist) {
boolean use_blocklist = prefs.getBoolean("use_blocklist", false);
if (use_blocklist) {
EntityLog.log(context, "Block list" +
" folder=" + folder.name +
" message=" + message.id +
"@" + new Date(message.received) +
":" + message.subject);
EntityFolder junk = db.folder().getFolderByType(message.account, EntityFolder.JUNK);
if (junk != null)
EntityOperation.queue(context, message, EntityOperation.MOVE, junk.id, false);
}
}
if (download && !message.ui_hide &&
MessageClassifier.isEnabled(context) && folder.auto_classify_source)
db.message().setMessageUiHide(message.id, true); // keep local value

View File

@ -54,7 +54,8 @@ public class FragmentDialogJunk extends FragmentDialogBase {
final boolean inJunk = args.getBoolean("inJunk");
final boolean canBlock = args.getBoolean("canBlock");
View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_junk, null);
final Context context = getContext();
final View view = LayoutInflater.from(context).inflate(R.layout.dialog_junk, null);
final TextView tvMessage = view.findViewById(R.id.tvMessage);
final ImageButton ibInfoProvider = view.findViewById(R.id.ibInfoProvider);
final CheckBox cbBlockSender = view.findViewById(R.id.cbBlockSender);
@ -64,9 +65,15 @@ public class FragmentDialogJunk extends FragmentDialogBase {
final Button btnEditRules = view.findViewById(R.id.btnEditRules);
final CheckBox cbJunkFilter = view.findViewById(R.id.cbJunkFilter);
final ImageButton ibInfoFilter = view.findViewById(R.id.ibInfoFilter);
final CheckBox cbBlocklist = view.findViewById(R.id.cbBlocklist);
final ImageButton ibInfoBlocklist = view.findViewById(R.id.ibInfoBlocklist);
final Group grpInJunk = view.findViewById(R.id.grpInJunk);
final Group grpMore = view.findViewById(R.id.grpMore);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean check_blocklist = prefs.getBoolean("check_blocklist", false);
boolean use_blocklist = prefs.getBoolean("use_blocklist", false);
// Wire controls
ibInfoProvider.setOnClickListener(new View.OnClickListener() {
@ -119,7 +126,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
@Override
protected void onExecuted(Bundle args, EntityFolder inbox) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_EDIT_RULES)
.putExtra("account", account)
@ -135,7 +142,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
}
}.execute(FragmentDialogJunk.this, args, "junk:rules");
} else {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_EDIT_RULES)
.putExtra("account", account)
@ -208,13 +215,31 @@ public class FragmentDialogJunk extends FragmentDialogBase {
}
});
cbBlocklist.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
prefs.edit()
.putBoolean("check_blocklist", isChecked)
.putBoolean("use_blocklist", isChecked)
.apply();
}
});
ibInfoBlocklist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.viewFAQ(v.getContext(), 168, true);
}
});
// Initialize
tvMessage.setText(inJunk
? getString(R.string.title_folder_junk)
: getString(R.string.title_ask_spam_who, from));
cbBlockSender.setEnabled(canBlock && ActivityBilling.isPro(getContext()));
cbBlockSender.setEnabled(canBlock && ActivityBilling.isPro(context));
cbBlockDomain.setEnabled(false);
ibMore.setImageLevel(1);
cbBlocklist.setChecked(check_blocklist && use_blocklist);
grpInJunk.setVisibility(inJunk ? View.GONE : View.VISIBLE);
grpMore.setVisibility(inJunk ? View.VISIBLE : View.GONE);
@ -259,7 +284,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
}
}.execute(FragmentDialogJunk.this, args, "junk:filter");
AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setView(view)
.setNegativeButton(android.R.string.cancel, null);

View File

@ -96,7 +96,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
"enabled", "poll_interval", "auto_optimize", "schedule", "schedule_start", "schedule_end",
"sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "gmail_thread_id",
"sync_folders", "sync_shared_folders", "subscriptions",
"check_authentication", "check_reply_domain", "check_mx", "check_blocklist", "tune_keep_alive"
"check_authentication", "check_reply_domain", "check_mx", "check_blocklists", "tune_keep_alive"
};
@Override

View File

@ -150,6 +150,44 @@
app:layout_constraintTop_toTopOf="@id/cbJunkFilter"
app:srcCompat="@drawable/twotone_info_24" />
<CheckBox
android:id="@+id/cbBlocklist"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_junk_blocklist"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@+id/ibInfoFilter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvJunkFilterHint" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvBlocklistHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/title_advanced_sync_delay_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
android:textStyle="italic"
app:layout_constraintEnd_toStartOf="@+id/ibInfoFilter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbBlocklist" />
<ImageButton
android:id="@+id/ibInfoBlocklist"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_info"
android:padding="6dp"
android:scaleType="fitCenter"
android:tint="?attr/colorAccent"
android:tooltipText="@string/title_info"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/cbBlocklist"
app:srcCompat="@drawable/twotone_info_24" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpInJunk"
android:layout_width="0dp"
@ -164,6 +202,7 @@
android:layout_height="0dp"
app:constraint_referenced_ids="
btnEditRules,
cbJunkFilter,tvJunkFilterHint,ibInfoFilter" />
cbJunkFilter,tvJunkFilterHint,ibInfoFilter,
cbBlocklist,tvBlocklistHint,ibInfoBlocklist" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

View File

@ -99,6 +99,7 @@
<string name="title_junk_filter">Use local spam filter</string>
<string name="title_junk_filter_hint">This can increase battery usage and incorrectly mark messages as spam</string>
<string name="title_junk_blocklist">Use spam block lists</string>
<string name="title_notification_sending">Sending messages</string>
<string name="title_notification_waiting">Waiting for suitable connection</string>
@ -971,7 +972,7 @@
<string name="title_move_undo">Moving to %1$s (%2$d)</string>
<string name="title_open_with">Open with</string>
<string name="title_authentication_failed">%1$s authentication failed</string>
<string name="title_on_blocklist">On blocklist</string>
<string name="title_on_blocklist">On spam block list</string>
<string name="title_receipt_subject">Read receipt: %1$s</string>
<string name="title_receipt_text">This read receipt only acknowledges that the message was displayed. There is no guarantee that the recipient has read the message contents.</string>