Added checking of reply addresses

This commit is contained in:
M66B
2020-01-11 09:21:43 +01:00
parent 89c7fb25ce
commit 295aeeb74f
5 changed files with 68 additions and 5 deletions

View File

@@ -2144,6 +2144,32 @@ class Core {
message.warning = Log.formatThrowable(ex, false);
}
boolean check_reply = prefs.getBoolean("check_reply", false);
if (check_reply &&
message.from != null && message.from.length > 0 &&
message.reply != null && message.reply.length > 0) {
for (Address reply : message.reply) {
String r = ((InternetAddress) reply).getAddress();
int rat = (r == null ? -1 : r.indexOf('@'));
if (rat > 0) {
String rdomain = r.substring(rat + 1);
for (Address from : message.from) {
String f = ((InternetAddress) from).getAddress();
int fat = (f == null ? -1 : f.indexOf('@'));
if (fat > 0) {
String fdomain = f.substring(fat + 1);
if (!rdomain.equalsIgnoreCase(fdomain)) {
if (message.warning == null)
message.warning = context.getString(R.string.title_reply_domain, fdomain, rdomain);
else
message.warning += ", " + context.getString(R.string.title_reply_domain, fdomain, rdomain);
}
}
}
}
}
}
if (message.total != null && message.total == 0)
reportEmptyMessage(context, account, istore);

View File

@@ -67,10 +67,12 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private TextView tvSubscriptionPro;
private SwitchCompat swSubscribedOnly;
private SwitchCompat swCheckMx;
private SwitchCompat swCheckReply;
private final static String[] RESET_OPTIONS = new String[]{
"enabled", "poll_interval", "schedule", "schedule_start", "schedule_end",
"sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "sync_folders", "subscriptions", "subscribed_only", "check_mx"
"sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "sync_folders", "subscriptions", "subscribed_only",
"check_mx", "check_reply"
};
@Override
@@ -107,6 +109,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
tvSubscriptionPro = view.findViewById(R.id.tvSubscriptionPro);
swSubscribedOnly = view.findViewById(R.id.swSubscribedOnly);
swCheckMx = view.findViewById(R.id.swCheckMx);
swCheckReply = view.findViewById(R.id.swCheckReply);
setOptions();
@@ -253,6 +256,13 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
}
});
swCheckReply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("check_reply", checked).apply();
}
});
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;
@@ -327,6 +337,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swSubscriptions.setEnabled(pro);
swSubscribedOnly.setChecked(prefs.getBoolean("subscribed_only", false));
swCheckMx.setChecked(prefs.getBoolean("check_mx", false));
swCheckReply.setChecked(prefs.getBoolean("check_reply", false));
}
private String formatHour(Context context, int minutes) {