Added checking of reply addresses

pull/172/head
M66B 5 years ago
parent 89c7fb25ce
commit 295aeeb74f

@ -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);

@ -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) {

@ -206,7 +206,7 @@
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvLookupMxHint"
android:id="@+id/tvCheckMxHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
@ -228,7 +228,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLookupMxHint" />
app:layout_constraintTop_toBottomOf="@id/tvCheckMxHint" />
<Spinner
android:id="@+id/spSendDelayed"

@ -373,7 +373,7 @@
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvLookupMxHint"
android:id="@+id/tvCheckMxHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
@ -395,6 +395,29 @@
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLookupMxHint" />
app:layout_constraintTop_toBottomOf="@id/tvCheckMxHint" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swCheckReply"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_check_reply"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvDelayHint"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvCheckReplyHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_check_reply_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swCheckReply" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

@ -391,6 +391,7 @@
<string name="title_advanced_poll_hint">Synchronizing periodically will compare local and remote messages each and every time, which is an expensive operation possibly resulting in extra battery usage, especially when there are a lot of messages to synchronize. Always synchronizing will avoid this by continuous monitoring for changes only.</string>
<string name="title_advanced_schedule_hint">Tap on a time to set a time</string>
<string name="title_advanced_check_mx">Check sender email addresses on synchronizing messages</string>
<string name="title_advanced_check_reply">Check reply email addresses on synchronizing messages</string>
<string name="title_advanced_unseen_hint">Some providers don\'t support this properly, which may cause synchronizing none or all messages</string>
<string name="title_advanced_sync_kept_hint">This will transfer extra data and consume extra battery power, especially if a lot of messages are stored on the device</string>
<string name="title_advanced_sync_folders_hint">Disabling this will reduce data and battery usage somewhat, but will disable updating the list of folders too</string>
@ -398,6 +399,7 @@
<string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled.</string>
<string name="title_advanced_lookup_mx_hint">This will check if DNS MX records exist</string>
<string name="title_advanced_check_reply_hint">This will check if domain name of the sender and reply addresses are the same</string>
<string name="title_advanced_metered_hint">Metered connections are generally mobile connections or paid Wi-Fi hotspots</string>
<string name="title_advanced_metered_warning">Disabling this option will disable receiving and sending messages on mobile internet connections</string>
@ -506,6 +508,7 @@
<string name="title_no_idle">This provider does not support push messages. This will delay reception of new messages and increase battery usage.</string>
<string name="title_no_utf8">This provider does not support UTF-8</string>
<string name="title_no_sync">Synchronization errors since %1$s</string>
<string name="title_reply_domain">The sender (%1$s) and reply domain (%2$s) differ</string>
<string name="title_identity_required">An identity is required to send messages</string>
<string name="title_drafts_required">A drafts folder is required to send messages</string>
<string name="title_account_delete">Delete this account permanently?</string>

Loading…
Cancel
Save