Added bottom posting

pull/189/head
M66B 4 years ago
parent abccf43344
commit e446dcedad

@ -3358,6 +3358,7 @@ public class FragmentCompose extends FragmentBase {
boolean sign_default = prefs.getBoolean("sign_default", false);
boolean encrypt_default = prefs.getBoolean("encrypt_default", false);
boolean receipt_default = prefs.getBoolean("receipt_default", false);
boolean write_below = prefs.getBoolean("write_below", false);
Log.i("Load draft action=" + action + " id=" + id + " reference=" + reference);
@ -3834,7 +3835,10 @@ public class FragmentCompose extends FragmentBase {
e.tagName(quote ? "blockquote" : "p");
reply.appendChild(e);
document.body().appendChild(reply);
if (write_below)
document.body().prependChild(reply);
else
document.body().appendChild(reply);
addSignature(context, document, data.draft, selected);
}
@ -4003,7 +4007,10 @@ public class FragmentCompose extends FragmentBase {
Document document = HtmlHelper.sanitizeCompose(context, doc.html(), true);
for (Element e : ref)
document.body().appendChild(e);
if (write_below)
document.body().prependChild(e);
else
document.body().appendChild(e);
EntityIdentity identity = null;
if (data.draft.identity != null)
@ -4451,12 +4458,16 @@ public class FragmentCompose extends FragmentBase {
// Get saved body
Document d;
boolean write_below = prefs.getBoolean("write_below", false);
if (extras != null && extras.containsKey("html")) {
// Save current revision
Document c = JsoupEx.parse(body);
for (Element e : ref)
c.body().appendChild(e);
if (write_below)
c.body().prependChild(e);
else
c.body().appendChild(e);
addSignature(context, c, draft, identity);
@ -4467,7 +4478,10 @@ public class FragmentCompose extends FragmentBase {
d = HtmlHelper.sanitizeCompose(context, body, true);
for (Element e : ref)
d.body().appendChild(e);
if (write_below)
d.body().prependChild(e);
else
d.body().appendChild(e);
addSignature(context, d, draft, identity);
}
@ -4977,6 +4991,7 @@ public class FragmentCompose extends FragmentBase {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int signature_location = prefs.getInt("signature_location", 1);
boolean usenet = prefs.getBoolean("usenet_signature", false);
boolean write_below = prefs.getBoolean("write_below", false);
Element div = document.createElement("div");
div.attr("fairemail", "signature");
@ -4992,12 +5007,15 @@ public class FragmentCompose extends FragmentBase {
div.append(identity.signature);
Elements ref = document.select("div[fairemail=reference]");
if (signature_location == 0)
if (signature_location == 0) // top
document.body().prependChild(div);
else if (ref.size() == 0 || signature_location == 2)
else if (ref.size() == 0 || signature_location == 2) // bottom
document.body().appendChild(div);
else if (signature_location == 1)
ref.first().before(div);
else if (signature_location == 1) // between
if (write_below)
ref.last().after(div);
else
ref.first().before(div);
}
private void showDraft(final EntityMessage draft, final boolean scroll) {

@ -54,6 +54,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swPrefixOnce;
private SwitchCompat swSeparateReply;
private SwitchCompat swExtendedReply;
private SwitchCompat swWriteBelow;
private SwitchCompat swQuoteReply;
private SwitchCompat swQuoteLimit;
private SwitchCompat swResizeReply;
@ -73,7 +74,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private final static String[] RESET_OPTIONS = new String[]{
"keyboard", "suggest_sent", "suggested_received", "suggest_frequently",
"send_reminders", "send_delayed",
"compose_font", "prefix_once", "separate_reply", "extended_reply", "quote_reply", "quote_limit", "resize_reply",
"compose_font", "prefix_once", "separate_reply", "extended_reply", "write_below", "quote_reply", "quote_limit", "resize_reply",
"signature_location", "signature_reply", "signature_forward",
"discard_delete",
"plain_only", "format_flowed", "usenet_signature", "remove_signatures",
@ -102,6 +103,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swPrefixOnce = view.findViewById(R.id.swPrefixOnce);
swSeparateReply = view.findViewById(R.id.swSeparateReply);
swExtendedReply = view.findViewById(R.id.swExtendedReply);
swWriteBelow = view.findViewById(R.id.swWriteBelow);
swQuoteReply = view.findViewById(R.id.swQuoteReply);
swQuoteLimit = view.findViewById(R.id.swQuoteLimit);
swResizeReply = view.findViewById(R.id.swResizeReply);
@ -228,6 +230,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
swWriteBelow.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("write_below", checked).apply();
}
});
swQuoteReply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -409,6 +418,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swPrefixOnce.setChecked(prefs.getBoolean("prefix_once", true));
swSeparateReply.setChecked(prefs.getBoolean("separate_reply", false));
swExtendedReply.setChecked(prefs.getBoolean("extended_reply", false));
swWriteBelow.setChecked(prefs.getBoolean("write_below", false));
swQuoteReply.setChecked(prefs.getBoolean("quote_reply", true));
swQuoteLimit.setChecked(prefs.getBoolean("quote_limit", true));
swResizeReply.setChecked(prefs.getBoolean("resize_reply", true));

@ -225,6 +225,18 @@
app:layout_constraintTop_toBottomOf="@id/swSeparateReply"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swWriteBelow"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_write_below"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swExtendedReply"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swQuoteReply"
android:layout_width="0dp"
@ -234,7 +246,7 @@
android:text="@string/title_advanced_quote_reply"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swExtendedReply"
app:layout_constraintTop_toBottomOf="@id/swWriteBelow"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

Loading…
Cancel
Save