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

View File

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

View File

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

View File

@ -211,6 +211,11 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.save(); GlobalUserPreferences.save();
needAppRestart=true; 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)); items.add(new HeaderItem(R.string.mo_composer_behavior));

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="90"
android:toDegrees="90"
android:pivotX="50%"
android:pivotY="50%"
android:drawable="@drawable/ic_fluent_double_tap_swipe_up_24_regular"/>
</item>
</selector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12.53,2.22C12.237,1.927 11.763,1.927 11.47,2.22L7.97,5.72C7.677,6.013 7.677,6.487 7.97,6.78C8.263,7.073 8.737,7.073 9.03,6.78L11.25,4.561V15.25C11.25,15.664 11.586,16 12,16C12.414,16 12.75,15.664 12.75,15.25V4.561L14.97,6.78C15.263,7.073 15.737,7.073 16.03,6.78C16.323,6.487 16.323,6.013 16.03,5.72L12.53,2.22ZM5,15C5,11.738 7.231,8.998 10.25,8.22V9.784C8.07,10.515 6.5,12.574 6.5,15C6.5,18.038 8.962,20.5 12,20.5C15.038,20.5 17.5,18.038 17.5,15C17.5,12.574 15.93,10.515 13.75,9.784V8.22C16.769,8.998 19,11.738 19,15C19,18.866 15.866,22 12,22C8.134,22 5,18.866 5,15ZM7.5,15C7.5,13.135 8.634,11.536 10.25,10.853V12.563C9.493,13.108 9,13.996 9,15C9,16.657 10.343,18 12,18C13.657,18 15,16.657 15,15C15,13.996 14.507,13.108 13.75,12.563V10.853C15.366,11.536 16.5,13.135 16.5,15C16.5,17.485 14.485,19.5 12,19.5C9.515,19.5 7.5,17.485 7.5,15Z"
android:fillColor="#212121"/>
</vector>

View File

@ -49,6 +49,7 @@
<string name="mo_duration_days_7">7 days</string> <string name="mo_duration_days_7">7 days</string>
<string name="mo_share_open_url">Open in App</string> <string name="mo_share_open_url">Open in App</string>
<string name="mo_disable_double_tap_to_swipe_between_tabs">Disable double tap to swipe between tabs</string>
</resources> </resources>