From afa16f2f9a72c0864493598f1c788a22ba4dda3a Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 30 Jan 2019 19:35:36 +0000 Subject: [PATCH] Added option to disable auto expanding --- .../eu/faircode/email/FragmentMessages.java | 43 ++++++++++--------- .../eu/faircode/email/FragmentOptions.java | 39 +++++++++++------ app/src/main/res/layout/fragment_options.xml | 31 +++++++++++-- app/src/main/res/values/strings.xml | 4 +- 4 files changed, 79 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 193f0c9221..380a12d0db 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -116,6 +116,7 @@ public class FragmentMessages extends FragmentBase { private boolean threading; private boolean pull; private boolean actionbar; + private boolean autoexpand; private boolean autoclose; private boolean autonext; private boolean addresses; @@ -133,7 +134,7 @@ public class FragmentMessages extends FragmentBase { private Long next = null; private Long closeNext = null; private int autoCloseCount = 0; - private boolean autoExpand = true; + private boolean autoExpanded = true; private Map> values = new HashMap<>(); private LongSparseArray bodies = new LongSparseArray<>(); private LongSparseArray accountSwipes = new LongSparseArray<>(); @@ -189,6 +190,7 @@ public class FragmentMessages extends FragmentBase { threading = prefs.getBoolean("threading", true); actionbar = prefs.getBoolean("actionbar", true); + autoexpand = prefs.getBoolean("autoexpand", true); autoclose = prefs.getBoolean("autoclose", true); autonext = prefs.getBoolean("autonext", false); addresses = prefs.getBoolean("addresses", true); @@ -1347,7 +1349,7 @@ public class FragmentMessages extends FragmentBase { @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - outState.putBoolean("autoExpand", autoExpand); + outState.putBoolean("autoExpanded", autoExpanded); outState.putInt("autoCloseCount", autoCloseCount); outState.putStringArray("values", values.keySet().toArray(new String[0])); @@ -1363,7 +1365,7 @@ public class FragmentMessages extends FragmentBase { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { - autoExpand = savedInstanceState.getBoolean("autoExpand"); + autoExpanded = savedInstanceState.getBoolean("autoExpanded"); autoCloseCount = savedInstanceState.getInt("autoCloseCount"); String[] names = savedInstanceState.getStringArray("values"); @@ -1931,8 +1933,8 @@ public class FragmentMessages extends FragmentBase { } } - if (autoExpand) { - autoExpand = false; + if (autoExpanded) { + autoExpanded = false; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); long download = prefs.getInt("download", 32768); @@ -1972,21 +1974,22 @@ public class FragmentMessages extends FragmentBase { // - single, non archived/trashed/sent message // - one unread, non archived/trashed/sent message in conversation // - sole message - - TupleMessageEx expand = null; - if (count == 1) - expand = single; - else if (unseen == 1) - expand = see; - else if (messages.size() == 1) - expand = messages.get(0); - - if (expand != null && - (expand.content || !metered || (expand.size != null && expand.size < download))) { - if (!values.containsKey("expanded")) - values.put("expanded", new ArrayList()); - values.get("expanded").add(expand.id); - handleExpand(expand.id); + if (autoexpand) { + TupleMessageEx expand = null; + if (count == 1) + expand = single; + else if (unseen == 1) + expand = see; + else if (messages.size() == 1) + expand = messages.get(0); + + if (expand != null && + (expand.content || !metered || (expand.size != null && expand.size < download))) { + if (!values.containsKey("expanded")) + values.put("expanded", new ArrayList()); + values.get("expanded").add(expand.id); + handleExpand(expand.id); + } } } else { if (autoCloseCount > 0 && (autoclose || autonext)) { diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index b1f15388cf..d703567953 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -70,9 +70,10 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O private SwitchCompat swPreview; private SwitchCompat swAddresses; private SwitchCompat swImages; + private SwitchCompat swActionbar; private SwitchCompat swPull; - private SwitchCompat swActionbar; + private SwitchCompat swAutoExpand; private SwitchCompat swAutoClose; private SwitchCompat swAutoNext; private SwitchCompat swAutoRead; @@ -90,20 +91,20 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O private Group grpNotification; static String[] OPTIONS_RESTART = new String[]{ - "unified", "date", "threading", "avatars", "identicons", "preview", "addresses", "autoimages", - "pull", "actionbar", "autoclose", "autonext", "debug" + "unified", "date", "threading", "avatars", "identicons", "preview", "addresses", "autoimages", "actionbar", + "pull", "autoexpand", "autoclose", "autonext", + "debug" }; private final static String[] ADVANCED_OPTIONS = new String[]{ "enabled", "updates", "metered", "download", - "unified", "date", "threading", "avatars", "identicons", "preview", "addresses", - "pull", "actionbar", "autoclose", "autonext", - "autoread", "collapse", "automove", "sender", "autoresize", "autosend", - "light", "sound", "debug", - "first", "why", "last_update_check", - "app_support", "message_swipe", "message_select", - "folder_actions", "folder_sync", + "unified", "date", "threading", "avatars", "identicons", "preview", "addresses", "autoimages", "actionbar", + "pull", "autoexpand", "autoclose", "autonext", "autoread", "collapse", "automove", "sender", "autoresize", "autosend", + "light", "sound", + "debug", + "first", "why", "last_update_check", "app_support", "message_swipe", "message_select", "folder_actions", "folder_sync", + "edit_ref_confirmed", "autosend", "automove", "show_html_confirmed", "show_images_confirmed" }; @Override @@ -130,9 +131,10 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O swPreview = view.findViewById(R.id.swPreview); swAddresses = view.findViewById(R.id.swAddresses); swImages = view.findViewById(R.id.swImages); + swActionbar = view.findViewById(R.id.swActionbar); swPull = view.findViewById(R.id.swPull); - swActionbar = view.findViewById(R.id.swActionbar); + swAutoExpand = view.findViewById(R.id.swAutoExpand); swAutoClose = view.findViewById(R.id.swAutoClose); swAutoNext = view.findViewById(R.id.swAutoNext); swAutoRead = view.findViewById(R.id.swAutoRead); @@ -273,6 +275,14 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O } }); + swActionbar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("actionbar", checked).apply(); + } + }); + + swPull.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -280,10 +290,10 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O } }); - swActionbar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + swAutoExpand.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - prefs.edit().putBoolean("actionbar", checked).apply(); + prefs.edit().putBoolean("autoexpand", checked).apply(); } }); @@ -455,9 +465,10 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O swPreview.setChecked(prefs.getBoolean("preview", false)); swAddresses.setChecked(prefs.getBoolean("addresses", true)); swImages.setChecked(prefs.getBoolean("autoimages", false)); + swActionbar.setChecked(prefs.getBoolean("actionbar", true)); swPull.setChecked(prefs.getBoolean("pull", true)); - swActionbar.setChecked(prefs.getBoolean("actionbar", true)); + swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true)); swAutoClose.setChecked(prefs.getBoolean("autoclose", true)); swAutoNext.setChecked(prefs.getBoolean("autonext", false)); swAutoNext.setEnabled(!swAutoClose.isChecked()); diff --git a/app/src/main/res/layout/fragment_options.xml b/app/src/main/res/layout/fragment_options.xml index 3cf8d2a020..8682f6f28e 100644 --- a/app/src/main/res/layout/fragment_options.xml +++ b/app/src/main/res/layout/fragment_options.xml @@ -361,6 +361,31 @@ app:layout_constraintTop_toBottomOf="@id/vSeparatorBehavior" app:switchPadding="12dp" /> + + + + Select notification sound Pull down to refresh + Automatically expand messages Automatically close conversations Automatically go to next conversation on close conversation Automatically mark messages read on moving messages @@ -177,7 +178,8 @@ Show unified inbox folders or unified inbox messages Group messages related to each other Only available when message text was downloaded - Automatically close conversation threads when all messages are archived, sent or trashed + Automatically open message when there is just one message or just one unread message in a conversation + Automatically close conversations when all messages are archived, sent or trashed Most providers do not allow modified sender addresses Select …