mirror of https://github.com/M66B/FairEmail.git
Added blocklist names
This commit is contained in:
parent
f3f0584555
commit
b6c30f7e00
|
@ -34,8 +34,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public class DnsBlockList {
|
||||
static final List<BlockList> BLOCKLISTS = Collections.unmodifiableList(Arrays.asList(
|
||||
new BlockList("zen.spamhaus.org", new String[]{
|
||||
private static final List<BlockList> BLOCKLISTS = Collections.unmodifiableList(Arrays.asList(
|
||||
new BlockList("Spamhaus/zen", "zen.spamhaus.org", new String[]{
|
||||
//https://www.spamhaus.org/faq/section/DNSBL%20Usage#200
|
||||
"127.0.0.2", // SBL Spamhaus SBL Data
|
||||
"127.0.0.3", // SBL Spamhaus SBL CSS Data
|
||||
|
@ -44,7 +44,7 @@ public class DnsBlockList {
|
|||
//127.0.0.10 PBL ISP Maintained
|
||||
//127.0.0.11 PBL Spamhaus Maintained
|
||||
}),
|
||||
new BlockList("bl.spamcop.net", new String[]{
|
||||
new BlockList("Spamcop", "bl.spamcop.net", new String[]{
|
||||
// https://www.spamcop.net/fom-serve/cache/291.html
|
||||
"127.0.0.2"
|
||||
})
|
||||
|
@ -56,6 +56,13 @@ public class DnsBlockList {
|
|||
private static final long CACHE_EXPIRY_AFTER = 3600 * 1000L; // milliseconds
|
||||
private static final Map<String, CacheEntry> cache = new Hashtable<>();
|
||||
|
||||
static List<String> getNames() {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (BlockList blocklist : BLOCKLISTS)
|
||||
names.add(blocklist.name);
|
||||
return names;
|
||||
}
|
||||
|
||||
static boolean isJunk(String email) {
|
||||
if (TextUtils.isEmpty(email))
|
||||
return false;
|
||||
|
@ -175,10 +182,12 @@ public class DnsBlockList {
|
|||
}
|
||||
|
||||
static class BlockList {
|
||||
String name;
|
||||
String address;
|
||||
InetAddress[] responses;
|
||||
|
||||
BlockList(String address, String[] responses) {
|
||||
BlockList(String name, String address, String[] responses) {
|
||||
this.name = name;
|
||||
this.address = address;
|
||||
List<InetAddress> r = new ArrayList<>();
|
||||
for (String response : responses)
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
@ -66,6 +67,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
|
|||
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 TextView tvBlocklist = view.findViewById(R.id.tvBlocklist);
|
||||
final ImageButton ibInfoBlocklist = view.findViewById(R.id.ibInfoBlocklist);
|
||||
final Group grpInJunk = view.findViewById(R.id.grpInJunk);
|
||||
final Group grpMore = view.findViewById(R.id.grpMore);
|
||||
|
@ -243,6 +245,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
|
|||
cbBlockDomain.setEnabled(false);
|
||||
ibMore.setImageLevel(1);
|
||||
cbBlocklist.setChecked(check_blocklist && use_blocklist);
|
||||
tvBlocklist.setText(TextUtils.join(", ", DnsBlockList.getNames()));
|
||||
grpInJunk.setVisibility(inJunk ? View.GONE : View.VISIBLE);
|
||||
grpMore.setVisibility(inJunk ? View.VISIBLE : View.GONE);
|
||||
|
||||
|
|
|
@ -371,10 +371,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
}
|
||||
});
|
||||
|
||||
List<String> blocklists = new ArrayList<>();
|
||||
for (DnsBlockList.BlockList blocklist : DnsBlockList.BLOCKLISTS)
|
||||
blocklists.add(blocklist.address);
|
||||
tvCheckBlocklistHint.setText(TextUtils.join(", ", blocklists));
|
||||
tvCheckBlocklistHint.setText(TextUtils.join(", ", DnsBlockList.getNames()));
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
|
|
|
@ -161,6 +161,18 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvJunkFilterHint" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvBlocklist"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="blocklists"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
android:textStyle="italic"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbBlocklist" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvBlocklistHint"
|
||||
android:layout_width="0dp"
|
||||
|
@ -172,7 +184,7 @@
|
|||
android:textStyle="italic"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ibInfoFilter"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbBlocklist" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvBlocklist" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibInfoBlocklist"
|
||||
|
@ -203,6 +215,6 @@
|
|||
app:constraint_referenced_ids="
|
||||
btnEditRules,
|
||||
cbJunkFilter,tvJunkFilterHint,ibInfoFilter,
|
||||
cbBlocklist,tvBlocklistHint,ibInfoBlocklist" />
|
||||
cbBlocklist,tvBlocklist,tvBlocklistHint,ibInfoBlocklist" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.faircode.email.ScrollViewEx>
|
Loading…
Reference in New Issue