From 1d9b8a8bdeae1b8d34e4aaf49ed19fc6e3e138cf Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 13 Oct 2018 16:01:35 +0000 Subject: [PATCH] Added advanced option to disable swipe actions --- .../java/eu/faircode/email/FragmentMessages.java | 3 +++ .../main/java/eu/faircode/email/FragmentOptions.java | 11 +++++++++++ app/src/main/res/layout/fragment_options.xml | 12 +++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 15b4971c..b1f50d1f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -177,6 +177,9 @@ public class FragmentMessages extends FragmentEx { new ItemTouchHelper(new ItemTouchHelper.Callback() { @Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { + if (!prefs.getBoolean("swipe", true)) + return 0; + int pos = viewHolder.getAdapterPosition(); if (pos == RecyclerView.NO_POSITION) return 0; diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index 9e14f914..293b35ed 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -36,6 +36,7 @@ public class FragmentOptions extends FragmentEx { private CheckBox cbAvatars; private CheckBox cbLight; private CheckBox cbBrowse; + private CheckBox cbSwipe; private CheckBox cbDebug; @Override @@ -50,6 +51,7 @@ public class FragmentOptions extends FragmentEx { cbAvatars = view.findViewById(R.id.cbAvatars); cbLight = view.findViewById(R.id.cbLight); cbBrowse = view.findViewById(R.id.cbBrowse); + cbSwipe = view.findViewById(R.id.cbSwipe); cbDebug = view.findViewById(R.id.cbDebug); // Wire controls @@ -92,6 +94,15 @@ public class FragmentOptions extends FragmentEx { } }); + cbSwipe.setChecked(prefs.getBoolean("swipe", true)); + cbSwipe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("swipe", checked).apply(); + ServiceSynchronize.reload(getContext(), "swipe=" + checked); + } + }); + cbDebug.setChecked(prefs.getBoolean("debug", false)); cbDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override diff --git a/app/src/main/res/layout/fragment_options.xml b/app/src/main/res/layout/fragment_options.xml index 625094ab..88090382 100644 --- a/app/src/main/res/layout/fragment_options.xml +++ b/app/src/main/res/layout/fragment_options.xml @@ -51,6 +51,16 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/cbLight" /> + + + app:layout_constraintTop_toBottomOf="@id/cbSwipe" /> \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2a4ae566..80f5d0dc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -83,6 +83,7 @@ Show contact photos Use notification light Browse messages on the server + Swipe actions Debug mode Select …