Set swipe velocity threshold

This commit is contained in:
M66B 2023-05-05 22:56:45 +02:00
parent 13c6d8a0a9
commit e45e229592
3 changed files with 24 additions and 3 deletions

View File

@ -700,6 +700,19 @@ public class ApplicationEx extends Application
editor.putBoolean("plain_only_reply", true);
} else if (version < 2046)
editor.remove("message_junk");
else if (version < 2069) {
if (prefs.contains("swipe_sensitivity") && !prefs.contains("swipe_sensitivity_updated")) {
int swipe_sensitivity = prefs.getInt("swipe_sensitivity", FragmentOptionsBehavior.DEFAULT_SWIPE_SENSITIVITY);
if (swipe_sensitivity > 0) {
swipe_sensitivity--;
if (swipe_sensitivity == FragmentOptionsBehavior.DEFAULT_SWIPE_SENSITIVITY)
editor.remove("swipe_sensitivity");
else
editor.putInt("swipe_sensitivity", swipe_sensitivity - 1)
.putBoolean("swipe_sensitivity_updated", true);
}
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)
editor.remove("background_service");

View File

@ -2748,14 +2748,22 @@ public class FragmentMessages extends FragmentBase
@Override
public float getSwipeEscapeVelocity(float defaultValue) {
return super.getSwipeEscapeVelocity(defaultValue) * getSwipeSensitivityFactor();
}
@Override
public float getSwipeVelocityThreshold(float defaultValue) {
return super.getSwipeVelocityThreshold(defaultValue) * getSwipeSensitivityFactor();
}
private int getSwipeSensitivityFactor() {
int swipe_sensitivity = FragmentOptionsBehavior.DEFAULT_SWIPE_SENSITIVITY;
Context context = getContext();
if (context != null) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
swipe_sensitivity = prefs.getInt("swipe_sensitivity", swipe_sensitivity);
}
return super.getSwipeEscapeVelocity(defaultValue) *
(FragmentOptionsBehavior.MAX_SWIPE_SENSITIVITY - swipe_sensitivity + 1);
return (FragmentOptionsBehavior.MAX_SWIPE_SENSITIVITY - swipe_sensitivity + 1);
}
@Override

View File

@ -107,7 +107,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private boolean accessibility;
final static int MAX_SWIPE_SENSITIVITY = 10;
final static int DEFAULT_SWIPE_SENSITIVITY = 7;
final static int DEFAULT_SWIPE_SENSITIVITY = 6;
final static int REQUEST_DEFAULT_FOLDER = 1;