Added option for signature location

pull/172/head
M66B 5 years ago
parent a680771bc3
commit 77e1f2ea83

@ -3178,9 +3178,9 @@ public class FragmentCompose extends FragmentBase {
File file = data.draft.getFile(context); File file = data.draft.getFile(context);
Document doc = JsoupEx.parse(Helper.readText(file)); Document doc = JsoupEx.parse(Helper.readText(file));
doc.select("div[fairemail=signature]").remove();
Elements ref = doc.select("div[fairemail=reference]"); Elements ref = doc.select("div[fairemail=reference]");
ref.remove(); ref.remove();
doc.select("div[fairemail=signature]").remove();
File refFile = data.draft.getRefFile(context); File refFile = data.draft.getRefFile(context);
if (refFile.exists()) { if (refFile.exists()) {
@ -3190,13 +3190,19 @@ public class FragmentCompose extends FragmentBase {
Document document = HtmlHelper.sanitize(context, doc.html(), true, false); Document document = HtmlHelper.sanitize(context, doc.html(), true, false);
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) for (Element e : ref)
document.body().appendChild(e); document.body().appendChild(e);
if (data.draft.identity != null) { if (signature_end && identity != null)
EntityIdentity identity = db.identity().getIdentity(data.draft.identity);
addSignature(context, document, data.draft, identity); addSignature(context, document, data.draft, identity);
}
String html = JsoupEx.parse(document.html()).html(); String html = JsoupEx.parse(document.html()).html();
Helper.writeText(file, html); Helper.writeText(file, html);
@ -3579,25 +3585,40 @@ public class FragmentCompose extends FragmentBase {
(extras != null && extras.containsKey("html"))) { (extras != null && extras.containsKey("html"))) {
dirty = true; dirty = true;
doc.select("div[fairemail=signature]").remove();
Elements ref = doc.select("div[fairemail=reference]"); Elements ref = doc.select("div[fairemail=reference]");
ref.remove(); ref.remove();
doc.select("div[fairemail=signature]").remove();
boolean signature_end = prefs.getBoolean("signature_end", false);
// Get saved body // Get saved body
Document d; Document d;
if (extras != null && extras.containsKey("html")) { if (extras != null && extras.containsKey("html")) {
// Save current revision // Save current revision
Document c = JsoupEx.parse(body); Document c = JsoupEx.parse(body);
if (!signature_end)
addSignature(context, c, draft, identity);
for (Element e : ref) for (Element e : ref)
c.body().appendChild(e); 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()); Helper.writeText(draft.getFile(context, draft.revision), c.html());
d = JsoupEx.parse(extras.getString("html")); d = JsoupEx.parse(extras.getString("html"));
} else { } else {
d = JsoupEx.parse(body); d = JsoupEx.parse(body);
if (!signature_end)
addSignature(context, d, draft, identity);
for (Element e : ref) for (Element e : ref)
d.body().appendChild(e); d.body().appendChild(e);
if (signature_end)
addSignature(context, d, draft, identity); addSignature(context, d, draft, identity);
} }
@ -3679,8 +3700,8 @@ public class FragmentCompose extends FragmentBase {
for (String text : Helper.getStrings(context, R.string.title_attachment_keywords)) for (String text : Helper.getStrings(context, R.string.title_attachment_keywords))
keywords.addAll(Arrays.asList(text.split(","))); keywords.addAll(Arrays.asList(text.split(",")));
d.select("div[fairemail=reference]").remove();
d.select("div[fairemail=signature]").remove(); d.select("div[fairemail=signature]").remove();
d.select("div[fairemail=reference]").remove();
String text = d.text(); String text = d.text();
for (String keyword : keywords) for (String keyword : keywords)
@ -3955,9 +3976,9 @@ public class FragmentCompose extends FragmentBase {
throw new IllegalArgumentException(context.getString(R.string.title_no_body)); throw new IllegalArgumentException(context.getString(R.string.title_no_body));
Document doc = JsoupEx.parse(Helper.readText(draft.getFile(context))); Document doc = JsoupEx.parse(Helper.readText(draft.getFile(context)));
doc.select("div[fairemail=signature]").remove();
Elements ref = doc.select("div[fairemail=reference]"); Elements ref = doc.select("div[fairemail=reference]");
ref.remove(); ref.remove();
doc.select("div[fairemail=signature]").remove();
Spanned spannedBody = HtmlHelper.fromHtml(doc.html(), new Html.ImageGetter() { Spanned spannedBody = HtmlHelper.fromHtml(doc.html(), new Html.ImageGetter() {
@Override @Override

@ -50,6 +50,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swPrefixOnce; private SwitchCompat swPrefixOnce;
private SwitchCompat swExtendedReply; private SwitchCompat swExtendedReply;
private SwitchCompat swQuoteReply; private SwitchCompat swQuoteReply;
private SwitchCompat swSignatureEnd;
private SwitchCompat swPlainOnly; private SwitchCompat swPlainOnly;
private SwitchCompat swUsenetSignature; private SwitchCompat swUsenetSignature;
private SwitchCompat swResizeImages; private SwitchCompat swResizeImages;
@ -63,7 +64,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"keyboard", "suggest_sent", "suggested_received", "keyboard", "suggest_sent", "suggested_received",
"prefix_once", "extended_reply", "quote_reply", "prefix_once", "extended_reply", "quote_reply", "signature_end",
"plain_only", "usenet_signature", "plain_only", "usenet_signature",
"resize_images", "resize_attachments", "send_reminders", "receipt_default", "resize", "lookup_mx", "send_delayed" "resize_images", "resize_attachments", "send_reminders", "receipt_default", "resize", "lookup_mx", "send_delayed"
}; };
@ -85,6 +86,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swPrefixOnce = view.findViewById(R.id.swPrefixOnce); swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swExtendedReply = view.findViewById(R.id.swExtendedReply); swExtendedReply = view.findViewById(R.id.swExtendedReply);
swQuoteReply = view.findViewById(R.id.swQuoteReply); swQuoteReply = view.findViewById(R.id.swQuoteReply);
swSignatureEnd = view.findViewById(R.id.swSignatureEnd);
swPlainOnly = view.findViewById(R.id.swPlainOnly); swPlainOnly = view.findViewById(R.id.swPlainOnly);
swUsenetSignature = view.findViewById(R.id.swUsenetSignature); swUsenetSignature = view.findViewById(R.id.swUsenetSignature);
swResizeImages = view.findViewById(R.id.swResizeImages); swResizeImages = view.findViewById(R.id.swResizeImages);
@ -152,6 +154,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
} }
}); });
swSignatureEnd.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("signature_end", checked).apply();
}
});
swPlainOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swPlainOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -282,6 +291,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", true)); swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", true));
swExtendedReply.setChecked(prefs.getBoolean("extended_reply", false)); swExtendedReply.setChecked(prefs.getBoolean("extended_reply", false));
swQuoteReply.setChecked(prefs.getBoolean("quote_reply", true)); swQuoteReply.setChecked(prefs.getBoolean("quote_reply", true));
swSignatureEnd.setChecked(prefs.getBoolean("signature_end", false));
swPlainOnly.setChecked(prefs.getBoolean("plain_only", false)); swPlainOnly.setChecked(prefs.getBoolean("plain_only", false));
swUsenetSignature.setChecked(prefs.getBoolean("usenet_signature", false)); swUsenetSignature.setChecked(prefs.getBoolean("usenet_signature", false));

@ -484,7 +484,7 @@ public class MessageHelper {
// When sending message // When sending message
if (identity != null) if (identity != null)
document.select("div[fairemail=reference],div[fairemail=signature]").removeAttr("fairemail"); document.select("div[fairemail=signature],div[fairemail=reference]").removeAttr("fairemail");
// multipart/mixed // multipart/mixed
// multipart/related // multipart/related

@ -119,6 +119,17 @@
app:layout_constraintTop_toBottomOf="@id/swExtendedReply" app:layout_constraintTop_toBottomOf="@id/swExtendedReply"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSignatureEnd"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_signature_end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swQuoteReply"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPlainOnly" android:id="@+id/swPlainOnly"
android:layout_width="0dp" android:layout_width="0dp"
@ -127,7 +138,7 @@
android:text="@string/title_advanced_plain_only" android:text="@string/title_advanced_plain_only"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swQuoteReply" app:layout_constraintTop_toBottomOf="@id/swSignatureEnd"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

@ -265,6 +265,7 @@
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string> <string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
<string name="title_advanced_extended_reply">Use extended reply/forward header</string> <string name="title_advanced_extended_reply">Use extended reply/forward header</string>
<string name="title_advanced_quote_reply">Quote replied text</string> <string name="title_advanced_quote_reply">Quote replied text</string>
<string name="title_advanced_signature_end">Add signature after quoted/forwarded message</string>
<string name="title_advanced_plain_only">Send plain text only by default</string> <string name="title_advanced_plain_only">Send plain text only by default</string>
<string name="title_advanced_usenet_signature">Usenet signature convention</string> <string name="title_advanced_usenet_signature">Usenet signature convention</string>
<string name="title_advanced_resize_images">Automatically resize embedded images</string> <string name="title_advanced_resize_images">Automatically resize embedded images</string>

Loading…
Cancel
Save