From f03480de0cfbaa29817d75e646d62437cdb70328 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 27 Mar 2021 08:30:20 +0100 Subject: [PATCH] Added option to expand first message when all read --- .../java/eu/faircode/email/FragmentMessages.java | 7 +++++-- .../eu/faircode/email/FragmentOptionsBehavior.java | 14 +++++++++++++- .../main/res/layout/fragment_options_behavior.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index f5308bf058..5cd8dfc295 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -4930,7 +4930,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. autoExpanded = false; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + boolean expand_first = prefs.getBoolean("expand_first", true); + boolean expand_all = prefs.getBoolean("expand_all", false); long download = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE); + if (download == 0) download = Long.MAX_VALUE; @@ -4984,7 +4987,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. expand = messages.get(0); else if (messages.size() > 0) { TupleMessageEx first = messages.get(adapter.getAscending() ? messages.size() - 1 : 0); - if (first != null && EntityFolder.OUTBOX.equals(first.folderType)) + if (first != null && + ((expand_first && unseen == 0) || EntityFolder.OUTBOX.equals(first.folderType))) expand = first; } @@ -4994,7 +4998,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. } // Auto expand all seen messages - boolean expand_all = prefs.getBoolean("expand_all", false); if (expand_all) for (TupleMessageEx message : messages) if (message != null && diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java index a9afd0fc5a..7d03e04279 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java @@ -74,6 +74,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe private SwitchCompat swSwipeClose; private SwitchCompat swSwipeMove; private SwitchCompat swAutoExpand; + private SwitchCompat swExpandFirst; private SwitchCompat swExpandAll; private SwitchCompat swExpandOne; private SwitchCompat swAutoClose; @@ -92,7 +93,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe "default_snooze", "pull", "autoscroll", "quick_filter", "quick_scroll", "doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move", - "autoexpand", "expand_all", "expand_one", "collapse_multiple", + "autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple", "autoclose", "onclose", "undo_timeout", "autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance" }; @@ -125,6 +126,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe swSwipeClose = view.findViewById(R.id.swSwipeClose); swSwipeMove = view.findViewById(R.id.swSwipeMove); swAutoExpand = view.findViewById(R.id.swAutoExpand); + swExpandFirst = view.findViewById(R.id.swExpandFirst); swExpandAll = view.findViewById(R.id.swExpandAll); swExpandOne = view.findViewById(R.id.swExpandOne); swCollapseMultiple = view.findViewById(R.id.swCollapseMultiple); @@ -288,6 +290,14 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("autoexpand", checked).apply(); + swExpandFirst.setEnabled(checked); + } + }); + + swExpandFirst.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("expand_first", checked).apply(); } }); @@ -459,6 +469,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe swSwipeMove.setChecked(prefs.getBoolean("swipe_move", false)); swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true)); + swExpandFirst.setChecked(prefs.getBoolean("expand_first", true)); + swExpandFirst.setEnabled(swAutoExpand.isChecked()); swExpandAll.setChecked(prefs.getBoolean("expand_all", false)); swExpandOne.setChecked(prefs.getBoolean("expand_one", true)); swExpandOne.setEnabled(!swExpandAll.isChecked()); diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml index fa64879c3d..0e3232f736 100644 --- a/app/src/main/res/layout/fragment_options_behavior.xml +++ b/app/src/main/res/layout/fragment_options_behavior.xml @@ -334,6 +334,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swAutoExpand" /> + + Swipe down to close conversation Swipe up to move conversation Automatically expand messages + Automatically expand the first message when the conversation is read Automatically expand all read messages Expand only one message at a time Collapse messages in a conversation with multiple messages on \'back\'