diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 848097934b..dd23ab6220 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -123,9 +123,9 @@ public class FragmentMessages extends FragmentBase { private boolean autonext; private boolean addresses; - private long primary = -1; + private Long primary = null; private boolean outbox = false; - private boolean connected = false; + private Boolean connected = null; private boolean searching = false; private AdapterMessage adapter; @@ -1396,7 +1396,8 @@ public class FragmentMessages extends FragmentBase { public void onChanged(EntityAccount account) { long primary = (account == null ? -1 : account.id); boolean connected = (account != null && "connected".equals(account.state)); - if (FragmentMessages.this.primary != primary || FragmentMessages.this.connected != connected) { + if (FragmentMessages.this.primary == null || FragmentMessages.this.connected == null || + FragmentMessages.this.primary != primary || FragmentMessages.this.connected != connected) { FragmentMessages.this.primary = primary; FragmentMessages.this.connected = connected; getActivity().invalidateOptionsMenu(); @@ -1649,8 +1650,10 @@ public class FragmentMessages extends FragmentBase { menu.findItem(R.id.menu_search).setVisible(viewType != AdapterMessage.ViewType.SEARCH); - menu.findItem(R.id.menu_folders).setVisible(primary >= 0); - menu.findItem(R.id.menu_folders).setIcon(connected ? R.drawable.baseline_folder_24 : R.drawable.baseline_folder_open_24); + menu.findItem(R.id.menu_folders).setVisible(primary == null || primary >= 0); + menu.findItem(R.id.menu_folders).setEnabled(primary != null); + menu.findItem(R.id.menu_folders).setIcon( + connected != null && connected ? R.drawable.baseline_folder_24 : R.drawable.baseline_folder_open_24); menu.findItem(R.id.menu_sort_on).setVisible(!selection && (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER));