Added option for signature on first reply only

This commit is contained in:
M66B 2022-04-18 10:43:35 +02:00
parent 3c5d41cad3
commit 0afb68a080
4 changed files with 47 additions and 2 deletions

View File

@ -4926,6 +4926,26 @@ public class FragmentCompose extends FragmentBase {
if (drafts == null)
throw new IllegalArgumentException(context.getString(R.string.title_no_drafts));
boolean signature_once = prefs.getBoolean("signature_reply_once", false);
if (signature_once && data.draft.signature &&
ref != null && ref.thread != null &&
("reply".equals(action) || "reply_all".equals(action))) {
List<EntityMessage> outbound = new ArrayList<>();
EntityFolder sent = db.folder().getFolderByType(drafts.account, EntityFolder.SENT);
if (sent != null)
outbound.addAll(db.message().getMessagesByThread(drafts.account, ref.thread, null, sent.id));
EntityFolder outbox = db.folder().getOutbox();
if (outbox != null)
outbound.addAll(db.message().getMessagesByThread(drafts.account, ref.thread, null, outbox.id));
if (outbound.size() > 0) {
Log.i("Signature suppressed");
data.draft.signature = false;
}
}
data.draft.account = drafts.account;
data.draft.folder = drafts.id;
data.draft.identity = selected.id;

View File

@ -84,6 +84,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private Spinner spSignatureLocation;
private SwitchCompat swSignatureNew;
private SwitchCompat swSignatureReply;
private SwitchCompat swSignatureReplyOnce;
private SwitchCompat swSignatureForward;
private Button btnEditSignature;
private SwitchCompat swDiscardDelete;
@ -106,7 +107,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
"send_reminders", "send_chips", "send_delayed",
"attach_new", "answer_action", "send_pending", "sound_sent",
"compose_font", "prefix_once", "prefix_count", "separate_reply", "extended_reply", "write_below", "quote_reply", "quote_limit", "resize_reply",
"signature_location", "signature_new", "signature_reply", "signature_forward",
"signature_location", "signature_new", "signature_reply", "signature_reply_once", "signature_forward",
"discard_delete", "reply_move",
"auto_link", "plain_only", "format_flowed", "usenet_signature", "remove_signatures",
"receipt_default", "receipt_type", "receipt_legacy", "lookup_mx"
@ -152,6 +153,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
spSignatureLocation = view.findViewById(R.id.spSignatureLocation);
swSignatureNew = view.findViewById(R.id.swSignatureNew);
swSignatureReply = view.findViewById(R.id.swSignatureReply);
swSignatureReplyOnce = view.findViewById(R.id.swSignatureReplyOnce);
swSignatureForward = view.findViewById(R.id.swSignatureForward);
btnEditSignature = view.findViewById(R.id.btnEditSignature);
swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
@ -434,6 +436,14 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("signature_reply", checked).apply();
swSignatureReplyOnce.setEnabled(checked);
}
});
swSignatureReplyOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("signature_reply_once", checked).apply();
}
});
@ -650,6 +660,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swSignatureNew.setChecked(prefs.getBoolean("signature_new", true));
swSignatureReply.setChecked(prefs.getBoolean("signature_reply", true));
swSignatureReplyOnce.setChecked(prefs.getBoolean("signature_reply_once", false));
swSignatureReplyOnce.setEnabled(swSignatureReply.isChecked());
swSignatureForward.setChecked(prefs.getBoolean("signature_forward", true));
swDiscardDelete.setChecked(prefs.getBoolean("discard_delete", true));
swReplyMove.setChecked(prefs.getBoolean("reply_move", false));

View File

@ -574,6 +574,18 @@
app:layout_constraintTop_toBottomOf="@id/swSignatureNew"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSignatureReplyOnce"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_signature_reply_once"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSignatureReply"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSignatureForward"
android:layout_width="0dp"
@ -583,7 +595,7 @@
android:text="@string/title_advanced_signature_forward"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSignatureReply"
app:layout_constraintTop_toBottomOf="@id/swSignatureReplyOnce"
app:switchPadding="12dp" />
<Button

View File

@ -406,6 +406,7 @@
<string name="title_advanced_signature_location">Signature position</string>
<string name="title_advanced_signature_new">Use signature for new messages</string>
<string name="title_advanced_signature_reply">Use signature when replying</string>
<string name="title_advanced_signature_reply_once">Only for the first reply</string>
<string name="title_advanced_signature_forward">Use signature when forwarding</string>
<string name="title_advanced_discard_delete">On discard draft permanently delete draft</string>
<string name="title_advanced_reply_move">On replying to a message, save the reply in the same folder</string>