feat: add toggle to disable double tap to swipe action

This commit is contained in:
LucasGGamerM
2023-03-19 11:20:46 -03:00
parent addb1b27bb
commit c0484de506
7 changed files with 31 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ public class GlobalUserPreferences{
public static boolean autoHideFab;
public static boolean unreadNotifications;
public static boolean defaultToUnlistedReplies;
public static boolean disableDoubleTapToSwipe;
public static String publishButtonText;
public static ThemePreference theme;
public static ColorPreference color;
@@ -105,6 +106,7 @@ public class GlobalUserPreferences{
autoHideFab=prefs.getBoolean("autoHideFab", true);
unreadNotifications=prefs.getBoolean("unreadNotifications", false);
defaultToUnlistedReplies=prefs.getBoolean("defaultToUnlistedReplies", false);
disableDoubleTapToSwipe=prefs.getBoolean("disableDoubleTapToSwipe", false);
publishButtonText=prefs.getString("publishButtonText", "");
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>());
@@ -158,6 +160,7 @@ public class GlobalUserPreferences{
.putString("publishButtonText", publishButtonText)
.putBoolean("bottomEncoding", bottomEncoding)
.putBoolean("defaultToUnlistedReplies", defaultToUnlistedReplies)
.putBoolean("disableDoubleTapToSwipe", disableDoubleTapToSwipe)
.putInt("theme", theme.ordinal())
.putString("color", color.name())
.putString("recentLanguages", gson.toJson(recentLanguages))

View File

@@ -477,7 +477,7 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
@Override
public void scrollToTop(){
if (((ScrollableToTop) fragments[pager.getCurrentItem()]).isScrolledToTop()) {
if (((ScrollableToTop) fragments[pager.getCurrentItem()]).isScrolledToTop() && !GlobalUserPreferences.disableDoubleTapToSwipe) {
int nextPage = (pager.getCurrentItem() + 1) % count;
navigateTo(nextPage);
return;

View File

@@ -202,7 +202,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
@Override
public void scrollToTop(){
if (getFragmentForPage(pager.getCurrentItem()).isScrolledToTop()) {
if (getFragmentForPage(pager.getCurrentItem()).isScrolledToTop() && !GlobalUserPreferences.disableDoubleTapToSwipe) {
int nextPage = (pager.getCurrentItem() + 1) % tabViews.length;
pager.setCurrentItem(nextPage, true);
return;

View File

@@ -211,6 +211,11 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.save();
needAppRestart=true;
}));
items.add(new SwitchItem(R.string.mo_disable_double_tap_to_swipe_between_tabs, R.drawable.ic_fluent_double_tap_swipe_right_24_regular, GlobalUserPreferences.disableDoubleTapToSwipe, i->{
GlobalUserPreferences.disableDoubleTapToSwipe=i.checked;
GlobalUserPreferences.save();
needAppRestart=true;
}));
items.add(new HeaderItem(R.string.mo_composer_behavior));