From 0205df92740bd62221065563e7c2faf6dceb5adc Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 14 Sep 2019 09:56:09 +0200 Subject: [PATCH] Added option to reverse swipe direction --- FAQ.md | 2 ++ .../eu/faircode/email/FragmentMessages.java | 20 +++++++++++-------- .../email/FragmentOptionsBehavior.java | 14 ++++++++++++- .../res/layout/fragment_options_behavior.xml | 14 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/FAQ.md b/FAQ.md index 2f33d3b758..dbb9f095e9 100644 --- a/FAQ.md +++ b/FAQ.md @@ -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. +
diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 9d6bc93dae..ea94eda7a1 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -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); } }); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java index 0f4abbbc79..1f8659fbea 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java @@ -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)); diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml index f82d14da2b..d3f2c7a002 100644 --- a/app/src/main/res/layout/fragment_options_behavior.xml +++ b/app/src/main/res/layout/fragment_options_behavior.xml @@ -53,6 +53,18 @@ app:layout_constraintTop_toBottomOf="@id/swAutoScroll" app:switchPadding="12dp" /> + + Pull down to refresh Scroll to top on receiving new messages Swipe left/right to go to next/previous conversation + Reverse swipe direction Double tap to mark message read/unread Mark messages read on expanding Automatically expand messages