From 3fee21e4463239d1d688cfe51295335176bd12ef Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 31 Mar 2021 21:10:57 +0200 Subject: [PATCH] Added setting to disable send pending icon/button --- .../eu/faircode/email/FragmentMessages.java | 34 ++++++++----------- .../eu/faircode/email/FragmentOptions.java | 1 + .../faircode/email/FragmentOptionsSend.java | 15 ++++++-- .../main/res/layout/fragment_options_send.xml | 14 +++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index e8b21a22cc..f462fbd4da 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -3692,6 +3692,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. boolean hints = (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + boolean send_pending = prefs.getBoolean("send_pending", true); grpHintSupport.setVisibility(prefs.getBoolean("app_support", false) || !hints ? View.GONE : View.VISIBLE); grpHintSwipe.setVisibility(prefs.getBoolean("message_swipe", false) || !hints ? View.GONE : View.VISIBLE); grpHintSelect.setVisibility(prefs.getBoolean("message_select", false) || !hints ? View.GONE : View.VISIBLE); @@ -3743,16 +3744,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. updateState(folders); } }); - db.message().liveOutboxPending().observe(getViewLifecycleOwner(), new Observer() { - @Override - public void onChanged(Integer pending) { - if (pending != null && pending > 10) - tvOutboxCount.setText("+"); - else - tvOutboxCount.setText(pending == null || pending == 0 ? null : NF.format(pending)); - grpOutbox.setVisibility(pending == null || pending == 0 ? View.GONE : View.VISIBLE); - } - }); break; case FOLDER: @@ -3766,16 +3757,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. updateState(folders); } }); - db.message().liveOutboxPending().observe(getViewLifecycleOwner(), new Observer() { - @Override - public void onChanged(Integer pending) { - if (pending != null && pending > 10) - tvOutboxCount.setText("+"); - else - tvOutboxCount.setText(pending == null || pending == 0 ? null : NF.format(pending)); - grpOutbox.setVisibility(pending == null || pending == 0 ? View.GONE : View.VISIBLE); - } - }); break; case THREAD: @@ -3816,6 +3797,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. break; } + if (send_pending && + (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER)) + db.message().liveOutboxPending().observe(getViewLifecycleOwner(), new Observer() { + @Override + public void onChanged(Integer pending) { + if (pending != null && pending > 10) + tvOutboxCount.setText("+"); + else + tvOutboxCount.setText(pending == null || pending == 0 ? null : NF.format(pending)); + grpOutbox.setVisibility(pending == null || pending == 0 ? View.GONE : View.VISIBLE); + } + }); + if (!checkReporting()) if (!checkReview()) checkFingerprint(); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index 8592cbe04e..798066731b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -84,6 +84,7 @@ public class FragmentOptions extends FragmentBase { static String[] OPTIONS_RESTART = new String[]{ "first", "app_support", "notify_archive", "message_swipe", "message_select", "folder_actions", "folder_sync", "subscriptions", + "send_pending", "portrait2", "landscape", "landscape3", "startup", "cards", "beige", "shadow_unread", "indentation", "date", "threading", "threading_unread", "highlight_unread", "highlight_color", "color_stripe", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java index 4dbd33d1dd..6eb3e38a83 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSend.java @@ -50,6 +50,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private Button btnLocalContacts; private SwitchCompat swSendReminders; private Spinner spSendDelayed; + private SwitchCompat swSendPending; private Spinner spComposeFont; private SwitchCompat swPrefixOnce; @@ -77,7 +78,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc private final static String[] RESET_OPTIONS = new String[]{ "keyboard", "keyboard_no_fullscreen", "suggest_names", "suggest_sent", "suggested_received", "suggest_frequently", - "send_reminders", "send_delayed", + "send_reminders", "send_delayed", "send_pending", "compose_font", "prefix_once", "separate_reply", "extended_reply", "write_below", "quote_reply", "quote_limit", "resize_reply", "signature_location", "signature_reply", "signature_forward", "discard_delete", @@ -104,8 +105,9 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc btnLocalContacts = view.findViewById(R.id.btnLocalContacts); swSendReminders = view.findViewById(R.id.swSendReminders); spSendDelayed = view.findViewById(R.id.spSendDelayed); - spComposeFont = view.findViewById(R.id.spComposeFont); + swSendPending = view.findViewById(R.id.swSendPending); + spComposeFont = view.findViewById(R.id.spComposeFont); swPrefixOnce = view.findViewById(R.id.swPrefixOnce); swSeparateReply = view.findViewById(R.id.swSeparateReply); swExtendedReply = view.findViewById(R.id.swExtendedReply); @@ -206,6 +208,13 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc } }); + swSendPending.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("send_pending", checked).apply(); + } + }); + spComposeFont.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView adapterView, View view, int position, long id) { @@ -434,6 +443,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc break; } + swSendPending.setChecked(prefs.getBoolean("send_pending", true)); + boolean monospaced = prefs.getBoolean("monospaced", false); String compose_font = prefs.getString("compose_font", monospaced ? "monospace" : "sans-serif"); String[] fontNameValues = getResources().getStringArray(R.array.fontNameValues); diff --git a/app/src/main/res/layout/fragment_options_send.xml b/app/src/main/res/layout/fragment_options_send.xml index 49a8d1fc0c..49f3837395 100644 --- a/app/src/main/res/layout/fragment_options_send.xml +++ b/app/src/main/res/layout/fragment_options_send.xml @@ -207,6 +207,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvSendDelayed" /> + + + app:layout_constraintTop_toBottomOf="@+id/swSendPending" /> Show reminders Check recipient email addresses before sending Delay sending messages + Show non-obtrusive send delayed icon Use metered connections Automatically download messages and attachments on a metered connection up to