Added option to turn on legacy receipt request headers

This commit is contained in:
M66B 2022-01-26 08:19:01 +01:00
parent e93cba442d
commit 2e892022ca
4 changed files with 31 additions and 5 deletions

View File

@ -90,6 +90,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swRemoveSignatures;
private SwitchCompat swReceipt;
private Spinner spReceiptType;
private SwitchCompat swReceiptLegacy;
private SwitchCompat swLookupMx;
private final static String[] RESET_OPTIONS = new String[]{
@ -102,7 +103,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
"signature_location", "signature_new", "signature_reply", "signature_forward",
"discard_delete", "reply_move",
"auto_link", "plain_only", "format_flowed", "usenet_signature", "remove_signatures",
"receipt_default", "receipt_type", "lookup_mx"
"receipt_default", "receipt_type", "receipt_legacy", "lookup_mx"
};
@Override
@ -154,6 +155,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swRemoveSignatures = view.findViewById(R.id.swRemoveSignatures);
swReceipt = view.findViewById(R.id.swReceipt);
spReceiptType = view.findViewById(R.id.spReceiptType);
swReceiptLegacy = view.findViewById(R.id.swReceiptLegacy);
swLookupMx = view.findViewById(R.id.swLookupMx);
String[] fontNameNames = getResources().getStringArray(R.array.fontNameNames);
@ -474,6 +476,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
swReceiptLegacy.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("receipt_legacy", checked).apply();
}
});
swLookupMx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -598,6 +607,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
int receipt_type = prefs.getInt("receipt_type", 2);
spReceiptType.setSelection(receipt_type);
swReceiptLegacy.setChecked(prefs.getBoolean("receipt_legacy", false));
swLookupMx.setChecked(prefs.getBoolean("lookup_mx", false));
}
}

View File

@ -253,6 +253,7 @@ public class MessageHelper {
DB db = DB.getInstance(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int receipt_type = prefs.getInt("receipt_type", 2);
boolean receipt_legacy = prefs.getBoolean("receipt_legacy", false);
boolean hide_timezone = prefs.getBoolean("hide_timezone", true);
boolean autocrypt = prefs.getBoolean("autocrypt", true);
boolean mutual = prefs.getBoolean("autocrypt_mutual", true);
@ -449,9 +450,11 @@ public class MessageHelper {
// 2=Read+delivery receipt
// defacto standard
if (receipt_type == 1 || receipt_type == 2) // Delivery receipt
imessage.addHeader("Return-Receipt-To", to);
if (receipt_type == 1 || receipt_type == 2) {
// Delivery receipt
if (receipt_legacy)
imessage.addHeader("Return-Receipt-To", to);
}
// https://tools.ietf.org/html/rfc3798
if (receipt_type == 0 || receipt_type == 2) {

View File

@ -738,6 +738,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvReceiptType" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swReceiptLegacy"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_identity_receipt_legacy"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spReceiptType"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLookupMx"
android:layout_width="0dp"
@ -746,7 +757,7 @@
android:text="@string/title_advanced_lookup_mx"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spReceiptType"
app:layout_constraintTop_toBottomOf="@id/swReceiptLegacy"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView

View File

@ -839,6 +839,7 @@
<string name="title_identity_unicode_remark">Most servers do not support this</string>
<string name="title_identity_max_size">Maximum message size (MB)</string>
<string name="title_identity_receipt">Request delivery/read receipt by default</string>
<string name="title_identity_receipt_legacy">Use legacy receipt request headers</string>
<string name="title_identity_use_ip_hint">In case of \'invalid greeting\', \'requires valid address\' or a similar error, try to change this setting</string>
<string name="title_identity_self_hint">Also prevents you from replying to yourself</string>
<string name="title_optional">Optional</string>