From 07ec7b9e8ba8a064ec26482f44034a02a86a6ca2 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 9 Oct 2019 19:23:03 +0200 Subject: [PATCH] Revised collapse on back --- .../eu/faircode/email/FragmentMessages.java | 5 +++-- .../email/FragmentOptionsBehavior.java | 22 ++++++++++++++----- .../res/layout/fragment_options_behavior.xml | 19 ++++++++-------- app/src/main/res/values/strings.xml | 4 ++-- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index f96d9aeea2..1cbdc4c0b1 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -3601,8 +3601,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. int count = (values.containsKey("expanded") ? values.get("expanded").size() : 0); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - boolean collapse = prefs.getBoolean("collapse", false); - if ((count == 1 && collapse) || count > 1) { + boolean collapse_single = prefs.getBoolean("collapse_single", false); + boolean collapse_multiple = prefs.getBoolean("collapse_multiple", true); + if ((collapse_single && count == 1) || (collapse_multiple && count > 1)) { values.get("expanded").clear(); updateExpanded(); adapter.notifyDataSetChanged(); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java index 321a0133d3..d2fb9db814 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java @@ -49,7 +49,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe private SwitchCompat swExpandOne; private SwitchCompat swAutoClose; private Spinner spOnClose; - private SwitchCompat swCollapse; + private SwitchCompat swCollapseSingle; + private SwitchCompat swCollapseMultiple; private SwitchCompat swAutoRead; private SwitchCompat swAutoUnflag; private SwitchCompat swAutoMove; @@ -57,7 +58,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe private final static String[] RESET_OPTIONS = new String[]{ "pull", "autoscroll", "doubletap", "swipenav", "reversed", "autoexpand", "expand_one", "autoclose", "onclose", - "collapse", "autoread", "autounflag", "automove", "discard_delete" + "collapse_single", "collapse_multiple", "autoread", "autounflag", "automove", "discard_delete" }; @Override @@ -79,7 +80,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe swExpandOne = view.findViewById(R.id.swExpandOne); swAutoClose = view.findViewById(R.id.swAutoClose); spOnClose = view.findViewById(R.id.spOnClose); - swCollapse = view.findViewById(R.id.swCollapse); + swCollapseSingle = view.findViewById(R.id.swCollapseSingle); + swCollapseMultiple = view.findViewById(R.id.swCollapseMultiple); swAutoRead = view.findViewById(R.id.swAutoRead); swAutoUnflag = view.findViewById(R.id.swAutoUnflag); swAutoMove = view.findViewById(R.id.swAutoMove); @@ -165,10 +167,17 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe } }); - swCollapse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + swCollapseSingle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("collapse", checked).apply(); + prefs.edit().putBoolean("collapse_single", checked).apply(); + } + }); + + swCollapseMultiple.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("collapse_multiple", checked).apply(); } }); @@ -265,7 +274,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe spOnClose.setEnabled(!swAutoClose.isChecked()); - swCollapse.setChecked(prefs.getBoolean("collapse", false)); + swCollapseSingle.setChecked(prefs.getBoolean("collapse_single", false)); + swCollapseMultiple.setChecked(prefs.getBoolean("collapse_multiple", true)); swAutoRead.setChecked(prefs.getBoolean("autoread", false)); swAutoUnflag.setChecked(prefs.getBoolean("autounflag", false)); swAutoMove.setChecked(!prefs.getBoolean("automove", false)); diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml index a5c4edf280..57c2fd770f 100644 --- a/app/src/main/res/layout/fragment_options_behavior.xml +++ b/app/src/main/res/layout/fragment_options_behavior.xml @@ -105,27 +105,26 @@ app:switchPadding="12dp" /> - + app:layout_constraintTop_toBottomOf="@id/swCollapseSingle" + app:switchPadding="12dp" /> Reverse navigation direction Automatically expand messages Expand only one message at a time - Collapse messages in conversations on \'back\' + Collapse single message in a conversation on \'back\' + Collapse multiple messages in a conversation on \'back\' Automatically close conversations On closing a conversation Automatically mark messages read on moving messages @@ -355,7 +356,6 @@ Inline images are images included in the message Automatically open message when there is just one message or just one unread message in a conversation - Multiple expanded messages will always be closed on \'back\' Automatically close conversations when all messages are archived, sent or trashed Most providers do not allow modified sender addresses