Added option to disable pull down to refresh

This commit is contained in:
M66B 2019-01-03 12:14:14 +01:00
parent a280d034ec
commit 558eec538f
5 changed files with 41 additions and 10 deletions

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -286,6 +286,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSectionBehavior" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPull"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_pull_refresh"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator4"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSwipe"
android:layout_width="match_parent"
@ -295,7 +307,7 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_swipe"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparator4"
app:layout_constraintTop_toBottomOf="@id/swPull"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

@ -132,6 +132,7 @@
<string name="title_advanced_light">Use notification light</string>
<string name="title_advanced_sound">Select notification sound</string>
<string name="title_advanced_pull_refresh">Pull down to refresh</string>
<string name="title_advanced_swipe">Swipe actions</string>
<string name="title_advanced_actionbar">Conversation action bar</string>
<string name="title_advanced_autoclose">Automatically close conversations</string>