mirror of https://github.com/M66B/FairEmail.git
Refactoring
This commit is contained in:
parent
14b9d25a1e
commit
c45c1a42ee
|
@ -42,7 +42,7 @@ import java.util.Map;
|
|||
import javax.mail.internet.MimeUtility;
|
||||
|
||||
public class DnsBlockList {
|
||||
static final List<BlockList> BLOCK_LISTS = Collections.unmodifiableList(Arrays.asList(
|
||||
private static final List<BlockList> BLOCK_LISTS = Collections.unmodifiableList(Arrays.asList(
|
||||
// https://www.spamhaus.org/zen/
|
||||
new BlockList(true, "Spamhaus/zen", "zen.spamhaus.org", true, new String[]{
|
||||
// https://www.spamhaus.org/faq/section/DNSBL%20Usage#200
|
||||
|
@ -100,9 +100,10 @@ public class DnsBlockList {
|
|||
}
|
||||
|
||||
static boolean isEnabled(Context context, BlockList blocklist) {
|
||||
boolean def = (blocklist.enabled != null && blocklist.enabled);
|
||||
if (blocklist.enabled == null)
|
||||
return false;
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return prefs.getBoolean("blocklist." + blocklist.name, def);
|
||||
return prefs.getBoolean("blocklist." + blocklist.name, blocklist.enabled);
|
||||
}
|
||||
|
||||
static void reset(Context context) {
|
||||
|
@ -115,7 +116,7 @@ public class DnsBlockList {
|
|||
clearCache();
|
||||
}
|
||||
|
||||
static List<BlockList> getLists() {
|
||||
static List<BlockList> getListsAvailable() {
|
||||
List<BlockList> result = new ArrayList<>();
|
||||
for (BlockList blockList : BLOCK_LISTS)
|
||||
if (blockList.enabled != null)
|
||||
|
@ -123,7 +124,7 @@ public class DnsBlockList {
|
|||
return result;
|
||||
}
|
||||
|
||||
static List<String> getNames(Context context) {
|
||||
static List<String> getNamesEnabled(Context context) {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (BlockList blocklist : BLOCK_LISTS)
|
||||
if (isEnabled(context, blocklist))
|
||||
|
|
|
@ -245,7 +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(context)));
|
||||
tvBlocklist.setText(TextUtils.join(", ", DnsBlockList.getNamesEnabled(context)));
|
||||
grpInJunk.setVisibility(inJunk ? View.GONE : View.VISIBLE);
|
||||
grpMore.setVisibility(inJunk ? View.VISIBLE : View.GONE);
|
||||
|
||||
|
|
|
@ -356,7 +356,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
|
|||
|
||||
rvBlocklist.setHasFixedSize(false);
|
||||
rvBlocklist.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
AdapterBlocklist badapter = new AdapterBlocklist(getContext(), DnsBlockList.getLists());
|
||||
AdapterBlocklist badapter = new AdapterBlocklist(getContext(), DnsBlockList.getListsAvailable());
|
||||
rvBlocklist.setAdapter(badapter);
|
||||
|
||||
swTuneKeepAlive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
|
|
Loading…
Reference in New Issue