mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 12:44:42 +00:00
Removed auto junk
This commit is contained in:
parent
c2c2d131c8
commit
7904267e9b
6 changed files with 13 additions and 76 deletions
|
@ -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;
|
||||
|
|
|
@ -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<EntityIdentity> 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<Address> 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -117,30 +117,6 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvMore" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbJunkAuto"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_junk_auto"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ibInfoFilter"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnEditRules" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvJunkAutoHint"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/title_junk_auto_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/cbJunkAuto" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbJunkFilter"
|
||||
android:layout_width="0dp"
|
||||
|
@ -150,7 +126,7 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ibInfoFilter"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvJunkAutoHint" />
|
||||
app:layout_constraintTop_toBottomOf="@id/btnEditRules" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
android:id="@+id/tvJunkFilterHint"
|
||||
|
@ -243,7 +219,7 @@
|
|||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="
|
||||
btnEditRules,
|
||||
cbJunkAuto,tvJunkAutoHint,cbJunkFilter,tvJunkFilterHint,ibInfoFilter,
|
||||
cbJunkFilter,tvJunkFilterHint,ibInfoFilter,
|
||||
cbBlocklist,tvBlocklist,tvBlocklistHint,ibInfoBlocklist" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</eu.faircode.email.ScrollViewEx>
|
|
@ -98,9 +98,7 @@
|
|||
Blocking a sender domain uses filter rules, which is a pro feature.
|
||||
</string>
|
||||
|
||||
<string name="title_junk_auto">Automatically block spam senders</string>
|
||||
<string name="title_junk_filter">Use local spam filter</string>
|
||||
<string name="title_junk_auto_hint">This will block senders of new messages in the spam folder</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>
|
||||
|
||||
|
|
Loading…
Reference in a new issue