Added option for signature location

This commit is contained in:
M66B
2020-01-27 19:19:25 +01:00
parent a680771bc3
commit 77e1f2ea83
5 changed files with 55 additions and 12 deletions

View File

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