Added option to reverse swipe direction

pull/162/head
M66B 5 years ago
parent e301d9ce16
commit 0205df9274

@ -2233,6 +2233,8 @@ Similarly, if you read from right to left, swiping to the right will show the ne
This behavior seems quite natural to me, also because it is similar to turning pages.
Anyway, there is a behavior setting to reverse the swipe direction.
<br />
<a name="faq132"></a>

@ -944,29 +944,33 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (swipenav) {
Log.i("Swipe navigation");
boolean ltr = (getContext().getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR);
final SwipeListener swipeListener = new SwipeListener(getContext(), new SwipeListener.ISwipeListener() {
@Override
public boolean onSwipeRight() {
if (previous == null) {
boolean rtl = prefs.getBoolean("swipe_reversed", false);
Long go = (rtl ? next : previous);
if (go == null) {
Animation bounce = AnimationUtils.loadAnimation(getContext(), R.anim.bounce_right);
view.startAnimation(bounce);
} else
navigate(previous, ltr);
navigate(go, true);
return (previous != null);
return (go != null);
}
@Override
public boolean onSwipeLeft() {
if (next == null) {
boolean rtl = prefs.getBoolean("swipe_reversed", false);
Long go = (rtl ? previous : next);
if (go == null) {
Animation bounce = AnimationUtils.loadAnimation(getContext(), R.anim.bounce_left);
view.startAnimation(bounce);
} else
navigate(next, !ltr);
navigate(go, false);
return (next != null);
return (go != null);
}
});

@ -43,6 +43,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swPull;
private SwitchCompat swAutoScroll;
private SwitchCompat swSwipeNav;
private SwitchCompat swSwipeReversed;
private SwitchCompat swDoubleTap;
private SwitchCompat swExpandRead;
private SwitchCompat swAutoExpand;
@ -55,7 +56,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swDisableTracking;
private final static String[] RESET_OPTIONS = new String[]{
"pull", "autoscroll", "swipenav", "doubletap", "expand_read", "autoexpand", "autoclose", "onclose",
"pull", "autoscroll", "swipenav", "swipe_reversed", "doubletap", "expand_read", "autoexpand", "autoclose", "onclose",
"collapse", "autoread", "automove", "discard_delete", "disable_tracking"
};
@ -72,6 +73,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swPull = view.findViewById(R.id.swPull);
swAutoScroll = view.findViewById(R.id.swAutoScroll);
swSwipeNav = view.findViewById(R.id.swSwipeNav);
swSwipeReversed = view.findViewById(R.id.swSwipeReversed);
swDoubleTap = view.findViewById(R.id.swDoubleTap);
swExpandRead = view.findViewById(R.id.swExpandRead);
swAutoExpand = view.findViewById(R.id.swAutoExpand);
@ -107,6 +109,14 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("swipenav", checked).apply();
swSwipeReversed.setEnabled(checked);
}
});
swSwipeReversed.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("swipe_reversed", checked).apply();
}
});
@ -240,6 +250,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swPull.setChecked(prefs.getBoolean("pull", true));
swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false));
swSwipeNav.setChecked(prefs.getBoolean("swipenav", true));
swSwipeReversed.setChecked(prefs.getBoolean("swipe_reversed", false));
swSwipeReversed.setEnabled(swSwipeNav.isChecked());
swDoubleTap.setChecked(prefs.getBoolean("doubletap", false));
swExpandRead.setChecked(prefs.getBoolean("expand_read", true));
swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true));

@ -53,6 +53,18 @@
app:layout_constraintTop_toBottomOf="@id/swAutoScroll"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSwipeReversed"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_swipe_reversed"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSwipeNav"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDoubleTap"
android:layout_width="0dp"
@ -61,7 +73,7 @@
android:text="@string/title_advanced_double_tap"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSwipeNav"
app:layout_constraintTop_toBottomOf="@id/swSwipeReversed"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -263,6 +263,7 @@
<string name="title_advanced_pull_refresh">Pull down to refresh</string>
<string name="title_advanced_autoscroll">Scroll to top on receiving new messages</string>
<string name="title_advanced_swipenav">Swipe left/right to go to next/previous conversation</string>
<string name="title_advanced_swipe_reversed">Reverse swipe direction</string>
<string name="title_advanced_double_tap">Double tap to mark message read/unread</string>
<string name="title_advanced_expand_read">Mark messages read on expanding</string>
<string name="title_advanced_autoexpand">Automatically expand messages</string>

Loading…
Cancel
Save