From 1ed6fe621d59890335e09f31856ee55803b7b44b Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 30 Jul 2021 08:26:37 +0200 Subject: [PATCH] Added option to auto close on mark unseen --- .../java/eu/faircode/email/AdapterMessage.java | 8 +++++++- .../eu/faircode/email/FragmentOptionsBehavior.java | 14 +++++++++++++- .../main/res/layout/fragment_options_behavior.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index a6203c7089..99791cd876 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -279,6 +279,8 @@ public class AdapterMessage extends RecyclerView.Adapter languages; private static boolean debug; @@ -4807,7 +4809,10 @@ public class AdapterMessage extends RecyclerView.Adapter= Build.VERSION_CODES.N) { languages = new ArrayList<>(); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java index 9f997e2c50..10d3d086f4 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java @@ -83,6 +83,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe private TextView tvAutoSeenHint; private TextView tvOnClose; private Spinner spOnClose; + private SwitchCompat swAutoCloseUnseen; private Spinner spUndoTimeout; private SwitchCompat swCollapseMultiple; private SwitchCompat swAutoRead; @@ -100,7 +101,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe "pull", "autoscroll", "quick_filter", "quick_scroll", "swipe_sensitivity", "doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move", "autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple", - "autoclose", "onclose", "undo_timeout", + "autoclose", "onclose", "autoclose_unseen", + "undo_timeout", "autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance" }; @@ -141,6 +143,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe swAutoClose = view.findViewById(R.id.swAutoClose); tvOnClose = view.findViewById(R.id.tvOnClose); spOnClose = view.findViewById(R.id.spOnClose); + swAutoCloseUnseen = view.findViewById(R.id.swAutoCloseUnseen); spUndoTimeout = view.findViewById(R.id.spUndoTimeout); swAutoRead = view.findViewById(R.id.swAutoRead); swFlagSnoozed = view.findViewById(R.id.swFlagSnoozed); @@ -386,6 +389,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe } }); + swAutoCloseUnseen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("autoclose_unseen", checked).apply(); + } + }); + spUndoTimeout.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView adapterView, View view, int position, long id) { @@ -524,6 +534,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe tvOnClose.setEnabled(!swAutoClose.isChecked()); spOnClose.setEnabled(!swAutoClose.isChecked()); + swAutoCloseUnseen.setChecked(prefs.getBoolean("autoclose_unseen", false)); + int undo_timeout = prefs.getInt("undo_timeout", 5000); int[] undoValues = getResources().getIntArray(R.array.undoValues); for (int pos = 0; pos < undoValues.length; pos++) diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml index 751ecd4699..32c9ac4c1f 100644 --- a/app/src/main/res/layout/fragment_options_behavior.xml +++ b/app/src/main/res/layout/fragment_options_behavior.xml @@ -529,6 +529,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvOnClose" /> + + + app:layout_constraintTop_toBottomOf="@id/swAutoCloseUnseen" /> Collapse messages in a conversation with multiple messages on \'back\' Automatically close conversations On closing a conversation + Close conversations on marking messages as unread Undo timeout Show non-obtrusive quick filter icons Show non-obtrusive quick scroll up/down icons