Added option to auto store sent messages in user folders

pull/197/head
M66B 5 years ago
parent 264a66e4ac
commit 09b8f1a37f

@ -65,6 +65,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swSignatureForward; private SwitchCompat swSignatureForward;
private Button btnEditSignature; private Button btnEditSignature;
private SwitchCompat swDiscardDelete; private SwitchCompat swDiscardDelete;
private SwitchCompat swReplyMove;
private SwitchCompat swAutoLink; private SwitchCompat swAutoLink;
private SwitchCompat swPlainOnly; private SwitchCompat swPlainOnly;
@ -81,7 +82,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
"send_reminders", "send_delayed", "send_pending", "send_reminders", "send_delayed", "send_pending",
"compose_font", "prefix_once", "separate_reply", "extended_reply", "write_below", "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", "signature_location", "signature_reply", "signature_forward",
"discard_delete", "discard_delete", "reply_move",
"auto_link", "plain_only", "format_flowed", "usenet_signature", "remove_signatures", "auto_link", "plain_only", "format_flowed", "usenet_signature", "remove_signatures",
"receipt_default", "receipt_type", "lookup_mx" "receipt_default", "receipt_type", "lookup_mx"
}; };
@ -120,6 +121,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swSignatureForward = view.findViewById(R.id.swSignatureForward); swSignatureForward = view.findViewById(R.id.swSignatureForward);
btnEditSignature = view.findViewById(R.id.btnEditSignature); btnEditSignature = view.findViewById(R.id.btnEditSignature);
swDiscardDelete = view.findViewById(R.id.swDiscardDelete); swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
swReplyMove = view.findViewById(R.id.swReplyMove);
swAutoLink = view.findViewById(R.id.swAutoLink); swAutoLink = view.findViewById(R.id.swAutoLink);
swPlainOnly = view.findViewById(R.id.swPlainOnly); swPlainOnly = view.findViewById(R.id.swPlainOnly);
@ -330,6 +332,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
} }
}); });
swReplyMove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("reply_move", checked).apply();
}
});
swAutoLink.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swAutoLink.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -468,6 +477,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swSignatureReply.setChecked(prefs.getBoolean("signature_reply", true)); swSignatureReply.setChecked(prefs.getBoolean("signature_reply", true));
swSignatureForward.setChecked(prefs.getBoolean("signature_forward", true)); swSignatureForward.setChecked(prefs.getBoolean("signature_forward", true));
swDiscardDelete.setChecked(prefs.getBoolean("discard_delete", false)); swDiscardDelete.setChecked(prefs.getBoolean("discard_delete", false));
swReplyMove.setChecked(prefs.getBoolean("reply_move", false));
swAutoLink.setChecked(prefs.getBoolean("auto_link", false)); swAutoLink.setChecked(prefs.getBoolean("auto_link", false));
swPlainOnly.setChecked(prefs.getBoolean("plain_only", false)); swPlainOnly.setChecked(prefs.getBoolean("plain_only", false));

@ -514,6 +514,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
} }
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean reply_move = prefs.getBoolean("reply_move", false);
boolean debug = prefs.getBoolean("debug", false); boolean debug = prefs.getBoolean("debug", false);
if (message.identity == null) if (message.identity == null)
@ -550,7 +551,23 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
// Prepare sent message // Prepare sent message
Long sid = null; Long sid = null;
EntityFolder sent = db.folder().getFolderByType(message.account, EntityFolder.SENT); EntityFolder sent = null;
if (reply_move && !TextUtils.isEmpty(message.inreplyto)) {
List<EntityMessage> replied = db.message().getMessagesByMsgId(message.account, message.inreplyto);
if (replied != null)
for (EntityMessage m : replied) {
EntityFolder folder = db.folder().getFolder(m.folder);
if (folder != null && EntityFolder.USER.equals(folder.type)) {
sent = folder;
break;
}
}
}
if (sent == null)
sent = db.folder().getFolderByType(message.account, EntityFolder.SENT);
if (sent != null) { if (sent != null) {
Log.i(sent.name + " Preparing sent message"); Log.i(sent.name + " Preparing sent message");

@ -402,6 +402,28 @@
app:layout_constraintTop_toBottomOf="@id/btnEditSignature" app:layout_constraintTop_toBottomOf="@id/btnEditSignature"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swReplyMove"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_reply_move"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDiscardDelete"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvReplyMoveHint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_reply_move_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swReplyMove" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvCaptionAdvanced" android:id="@+id/tvCaptionAdvanced"
android:layout_width="0dp" android:layout_width="0dp"
@ -412,7 +434,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Large" android:textAppearance="@style/TextAppearance.AppCompat.Large"
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/swDiscardDelete" /> app:layout_constraintTop_toBottomOf="@+id/tvReplyMoveHint" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoLink" android:id="@+id/swAutoLink"

@ -330,6 +330,7 @@
<string name="title_advanced_signature_reply">Use signature when replying</string> <string name="title_advanced_signature_reply">Use signature when replying</string>
<string name="title_advanced_signature_forward">Use signature when forwarding</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_discard_delete">On discard draft permanently delete draft</string>
<string name="title_advanced_reply_move">On replying to a message that is not in the inbox, save the reply in the same folder</string>
<string name="title_advanced_auto_link">Automatically create links</string> <string name="title_advanced_auto_link">Automatically create links</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>
@ -581,6 +582,7 @@
<string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled.</string> <string name="title_advanced_suggest_local_hint">In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled.</string>
<string name="title_advanced_usenet_hint">Insert \'-- \' between the text and the signature</string> <string name="title_advanced_usenet_hint">Insert \'-- \' between the text and the signature</string>
<string name="title_advanced_send_reminders_hint">Show a warning when the message text or the subject is empty or when an attachment might be missing</string> <string name="title_advanced_send_reminders_hint">Show a warning when the message text or the subject is empty or when an attachment might be missing</string>
<string name="title_advanced_reply_move_hint">The email server could still add the messages to the sent message folder</string>
<string name="title_advanced_metered_hint">Metered connections are generally mobile connections or paid Wi-Fi hotspots</string> <string name="title_advanced_metered_hint">Metered connections are generally mobile connections or paid Wi-Fi hotspots</string>
<string name="title_advanced_metered_warning">Disabling this option will disable receiving and sending messages on mobile internet connections</string> <string name="title_advanced_metered_warning">Disabling this option will disable receiving and sending messages on mobile internet connections</string>

Loading…
Cancel
Save