diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java
index 8ef0e4b3f2..5368795a84 100644
--- a/app/src/main/java/eu/faircode/email/ApplicationEx.java
+++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java
@@ -236,6 +236,13 @@ public class ApplicationEx extends Application {
editor.putBoolean("move_1_confirmed", automove);
editor.remove("automove");
}
+ } else if (version < 972) {
+ if (prefs.contains("signature_end")) {
+ boolean signature_end = prefs.getBoolean("signature_end", false);
+ if (signature_end)
+ editor.putInt("signature_location", 2);
+ editor.remove("signature_end");
+ }
}
if (BuildConfig.DEBUG && false) {
diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java
index 9ac660b3ea..0a73af4a31 100644
--- a/app/src/main/java/eu/faircode/email/FragmentCompose.java
+++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java
@@ -3264,16 +3264,11 @@ public class FragmentCompose extends FragmentBase {
EntityIdentity identity = null;
if (data.draft.identity != null)
identity = db.identity().getIdentity(data.draft.identity);
- boolean signature_end = prefs.getBoolean("signature_end", false);
-
- if (!signature_end && identity != null)
- addSignature(context, document, data.draft, identity);
for (Element e : ref)
document.body().appendChild(e);
- if (signature_end && identity != null)
- addSignature(context, document, data.draft, identity);
+ addSignature(context, document, data.draft, identity);
String html = JsoupEx.parse(document.html()).html();
Helper.writeText(file, html);
@@ -3670,22 +3665,16 @@ public class FragmentCompose extends FragmentBase {
(extras != null && extras.containsKey("html"))) {
dirty = true;
- boolean signature_end = prefs.getBoolean("signature_end", false);
-
// Get saved body
Document d;
if (extras != null && extras.containsKey("html")) {
// Save current revision
Document c = JsoupEx.parse(body);
- if (!signature_end)
- addSignature(context, c, draft, identity);
-
for (Element e : ref)
c.body().appendChild(e);
- if (signature_end)
- addSignature(context, c, draft, identity);
+ addSignature(context, c, draft, identity);
Helper.writeText(draft.getFile(context, draft.revision), c.html());
@@ -3693,14 +3682,10 @@ public class FragmentCompose extends FragmentBase {
} else {
d = JsoupEx.parse(body);
- if (!signature_end)
- addSignature(context, d, draft, identity);
-
for (Element e : ref)
d.body().appendChild(e);
- if (signature_end)
- addSignature(context, d, draft, identity);
+ addSignature(context, d, draft, identity);
}
body = d.html();
@@ -4007,11 +3992,13 @@ public class FragmentCompose extends FragmentBase {
identity == null || TextUtils.isEmpty(identity.signature))
return;
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ int signature_location = prefs.getInt("signature_location", 1);
+ boolean usenet = prefs.getBoolean("usenet_signature", false);
+
Element div = document.createElement("div");
div.attr("fairemail", "signature");
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- boolean usenet = prefs.getBoolean("usenet_signature", false);
if (usenet) {
// https://www.ietf.org/rfc/rfc3676.txt
Element span = document.createElement("span");
@@ -4021,7 +4008,14 @@ public class FragmentCompose extends FragmentBase {
}
div.append(identity.signature);
- document.body().appendChild(div);
+
+ Elements ref = document.select("div[fairemail=reference]");
+ if (signature_location == 0)
+ document.body().prependChild(div);
+ else if (ref.size() == 0 || signature_location == 2)
+ document.body().appendChild(div);
+ else if (signature_location == 1)
+ ref.first().before(div);
}
private void showDraft(final EntityMessage draft) {
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java
index b5fa5cc101..d31f28538a 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java
@@ -51,7 +51,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swExtendedReply;
private SwitchCompat swQuoteReply;
private SwitchCompat swPlainOnly;
- private SwitchCompat swSignatureEnd;
+ private Spinner spSignatureLocation;
private SwitchCompat swUsenetSignature;
private SwitchCompat swRemoveSignatures;
private SwitchCompat swResizeImages;
@@ -65,8 +65,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private final static String[] RESET_OPTIONS = new String[]{
"keyboard", "suggest_sent", "suggested_received",
- "prefix_once", "extended_reply", "quote_reply", "signature_end",
- "plain_only", "usenet_signature", "remove_signatures",
+ "prefix_once", "extended_reply", "quote_reply",
+ "plain_only", "signature_location", "usenet_signature", "remove_signatures",
"resize_images", "resize_attachments", "send_reminders", "receipt_default", "resize", "lookup_mx", "send_delayed"
};
@@ -88,7 +88,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swExtendedReply = view.findViewById(R.id.swExtendedReply);
swQuoteReply = view.findViewById(R.id.swQuoteReply);
swPlainOnly = view.findViewById(R.id.swPlainOnly);
- swSignatureEnd = view.findViewById(R.id.swSignatureEnd);
+ spSignatureLocation = view.findViewById(R.id.spSignatureLocation);
swUsenetSignature = view.findViewById(R.id.swUsenetSignature);
swRemoveSignatures = view.findViewById(R.id.swRemoveSignatures);
swResizeImages = view.findViewById(R.id.swResizeImages);
@@ -163,10 +163,15 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
- swSignatureEnd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ spSignatureLocation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
- prefs.edit().putBoolean("signature_end", checked).apply();
+ public void onItemSelected(AdapterView> adapterView, View view, int position, long id) {
+ prefs.edit().putInt("signature_location", position).apply();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ prefs.edit().remove("signature_location").apply();
}
});
@@ -301,7 +306,10 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swExtendedReply.setChecked(prefs.getBoolean("extended_reply", false));
swQuoteReply.setChecked(prefs.getBoolean("quote_reply", true));
swPlainOnly.setChecked(prefs.getBoolean("plain_only", false));
- swSignatureEnd.setChecked(prefs.getBoolean("signature_end", false));
+
+ int signature_location = prefs.getInt("signature_location", 1);
+ spSignatureLocation.setSelection(signature_location);
+
swUsenetSignature.setChecked(prefs.getBoolean("usenet_signature", false));
swRemoveSignatures.setChecked(prefs.getBoolean("remove_signatures", false));
diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml
index 220fe43356..f6ca23bc99 100644
--- a/app/src/main/res/layout/fragment_options_send.xml
+++ b/app/src/main/res/layout/fragment_options_send.xml
@@ -130,16 +130,27 @@
app:layout_constraintTop_toBottomOf="@id/swQuoteReply"
app:switchPadding="12dp" />
-
+ app:layout_constraintTop_toBottomOf="@id/swPlainOnly" />
+
+