mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 11:28:41 +01:00
Added option to reverse swipe direction
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user