From e94e1ca408d6ce9a36f343ac157e3610e5f357f6 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 15 Feb 2022 20:05:02 +0100 Subject: [PATCH] Configurable default answer action --- .../java/eu/faircode/email/ApplicationEx.java | 4 +++ .../eu/faircode/email/FragmentMessages.java | 13 ++++++--- .../faircode/email/FragmentOptionsSend.java | 29 ++++++++++++++----- .../main/res/layout/fragment_options_send.xml | 26 ++++++++--------- app/src/main/res/values/strings.xml | 21 ++++++++++++-- 5 files changed, 67 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java index b05c332449..177b27e8a0 100644 --- a/app/src/main/java/eu/faircode/email/ApplicationEx.java +++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java @@ -577,6 +577,10 @@ public class ApplicationEx extends Application } else if (version < 1837) { if (!prefs.contains("compact_folders")) editor.putBoolean("compact_folders", false); + } else if (version < 1839) { + boolean reply_all = prefs.getBoolean("reply_all", false); + if (reply_all) + editor.remove("reply_all").putString("answer_action", "reply_all"); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index c34d726c12..7d9c4f10f5 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -2787,7 +2787,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. } }; - private void onReply(boolean sender) { + private void onReply(boolean long_press) { if (values.containsKey("expanded") && values.get("expanded").size() > 0) { long id = values.get("expanded").get(0); int pos = adapter.getPositionForKey(id); @@ -2798,10 +2798,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. if (message == null) return; - if (sender && message.content) { + if (long_press && message.content) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - boolean reply_all = prefs.getBoolean("reply_all", false); - onMenuReply(message, reply_all ? "reply_all" : "reply", selected); + String answer_action = prefs.getString("answer_action", "reply"); + if ("reply".equals(answer_action) || + "reply_all".equals(answer_action) || + "list".equals(answer_action)) + onMenuReply(message, answer_action, selected); + else + onMenuReply(message, answer_action); } else onReply(message, selected, fabReply); } diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index 551ffde8d4..6b6bfefc33 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -64,7 +64,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private SwitchCompat swSendReminders; private Spinner spSendDelayed; private SwitchCompat swAttachNew; - private SwitchCompat swReplyAll; + private Spinner spAnswerAction; private SwitchCompat swSendPending; private Spinner spComposeFont; @@ -97,7 +97,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc "suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", "alt_re", "alt_fwd", "send_reminders", "send_delayed", - "attach_new", "reply_all", "send_pending", + "attach_new", "answer_action", "send_pending", "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", "discard_delete", "reply_move", @@ -129,7 +129,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc swSendReminders = view.findViewById(R.id.swSendReminders); spSendDelayed = view.findViewById(R.id.spSendDelayed); swAttachNew = view.findViewById(R.id.swAttachNew); - swReplyAll = view.findViewById(R.id.swReplyAll); + spAnswerAction = view.findViewById(R.id.spAnswerAction); swSendPending = view.findViewById(R.id.swSendPending); spComposeFont = view.findViewById(R.id.spComposeFont); @@ -287,10 +287,16 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc } }); - swReplyAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + spAnswerAction.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("reply_all", checked).apply(); + public void onItemSelected(AdapterView adapterView, View view, int position, long id) { + String[] values = getResources().getStringArray(R.array.answerValues); + prefs.edit().putString("answer_action", values[position]).apply(); + } + + @Override + public void onNothingSelected(AdapterView parent) { + prefs.edit().remove("sender_ellipsize").apply(); } }); @@ -567,7 +573,16 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc } swAttachNew.setChecked(prefs.getBoolean("attach_new", true)); - swReplyAll.setChecked(prefs.getBoolean("reply_all", false)); + + boolean reply_all = prefs.getBoolean("reply_all", false); + String answer_action = prefs.getString("answer_action", reply_all ? "reply_all" : "reply"); + String[] answerValues = getResources().getStringArray(R.array.answerValues); + for (int pos = 0; pos < answerValues.length; pos++) + if (answerValues[pos].equals(answer_action)) { + spAnswerAction.setSelection(pos); + break; + } + swSendPending.setChecked(prefs.getBoolean("send_pending", true)); String compose_font = prefs.getString("compose_font", ""); diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index ef9bf66af3..a28cb70615 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -333,27 +333,27 @@ app:layout_constraintTop_toBottomOf="@id/spSendDelayed" app:switchPadding="12dp" /> - + app:layout_constraintTop_toBottomOf="@id/swAttachNew" /> - + app:layout_constraintTop_toBottomOf="@id/tvAnswerAction" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 36f5c9b04e..e01392e2f8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -378,7 +378,7 @@ Show reminders Delay sending messages Add shared files to a new draft - Long press answer button to reply to all + Long pressing on the answer button will: Show non-obtrusive send delayed icon Default font @@ -752,7 +752,6 @@ If disabled, only email addresses will be used when selecting contacts In addition to contacts provided by Android. Contact data will be stored for newly sent or received messages only when enabled. Show a warning when the message text or the subject is empty or when an attachment might be missing - If disabled, long pressing the answer button will answer the sender The email server could still add the messages to the sent message folder Insert \'-- \' between the text and the signature This can result in too little or too much text being removed @@ -2235,6 +2234,24 @@ Extra large + + reply + reply_all + list + forward + resend + editasnew + + + + @string/title_reply_to_sender + @string/title_reply_to_all + @string/title_reply_list + @string/title_forward + @string/title_resend + @string/title_editasnew + + 17BA15C1AF55D925F98B99CEA4375D4CDF4C174B 77CD40058858DC3A38523E01C227A39AA019F88B 200D0AA43A8ADBC7BB8237023C1553F4753CA7D2