From 7904267e9b7814cade33cf4639116d282bc97df7 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 18 Sep 2021 19:49:14 +0200 Subject: [PATCH] Removed auto junk --- app/src/main/java/eu/faircode/email/Core.java | 1 + .../java/eu/faircode/email/EntityContact.java | 44 +++++-------------- .../eu/faircode/email/FragmentDialogJunk.java | 10 ----- .../eu/faircode/email/FragmentMessages.java | 4 -- app/src/main/res/layout/dialog_junk.xml | 28 +----------- app/src/main/res/values/strings.xml | 2 - 6 files changed, 13 insertions(+), 76 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 7a08dd189f..c9902e1079 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -4021,6 +4021,7 @@ class Core { EntityFolder junk = db.folder().getFolderByType(message.account, EntityFolder.JUNK); if (junk != null) { EntityOperation.queue(context, message, EntityOperation.MOVE, junk.id); + message.ui_hide = true; executed = true; } break; diff --git a/app/src/main/java/eu/faircode/email/EntityContact.java b/app/src/main/java/eu/faircode/email/EntityContact.java index f2af794b0b..3d4cb1e0df 100644 --- a/app/src/main/java/eu/faircode/email/EntityContact.java +++ b/app/src/main/java/eu/faircode/email/EntityContact.java @@ -100,45 +100,36 @@ public class EntityContact implements Serializable { @NonNull EntityAccount account, @NonNull EntityFolder folder, @NonNull EntityMessage message) { - if (!EntityFolder.JUNK.equals(folder.type)) { - int days = (folder.isOutgoing() ? folder.keep_days : folder.sync_days); - if (days == Integer.MAX_VALUE) - days = EntityFolder.DEFAULT_KEEP; - if (message.received < account.created - days * 24 * 3600 * 1000L) - return; - } + int days = (folder.isOutgoing() ? folder.keep_days : folder.sync_days); + if (days == Integer.MAX_VALUE) + days = EntityFolder.DEFAULT_KEEP; + if (message.received < account.created - days * 24 * 3600 * 1000L) + return; if (EntityFolder.DRAFTS.equals(folder.type) || EntityFolder.ARCHIVE.equals(folder.type) || - EntityFolder.TRASH.equals(folder.type)) + EntityFolder.TRASH.equals(folder.type) || + EntityFolder.JUNK.equals(folder.type)) return; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean suggest_sent = prefs.getBoolean("suggest_sent", true); boolean suggest_received = prefs.getBoolean("suggest_received", false); - boolean auto_junk = prefs.getBoolean("auto_junk", false); // Shortcut - if (!suggest_sent && !suggest_received && - !(EntityFolder.JUNK.equals(folder.type) && auto_junk)) + if (!suggest_sent && !suggest_received) return; - int type; - if (EntityFolder.JUNK.equals(folder.type)) - type = TYPE_JUNK; - else - type = (folder.isOutgoing() ? TYPE_TO : TYPE_FROM); + int type = (folder.isOutgoing() ? TYPE_TO : TYPE_FROM); // Check if from self - if (type == TYPE_FROM || type == TYPE_JUNK) { + if (type == TYPE_FROM) { if (message.from != null) { List identities = Core.getIdentities(folder.account, context); if (identities != null) { for (Address sender : message.from) { for (EntityIdentity identity : identities) if (identity.similarAddress(sender)) { - if (type == TYPE_JUNK) - return; type = TYPE_TO; break; } @@ -153,8 +144,6 @@ public class EntityContact implements Serializable { return; if (type == TYPE_FROM && !suggest_received) return; - if (type == TYPE_JUNK && !auto_junk) - return; List
addresses = new ArrayList<>(); if (type == TYPE_FROM) { @@ -168,19 +157,6 @@ public class EntityContact implements Serializable { addresses.addAll(Arrays.asList(message.to)); if (message.cc != null) addresses.addAll(Arrays.asList(message.cc)); - } else if (type == TYPE_JUNK) { - if (message.from != null) { - DB db = DB.getInstance(context); - for (Address from : message.from) { - String email = ((InternetAddress) from).getAddress(); - if (TextUtils.isEmpty(email)) - continue; - EntityContact nojunk = db.contact().getContact(message.account, TYPE_NO_JUNK, email); - if (nojunk != null) - return; - } - addresses.addAll(Arrays.asList(message.from)); - } } update(context, folder.account, addresses.toArray(new Address[0]), type, message.received); diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java b/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java index 40812c640b..b3106cd37b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogJunk.java @@ -64,7 +64,6 @@ 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); @@ -74,7 +73,6 @@ 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); @@ -158,13 +156,6 @@ 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) { @@ -253,7 +244,6 @@ public class FragmentDialogJunk extends FragmentDialogBase { 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); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 381c6cfbd4..c221148b09 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -7827,10 +7827,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (message == null) return null; - EntityAccount account = db.account().getAccount(message.account); - if (account == null) - return null; - EntityFolder junk = db.folder().getFolderByType(message.account, EntityFolder.JUNK); if (junk == null) throw new IllegalArgumentException(context.getString(R.string.title_no_junk_folder)); diff --git a/app/src/main/res/layout/dialog_junk.xml b/app/src/main/res/layout/dialog_junk.xml index 4bde9774e3..cf8b2748f6 100644 --- a/app/src/main/res/layout/dialog_junk.xml +++ b/app/src/main/res/layout/dialog_junk.xml @@ -117,30 +117,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvMore" /> - - - - + app:layout_constraintTop_toBottomOf="@id/btnEditRules" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f1fe23f6c2..40243f6267 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -98,9 +98,7 @@ Blocking a sender domain uses filter rules, which is a pro feature. - Automatically block spam senders Use local spam filter - This will block senders of new messages in the spam folder This can increase battery usage and incorrectly mark messages as spam Use spam block lists