1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-03-04 02:28:18 +00:00

Added option to reverse swipe direction

This commit is contained in:
M66B 2019-09-14 09:56:09 +02:00
parent e301d9ce16
commit 0205df9274
5 changed files with 41 additions and 10 deletions

2
FAQ.md
View file

@ -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. 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 /> <br />
<a name="faq132"></a> <a name="faq132"></a>

View file

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

View file

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

View file

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

View file

@ -263,6 +263,7 @@
<string name="title_advanced_pull_refresh">Pull down to refresh</string> <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_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_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_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_expand_read">Mark messages read on expanding</string>
<string name="title_advanced_autoexpand">Automatically expand messages</string> <string name="title_advanced_autoexpand">Automatically expand messages</string>