From 558eec538f0c1334a445f192bf5ee1499c8b5b91 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 3 Jan 2019 12:14:14 +0100 Subject: [PATCH] Added option to disable pull down to refresh --- .../java/eu/faircode/email/ActivityBase.java | 2 +- .../eu/faircode/email/FragmentMessages.java | 24 ++++++++++++------- .../eu/faircode/email/FragmentOptions.java | 10 ++++++++ app/src/main/res/layout/fragment_options.xml | 14 ++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index 9ca393b509..c01ade516d 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -42,7 +42,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc private static String[] restart = new String[]{ "unified", "threading", "compact", "avatars", "identicons", "preview", - "browse", "actionbar", "autoclose", "confirm", "debug" + "pull", "actionbar", "autoclose", "confirm", "debug" }; @Override diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 63cacbec8d..deb09e8c4c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -109,6 +109,7 @@ public class FragmentMessages extends FragmentEx { private boolean compact; private boolean threading; + private boolean pull; private boolean actionbar; private boolean autoclose; @@ -150,12 +151,6 @@ public class FragmentMessages extends FragmentEx { id = args.getLong("id", -1); search = args.getString("search"); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - compact = prefs.getBoolean("compact", false); - threading = prefs.getBoolean("threading", true); - actionbar = prefs.getBoolean("actionbar", true); - autoclose = prefs.getBoolean("autoclose", true); - if (TextUtils.isEmpty(search)) if (thread == null) if (folder < 0) @@ -166,6 +161,19 @@ public class FragmentMessages extends FragmentEx { viewType = AdapterMessage.ViewType.THREAD; else viewType = AdapterMessage.ViewType.SEARCH; + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + compact = prefs.getBoolean("compact", false); + + if (viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER) + pull = prefs.getBoolean("pull", true); + else + pull = false; + + threading = prefs.getBoolean("threading", true); + actionbar = prefs.getBoolean("actionbar", true); + autoclose = prefs.getBoolean("autoclose", true); + } @Override @@ -442,7 +450,7 @@ public class FragmentMessages extends FragmentEx { fabMore.hide(); if (getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) loadMessages(); - swipeRefresh.setEnabled(true); + swipeRefresh.setEnabled(pull); } } catch (IllegalStateException ex) { Log.w(ex); @@ -1187,7 +1195,7 @@ public class FragmentMessages extends FragmentEx { ((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener); // Initialize - swipeRefresh.setEnabled(viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER); + swipeRefresh.setEnabled(pull); tvNoEmail.setVisibility(View.GONE); bottom_navigation.setVisibility(View.GONE); grpReady.setVisibility(View.GONE); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index 8823c75816..dcd4550eea 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -68,6 +68,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS private SwitchCompat swLight; private Button btnSound; + private SwitchCompat swPull; private SwitchCompat swSwipe; private SwitchCompat swActionbar; private SwitchCompat swAutoClose; @@ -106,6 +107,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS swLight = view.findViewById(R.id.swLight); btnSound = view.findViewById(R.id.btnSound); + swPull = view.findViewById(R.id.swPull); swSwipe = view.findViewById(R.id.swSwipe); swActionbar = view.findViewById(R.id.swActionbar); swAutoClose = view.findViewById(R.id.swAutoClose); @@ -272,6 +274,14 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS } }); + swPull.setChecked(prefs.getBoolean("pull", true)); + swPull.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("pull", checked).apply(); + } + }); + swSwipe.setChecked(prefs.getBoolean("swipe", true)); swSwipe.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 b042dde2a8..a07a8c099f 100644 --- a/app/src/main/res/layout/fragment_options.xml +++ b/app/src/main/res/layout/fragment_options.xml @@ -286,6 +286,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvSectionBehavior" /> + + Use notification light Select notification sound + Pull down to refresh Swipe actions Conversation action bar Automatically close conversations