Auto close only when no navigation

pull/146/head
M66B 6 years ago
parent 01f557093f
commit 36e53aa2b0

@ -23,9 +23,7 @@ For:
## Planned features ## Planned features
* Notifications per account * Notifications per account
* Disable autoclose for conversations(for previous/next navigation)
* IMAP namespaces * IMAP namespaces
* Fixed action bar conversations
* Microsoft OAuth * Microsoft OAuth
Anything on this list is in random order and *might* be added in the near future. Anything on this list is in random order and *might* be added in the near future.

@ -97,6 +97,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
"identicons".equals(key) || "identicons".equals(key) ||
"preview".equals(key) || "preview".equals(key) ||
"confirm".equals(key) || "confirm".equals(key) ||
"navigation".equals(key) ||
"debug".equals(key))) "debug".equals(key)))
finish(); finish();
} }

@ -96,6 +96,8 @@ public class FragmentMessages extends FragmentEx {
private boolean found = false; private boolean found = false;
private String search = null; private String search = null;
private boolean navigation = true;
private long primary = -1; private long primary = -1;
private boolean outbox = false; private boolean outbox = false;
private boolean connected = false; private boolean connected = false;
@ -135,6 +137,9 @@ public class FragmentMessages extends FragmentEx {
found = args.getBoolean("found", false); found = args.getBoolean("found", false);
search = args.getString("search"); search = args.getString("search");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
navigation = prefs.getBoolean("navigation", true);
if (TextUtils.isEmpty(search)) if (TextUtils.isEmpty(search))
if (thread == null) if (thread == null)
if (folder < 0) if (folder < 0)
@ -876,13 +881,12 @@ public class FragmentMessages extends FragmentEx {
if (viewType == AdapterMessage.ViewType.THREAD) { if (viewType == AdapterMessage.ViewType.THREAD) {
// Navigation // Navigation
boolean nav = prefs.getBoolean("navigation", true);
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class); ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
ViewModelMessages.Target[] pn = model.getPrevNext(thread); ViewModelMessages.Target[] pn = model.getPrevNext(thread);
bottom_navigation.setTag(pn); bottom_navigation.setTag(pn);
bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(pn[0] != null); bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(pn[0] != null);
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(pn[1] != null); bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(pn[1] != null);
bottom_navigation.setVisibility(!nav || (pn[0] == null && pn[1] == null) ? View.GONE : View.VISIBLE); bottom_navigation.setVisibility(!navigation || (pn[0] == null && pn[1] == null) ? View.GONE : View.VISIBLE);
} else { } else {
db.account().liveAccountDraft(account < 0 ? null : account).observe(getViewLifecycleOwner(), new Observer<EntityAccount>() { db.account().liveAccountDraft(account < 0 ? null : account).observe(getViewLifecycleOwner(), new Observer<EntityAccount>() {
@Override @Override
@ -1226,7 +1230,7 @@ public class FragmentMessages extends FragmentEx {
handleExpand(expand.id); handleExpand(expand.id);
} }
} else { } else {
if (autoCount > 0) { if (autoCount > 0 && navigation) {
int count = 0; int count = 0;
for (int i = 0; i < messages.size(); i++) { for (int i = 0; i < messages.size(); i++) {
TupleMessageEx message = messages.get(i); TupleMessageEx message = messages.get(i);

Loading…
Cancel
Save