Added blocklist names

pull/199/head
M66B 4 years ago
parent f3f0584555
commit b6c30f7e00

@ -34,8 +34,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class DnsBlockList { public class DnsBlockList {
static final List<BlockList> BLOCKLISTS = Collections.unmodifiableList(Arrays.asList( private static final List<BlockList> BLOCKLISTS = Collections.unmodifiableList(Arrays.asList(
new BlockList("zen.spamhaus.org", new String[]{ new BlockList("Spamhaus/zen", "zen.spamhaus.org", new String[]{
//https://www.spamhaus.org/faq/section/DNSBL%20Usage#200 //https://www.spamhaus.org/faq/section/DNSBL%20Usage#200
"127.0.0.2", // SBL Spamhaus SBL Data "127.0.0.2", // SBL Spamhaus SBL Data
"127.0.0.3", // SBL Spamhaus SBL CSS 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.10 PBL ISP Maintained
//127.0.0.11 PBL Spamhaus 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 // https://www.spamcop.net/fom-serve/cache/291.html
"127.0.0.2" "127.0.0.2"
}) })
@ -56,6 +56,13 @@ public class DnsBlockList {
private static final long CACHE_EXPIRY_AFTER = 3600 * 1000L; // milliseconds private static final long CACHE_EXPIRY_AFTER = 3600 * 1000L; // milliseconds
private static final Map<String, CacheEntry> cache = new Hashtable<>(); 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) { static boolean isJunk(String email) {
if (TextUtils.isEmpty(email)) if (TextUtils.isEmpty(email))
return false; return false;
@ -175,10 +182,12 @@ public class DnsBlockList {
} }
static class BlockList { static class BlockList {
String name;
String address; String address;
InetAddress[] responses; InetAddress[] responses;
BlockList(String address, String[] responses) { BlockList(String name, String address, String[] responses) {
this.name = name;
this.address = address; this.address = address;
List<InetAddress> r = new ArrayList<>(); List<InetAddress> r = new ArrayList<>();
for (String response : responses) for (String response : responses)

@ -26,6 +26,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@ -66,6 +67,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
final CheckBox cbJunkFilter = view.findViewById(R.id.cbJunkFilter); final CheckBox cbJunkFilter = view.findViewById(R.id.cbJunkFilter);
final ImageButton ibInfoFilter = view.findViewById(R.id.ibInfoFilter); final ImageButton ibInfoFilter = view.findViewById(R.id.ibInfoFilter);
final CheckBox cbBlocklist = view.findViewById(R.id.cbBlocklist); 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 ImageButton ibInfoBlocklist = view.findViewById(R.id.ibInfoBlocklist);
final Group grpInJunk = view.findViewById(R.id.grpInJunk); final Group grpInJunk = view.findViewById(R.id.grpInJunk);
final Group grpMore = view.findViewById(R.id.grpMore); final Group grpMore = view.findViewById(R.id.grpMore);
@ -243,6 +245,7 @@ public class FragmentDialogJunk extends FragmentDialogBase {
cbBlockDomain.setEnabled(false); cbBlockDomain.setEnabled(false);
ibMore.setImageLevel(1); ibMore.setImageLevel(1);
cbBlocklist.setChecked(check_blocklist && use_blocklist); cbBlocklist.setChecked(check_blocklist && use_blocklist);
tvBlocklist.setText(TextUtils.join(", ", DnsBlockList.getNames()));
grpInJunk.setVisibility(inJunk ? View.GONE : View.VISIBLE); grpInJunk.setVisibility(inJunk ? View.GONE : View.VISIBLE);
grpMore.setVisibility(inJunk ? View.VISIBLE : View.GONE); grpMore.setVisibility(inJunk ? View.VISIBLE : View.GONE);

@ -371,10 +371,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
} }
}); });
List<String> blocklists = new ArrayList<>(); tvCheckBlocklistHint.setText(TextUtils.join(", ", DnsBlockList.getNames()));
for (DnsBlockList.BlockList blocklist : DnsBlockList.BLOCKLISTS)
blocklists.add(blocklist.address);
tvCheckBlocklistHint.setText(TextUtils.join(", ", blocklists));
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);

@ -161,6 +161,18 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvJunkFilterHint" /> 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 <eu.faircode.email.FixedTextView
android:id="@+id/tvBlocklistHint" android:id="@+id/tvBlocklistHint"
android:layout_width="0dp" android:layout_width="0dp"
@ -172,7 +184,7 @@
android:textStyle="italic" android:textStyle="italic"
app:layout_constraintEnd_toStartOf="@+id/ibInfoFilter" app:layout_constraintEnd_toStartOf="@+id/ibInfoFilter"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbBlocklist" /> app:layout_constraintTop_toBottomOf="@id/tvBlocklist" />
<ImageButton <ImageButton
android:id="@+id/ibInfoBlocklist" android:id="@+id/ibInfoBlocklist"
@ -203,6 +215,6 @@
app:constraint_referenced_ids=" app:constraint_referenced_ids="
btnEditRules, btnEditRules,
cbJunkFilter,tvJunkFilterHint,ibInfoFilter, cbJunkFilter,tvJunkFilterHint,ibInfoFilter,
cbBlocklist,tvBlocklistHint,ibInfoBlocklist" /> cbBlocklist,tvBlocklist,tvBlocklistHint,ibInfoBlocklist" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx> </eu.faircode.email.ScrollViewEx>
Loading…
Cancel
Save