Added option to disable previous/next navigation

pull/146/head
M66B 6 years ago
parent d8af4cb378
commit f82be4777d

@ -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();

@ -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

@ -109,6 +109,7 @@ public class FragmentSetup extends FragmentEx {
"browse",
"swipe",
"compat",
"navigation",
"insecure",
"sort"
);

@ -167,7 +167,7 @@
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_height="wrap_content"
android:background="?attr/colorSeparator"
app:itemIconTint="@color/bottomnav_background"
app:itemTextColor="@color/bottomnav_background"

@ -65,6 +65,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSwipe" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_nav"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swCompact" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swInsecure"
android:layout_width="match_parent"
@ -72,7 +81,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_allow_insecure"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swCompact" />
app:layout_constraintTop_toBottomOf="@id/swNav" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDebug"

@ -86,6 +86,7 @@
<string name="title_advanced_browse">Browse messages on the server</string>
<string name="title_advanced_swipe">Swipe actions</string>
<string name="title_advanced_compact">Compact message view</string>
<string name="title_advanced_nav">Previous/next navigation</string>
<string name="title_advanced_debug">Debug mode</string>
<string name="title_select">Select &#8230;</string>

Loading…
Cancel
Save