From f82be4777d93388d0db86c21528fe2e52596c15b Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 2 Nov 2018 19:37:44 +0000 Subject: [PATCH] Added option to disable previous/next navigation --- .../main/java/eu/faircode/email/FragmentMessages.java | 3 ++- .../main/java/eu/faircode/email/FragmentOptions.java | 10 ++++++++++ .../main/java/eu/faircode/email/FragmentSetup.java | 1 + app/src/main/res/layout/fragment_messages.xml | 2 +- app/src/main/res/layout/fragment_options.xml | 11 ++++++++++- app/src/main/res/values/strings.xml | 1 + 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 97bb1ef95c..5b9cb6a094 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -815,12 +815,13 @@ public class FragmentMessages extends FragmentEx { if (viewType == AdapterMessage.ViewType.THREAD) { // Navigation + boolean nav = prefs.getBoolean("navigation", true); ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class); ViewModelMessages.Target[] pn = model.getPrevNext(thread); bottom_navigation.setTag(pn); 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.setVisibility(pn[0] == null && pn[1] == null ? View.GONE : View.VISIBLE); + bottom_navigation.setVisibility(!nav || (pn[0] == null && pn[1] == null) ? View.GONE : View.VISIBLE); } else { // Compose FAB Bundle args = new Bundle(); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index 79d87a8747..028a5f0c78 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -38,6 +38,7 @@ public class FragmentOptions extends FragmentEx { private SwitchCompat swBrowse; private SwitchCompat swSwipe; private SwitchCompat swCompact; + private SwitchCompat swNav; private SwitchCompat swInsecure; private SwitchCompat swDebug; @@ -55,6 +56,7 @@ public class FragmentOptions extends FragmentEx { swBrowse = view.findViewById(R.id.swBrowse); swSwipe = view.findViewById(R.id.swSwipe); swCompact = view.findViewById(R.id.swCompact); + swNav = view.findViewById(R.id.swNav); swInsecure = view.findViewById(R.id.swInsecure); swDebug = view.findViewById(R.id.swDebug); @@ -114,6 +116,14 @@ public class FragmentOptions extends FragmentEx { } }); + swNav.setChecked(prefs.getBoolean("navigation", true)); + swNav.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("navigation", checked).apply(); + } + }); + swInsecure.setChecked(prefs.getBoolean("insecure", false)); swInsecure.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java index 77d03c6cb5..b9d5fb7085 100644 --- a/app/src/main/java/eu/faircode/email/FragmentSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java @@ -109,6 +109,7 @@ public class FragmentSetup extends FragmentEx { "browse", "swipe", "compat", + "navigation", "insecure", "sort" ); diff --git a/app/src/main/res/layout/fragment_messages.xml b/app/src/main/res/layout/fragment_messages.xml index 67c96949e6..3abcd61fb4 100644 --- a/app/src/main/res/layout/fragment_messages.xml +++ b/app/src/main/res/layout/fragment_messages.xml @@ -167,7 +167,7 @@ + + + app:layout_constraintTop_toBottomOf="@id/swNav" /> Browse messages on the server Swipe actions Compact message view + Previous/next navigation Debug mode Select …