diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 27847aeaaa..b9d2552606 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -395,6 +395,18 @@ public class FragmentCompose extends FragmentBase { resolver = getContext().getContentResolver(); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + final boolean auto_save = prefs.getBoolean("auto_save", true); + final boolean keyboard_no_fullscreen = prefs.getBoolean("keyboard_no_fullscreen", false); + final boolean suggest_names = prefs.getBoolean("suggest_names", true); + final boolean suggest_sent = prefs.getBoolean("suggest_sent", true); + final boolean suggest_received = prefs.getBoolean("suggest_received", false); + final boolean suggest_frequently = prefs.getBoolean("suggest_frequently", false); + final boolean cc_bcc = prefs.getBoolean("cc_bcc", false); + final boolean circular = prefs.getBoolean("circular", true); + + final float dp3 = Helper.dp2pixels(getContext(), 3); + // Wire controls spIdentity.setOnItemSelectedListener(identitySelected); @@ -743,9 +755,11 @@ public class FragmentCompose extends FragmentBase { etBody.setTag(null); - Bundle extras = new Bundle(); - extras.putBoolean("silent", true); - onAction(R.id.action_save, extras, "paragraph"); + if (auto_save) { + Bundle extras = new Bundle(); + extras.putBoolean("silent", true); + onAction(R.id.action_save, extras, "paragraph"); + } } catch (Throwable ex) { Log.e(ex); } finally { @@ -960,8 +974,6 @@ public class FragmentCompose extends FragmentBase { setHasOptionsMenu(true); FragmentDialogTheme.setBackground(getContext(), view, true); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - boolean keyboard_no_fullscreen = prefs.getBoolean("keyboard_no_fullscreen", false); if (keyboard_no_fullscreen) { // https://developer.android.com/reference/android/view/inputmethod/EditorInfo#IME_FLAG_NO_FULLSCREEN etExtra.setImeOptions(etExtra.getImeOptions() | IME_FLAG_NO_FULLSCREEN); @@ -1003,14 +1015,6 @@ public class FragmentCompose extends FragmentBase { final DB db = DB.getInstance(getContext()); - final boolean suggest_names = prefs.getBoolean("suggest_names", true); - final boolean suggest_sent = prefs.getBoolean("suggest_sent", true); - final boolean suggest_received = prefs.getBoolean("suggest_received", false); - final boolean suggest_frequently = prefs.getBoolean("suggest_frequently", false); - final boolean cc_bcc = prefs.getBoolean("cc_bcc", false); - final boolean circular = prefs.getBoolean("circular", true); - final float dp3 = Helper.dp2pixels(getContext(), 3); - SimpleCursorAdapter cadapter = new SimpleCursorAdapter( getContext(), R.layout.spinner_contact, diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index a5f9509fcc..951a23ebb7 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -75,6 +75,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private SwitchCompat swSendPending; private Button btnSound; + private SwitchCompat swAutoSave; private Spinner spComposeFont; private SwitchCompat swSeparateReply; private SwitchCompat swExtendedReply; @@ -107,7 +108,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc "alt_re", "alt_fwd", "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", + "auto_save", "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_reply_once", "signature_forward", "discard_delete", "reply_move", "auto_link", "plain_only", "format_flowed", "usenet_signature", "remove_signatures", @@ -145,6 +146,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc swSendPending = view.findViewById(R.id.swSendPending); btnSound = view.findViewById(R.id.btnSound); + swAutoSave = view.findViewById(R.id.swAutoSave); spComposeFont = view.findViewById(R.id.spComposeFont); swSeparateReply = view.findViewById(R.id.swSeparateReply); swExtendedReply = view.findViewById(R.id.swExtendedReply); @@ -359,6 +361,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc } }); + swAutoSave.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("auto_save", checked).apply(); + } + }); + spComposeFont.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView adapterView, View view, int position, long id) { @@ -649,6 +658,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc swSendPending.setChecked(prefs.getBoolean("send_pending", true)); + swAutoSave.setChecked(prefs.getBoolean("auto_save", true)); + String compose_font = prefs.getString("compose_font", ""); List fonts = StyleHelper.getFonts(getContext()); for (int pos = 0; pos < fonts.size(); pos++) { diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index 39258d1b36..51f6c2c283 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -460,6 +460,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + app:layout_constraintTop_toBottomOf="@id/swAutoSave" /> Long pressing on the answer button will: Show non-obtrusive send delayed icon + Automatically save after new paragraphs Default font Automatically select identities for new messages Prefix subject only once on replying or forwarding