mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 14:11:00 +00:00
Added option to disable pull down to refresh
This commit is contained in:
parent
a280d034ec
commit
558eec538f
5 changed files with 41 additions and 10 deletions
|
@ -42,7 +42,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||||
|
|
||||||
private static String[] restart = new String[]{
|
private static String[] restart = new String[]{
|
||||||
"unified", "threading", "compact", "avatars", "identicons", "preview",
|
"unified", "threading", "compact", "avatars", "identicons", "preview",
|
||||||
"browse", "actionbar", "autoclose", "confirm", "debug"
|
"pull", "actionbar", "autoclose", "confirm", "debug"
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -109,6 +109,7 @@ public class FragmentMessages extends FragmentEx {
|
||||||
|
|
||||||
private boolean compact;
|
private boolean compact;
|
||||||
private boolean threading;
|
private boolean threading;
|
||||||
|
private boolean pull;
|
||||||
private boolean actionbar;
|
private boolean actionbar;
|
||||||
private boolean autoclose;
|
private boolean autoclose;
|
||||||
|
|
||||||
|
@ -150,12 +151,6 @@ public class FragmentMessages extends FragmentEx {
|
||||||
id = args.getLong("id", -1);
|
id = args.getLong("id", -1);
|
||||||
search = args.getString("search");
|
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 (TextUtils.isEmpty(search))
|
||||||
if (thread == null)
|
if (thread == null)
|
||||||
if (folder < 0)
|
if (folder < 0)
|
||||||
|
@ -166,6 +161,19 @@ public class FragmentMessages extends FragmentEx {
|
||||||
viewType = AdapterMessage.ViewType.THREAD;
|
viewType = AdapterMessage.ViewType.THREAD;
|
||||||
else
|
else
|
||||||
viewType = AdapterMessage.ViewType.SEARCH;
|
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
|
@Override
|
||||||
|
@ -442,7 +450,7 @@ public class FragmentMessages extends FragmentEx {
|
||||||
fabMore.hide();
|
fabMore.hide();
|
||||||
if (getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
if (getViewLifecycleOwner().getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||||
loadMessages();
|
loadMessages();
|
||||||
swipeRefresh.setEnabled(true);
|
swipeRefresh.setEnabled(pull);
|
||||||
}
|
}
|
||||||
} catch (IllegalStateException ex) {
|
} catch (IllegalStateException ex) {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
|
@ -1187,7 +1195,7 @@ public class FragmentMessages extends FragmentEx {
|
||||||
((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener);
|
((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener);
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
swipeRefresh.setEnabled(viewType == AdapterMessage.ViewType.UNIFIED || viewType == AdapterMessage.ViewType.FOLDER);
|
swipeRefresh.setEnabled(pull);
|
||||||
tvNoEmail.setVisibility(View.GONE);
|
tvNoEmail.setVisibility(View.GONE);
|
||||||
bottom_navigation.setVisibility(View.GONE);
|
bottom_navigation.setVisibility(View.GONE);
|
||||||
grpReady.setVisibility(View.GONE);
|
grpReady.setVisibility(View.GONE);
|
||||||
|
|
|
@ -68,6 +68,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||||
private SwitchCompat swLight;
|
private SwitchCompat swLight;
|
||||||
private Button btnSound;
|
private Button btnSound;
|
||||||
|
|
||||||
|
private SwitchCompat swPull;
|
||||||
private SwitchCompat swSwipe;
|
private SwitchCompat swSwipe;
|
||||||
private SwitchCompat swActionbar;
|
private SwitchCompat swActionbar;
|
||||||
private SwitchCompat swAutoClose;
|
private SwitchCompat swAutoClose;
|
||||||
|
@ -106,6 +107,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||||
swLight = view.findViewById(R.id.swLight);
|
swLight = view.findViewById(R.id.swLight);
|
||||||
btnSound = view.findViewById(R.id.btnSound);
|
btnSound = view.findViewById(R.id.btnSound);
|
||||||
|
|
||||||
|
swPull = view.findViewById(R.id.swPull);
|
||||||
swSwipe = view.findViewById(R.id.swSwipe);
|
swSwipe = view.findViewById(R.id.swSwipe);
|
||||||
swActionbar = view.findViewById(R.id.swActionbar);
|
swActionbar = view.findViewById(R.id.swActionbar);
|
||||||
swAutoClose = view.findViewById(R.id.swAutoClose);
|
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.setChecked(prefs.getBoolean("swipe", true));
|
||||||
swSwipe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swSwipe.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -286,6 +286,18 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvSectionBehavior" />
|
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
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
android:id="@+id/swSwipe"
|
android:id="@+id/swSwipe"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -295,7 +307,7 @@
|
||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
android:text="@string/title_advanced_swipe"
|
android:text="@string/title_advanced_swipe"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/vSeparator4"
|
app:layout_constraintTop_toBottomOf="@id/swPull"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
|
|
@ -132,6 +132,7 @@
|
||||||
<string name="title_advanced_light">Use notification light</string>
|
<string name="title_advanced_light">Use notification light</string>
|
||||||
<string name="title_advanced_sound">Select notification sound</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_swipe">Swipe actions</string>
|
||||||
<string name="title_advanced_actionbar">Conversation action bar</string>
|
<string name="title_advanced_actionbar">Conversation action bar</string>
|
||||||
<string name="title_advanced_autoclose">Automatically close conversations</string>
|
<string name="title_advanced_autoclose">Automatically close conversations</string>
|
||||||
|
|
Loading…
Reference in a new issue