add option to disable swiping

closes sk22#165
This commit is contained in:
sk 2022-12-19 11:31:38 -03:00 committed by LucasGGamerM
parent e4e9516d5d
commit d0d1d15de5
7 changed files with 78 additions and 62 deletions

View File

@ -25,6 +25,7 @@ public class GlobalUserPreferences{
public static boolean showInteractionCounts;
public static boolean alwaysExpandContentWarnings;
public static boolean disableMarquee;
public static boolean disableSwipe;
public static boolean voteButtonForSingleChoice;
public static ThemePreference theme;
public static ColorPreference color;
@ -54,6 +55,7 @@ public class GlobalUserPreferences{
showInteractionCounts=prefs.getBoolean("showInteractionCounts", false);
alwaysExpandContentWarnings=prefs.getBoolean("alwaysExpandContentWarnings", false);
disableMarquee=prefs.getBoolean("disableMarquee", false);
disableSwipe=prefs.getBoolean("disableSwipe", false);
voteButtonForSingleChoice=prefs.getBoolean("voteButtonForSingleChoice", true);
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>());
@ -77,6 +79,7 @@ public class GlobalUserPreferences{
.putBoolean("showInteractionCounts", showInteractionCounts)
.putBoolean("alwaysExpandContentWarnings", alwaysExpandContentWarnings)
.putBoolean("disableMarquee", disableMarquee)
.putBoolean("disableSwipe", disableSwipe)
.putInt("theme", theme.ordinal())
.putString("recentLanguages", gson.toJson(recentLanguages))
.putInt("color", color.ordinal())

View File

@ -14,6 +14,7 @@ import android.widget.FrameLayout;
import android.widget.LinearLayout;
import org.joinmastodon.android.E;
import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.R;
import org.joinmastodon.android.api.requests.accounts.GetFollowRequests;
import org.joinmastodon.android.events.FollowRequestHandledEvent;
@ -109,6 +110,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc
tabLayout.setTabTextColors(UiUtils.getThemeColor(getActivity(), R.attr.colorTabInactive), UiUtils.getThemeColor(getActivity(), android.R.attr.textColorPrimary));
pager.setOffscreenPageLimit(4);
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
pager.setAdapter(new DiscoverPagerAdapter());
pager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback(){
@Override

View File

@ -237,6 +237,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
}
pager.setOffscreenPageLimit(5);
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
pager.setAdapter(new ProfilePagerAdapter());
pager.getLayoutParams().height=getResources().getDisplayMetrics().heightPixels;

View File

@ -121,6 +121,11 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.alwaysExpandContentWarnings=i.checked;
GlobalUserPreferences.save();
}));
items.add(new SwitchItem(R.string.sk_tabs_disable_swipe, R.drawable.ic_fluent_swipe_right_24_regular, GlobalUserPreferences.disableSwipe, i->{
GlobalUserPreferences.disableSwipe=i.checked;
GlobalUserPreferences.save();
needAppRestart=true;
}));
items.add(new HeaderItem(R.string.home_timeline));
items.add(new SwitchItem(R.string.sk_settings_show_replies, R.drawable.ic_fluent_chat_multiple_24_regular, GlobalUserPreferences.showReplies, i->{

View File

@ -104,6 +104,7 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
tabLayout.setTabTextColors(UiUtils.getThemeColor(getActivity(), R.attr.colorTabInactive), UiUtils.getThemeColor(getActivity(), android.R.attr.textColorPrimary));
pager.setOffscreenPageLimit(4);
pager.setUserInputEnabled(!GlobalUserPreferences.disableSwipe);
pager.setAdapter(new DiscoverPagerAdapter());
pager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback(){
@Override

View File

@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M5.997 12c0 0.38 0.282 0.694 0.647 0.743l0.102 0.007H19.44l-2.216 2.22c-0.266 0.266-0.29 0.683-0.073 0.976l0.073 0.084c0.266 0.267 0.682 0.29 0.975 0.073l0.084-0.073 3.497-3.5c0.267-0.266 0.29-0.683 0.073-0.976L21.78 11.47l-3.497-3.5c-0.292-0.293-0.767-0.293-1.06 0-0.265 0.266-0.29 0.683-0.072 0.976l0.073 0.084 2.216 2.22H6.746c-0.414 0-0.75 0.336-0.75 0.75zM2 12c0 2.761 2.237 5 4.996 5 2.143 0 3.972-1.351 4.68-3.25h-1.651C9.42 14.797 8.29 15.5 6.995 15.5 5.066 15.5 3.5 13.933 3.5 12s1.565-3.5 3.497-3.5c1.294 0 2.425 0.704 3.03 1.75h1.651C10.968 8.352 9.14 7 6.996 7 4.236 7 2 9.239 2 12z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@ -1,65 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="sk_app_name" translatable="false">Moshidon</string>
<string name="sk_pinned_posts">Pinned</string>
<string name="sk_delete_and_redraft">Delete and re-draft</string>
<string name="sk_confirm_delete_and_redraft_title">Delete and re-draft Post</string>
<string name="sk_confirm_delete_and_redraft">Are you sure you want to delete and re-draft this post?</string>
<string name="sk_pin_post">Pin to profile</string>
<string name="sk_confirm_pin_post_title">Pin post to profile</string>
<string name="sk_confirm_pin_post">Do you want to pin this post to your profile?</string>
<string name="sk_pinning">Pinning post…</string>
<string name="sk_unpin_post">Unpin from profile</string>
<string name="sk_confirm_unpin_post_title">Unpin post from profile</string>
<string name="sk_confirm_unpin_post">Are you sure you want to unpin this post?</string>
<string name="sk_unpinning">Unpinning post…</string>
<string name="sk_image_description">Image description</string>
<string name="sk_visibility_unlisted">Unlisted</string>
<string name="sk_settings_show_replies">Show replies</string>
<string name="sk_settings_show_boosts">Show boosts</string>
<string name="sk_settings_load_new_posts">Automatically load new posts</string>
<string name="sk_settings_show_interaction_counts">Show interaction counts</string>
<string name="sk_settings_app_version">Moshidon v%1$s (%2$d)</string>
<string name="sk_mark_media_as_sensitive">Mark media as sensitive</string>
<string name="sk_user_post_notifications_on">Turned on post notifications for %s</string>
<string name="sk_user_post_notifications_off">Turned off post notifications for %s</string>
<string name="sk_federated_timeline">Federation</string>
<string name="sk_federated_timeline_info_banner">These are the most recent posts by the people in your federation.</string>
<string name="sk_update_available">Moshidon %s is ready to download.</string>
<string name="sk_update_ready">Moshidon %s is downloaded and ready to install.</string>
<string name="sk_check_for_update">Check for update</string>
<string name="sk_no_update_available">No update available</string>
<string name="sk_list_timelines">Lists</string>
<string name="sk_follow_requests">Follow requests</string>
<string name="sk_accept_follow_request">Accept follow request</string>
<string name="sk_reject_follow_request">Reject follow request</string>
<string name="sk_lists_with_user">Lists with %s</string>
<string name="sk_settings_always_reveal_content_warnings">Always reveal content warnings</string>
<string name="sk_disable_marquee">Disable scrolling text in title bars</string>
<string name="sk_settings_contribute">Contribute to Moshidon</string>
<string name="sk_settings_show_federated_timeline">Show federated timeline</string>
<string name="sk_notification_type_status">Posts</string>
<string name="sk_notify_posts">Post notifications</string>
<string name="sk_settings_color_picker">Color theme</string>
<string name="sk_color_theme_pink">Pink</string>
<string name="sk_color_theme_purple">Purple</string>
<string name="sk_color_theme_green">Green</string>
<string name="sk_color_theme_blue">Blue</string>
<string name="sk_color_theme_brown">Orange</string>
<string name="sk_color_theme_yellow">Yellow</string>
<string name="sk_color_theme_red">Red</string>
<string name="sk_color_theme_material3">Material You</string>
<string name="sk_not_supported">Not supported on your device</string>
<string name="sk_poll_allow_multiple">Allow multiple choices</string>
<string name="sk_translate_post">Translate</string>
<string name="sk_translate_show_original">Show original</string>
<string name="sk_translated_using">Translated using %s</string>
<string name="sk_post_language">Language: %s</string>
<string name="sk_available_languages">Available languages</string>
<string name="sk_language_name">%s (%s)</string>
<string name="sk_clear_recent_languages">Clear recent languages</string>
<string name="sk_confirm_clear_recent_languages">Are you sure you want to clear your recently used languages?</string>
<string name="sk_welcome_title">Welcome to Moshidon!</string>
<string name="sk_welcome_text">To get started, please enter your home instances domain name below.</string>
<string name="sk_example_domain">example.social</string>
<string name="sk_app_name">Megalodon</string>
<string name="sk_pinned_posts">Pinned</string>
<string name="sk_delete_and_redraft">Delete and re-draft</string>
<string name="sk_confirm_delete_and_redraft_title">Delete and re-draft Post</string>
<string name="sk_confirm_delete_and_redraft">Are you sure you want to delete and re-draft this post?</string>
<string name="sk_pin_post">Pin to profile</string>
<string name="sk_confirm_pin_post_title">Pin post to profile</string>
<string name="sk_confirm_pin_post">Do you want to pin this post to your profile?</string>
<string name="sk_pinning">Pinning post…</string>
<string name="sk_unpin_post">Unpin from profile</string>
<string name="sk_confirm_unpin_post_title">Unpin post from profile</string>
<string name="sk_confirm_unpin_post">Are you sure you want to unpin this post?</string>
<string name="sk_unpinning">Unpinning post…</string>
<string name="sk_image_description">Image description</string>
<string name="sk_visibility_unlisted">Unlisted</string>
<string name="sk_settings_show_replies">Show replies</string>
<string name="sk_settings_show_boosts">Show boosts</string>
<string name="sk_settings_load_new_posts">Automatically load new posts</string>
<string name="sk_settings_show_interaction_counts">Show interaction counts</string>
<string name="sk_settings_app_version">Megalodon v%1$s (%2$d)</string>
<string name="sk_mark_media_as_sensitive">Mark media as sensitive</string>
<string name="sk_user_post_notifications_on">Turned on post notifications for %s</string>
<string name="sk_user_post_notifications_off">Turned off post notifications for %s</string>
<string name="sk_federated_timeline">Federation</string>
<string name="sk_federated_timeline_info_banner">These are the most recent posts by the people in your federation.</string>
<string name="sk_update_available">Megalodon %s is ready to download.</string>
<string name="sk_update_ready">Megalodon %s is downloaded and ready to install.</string>
<string name="sk_check_for_update">Check for update</string>
<string name="sk_no_update_available">No update available</string>
<string name="sk_list_timelines">Lists</string>
<string name="sk_follow_requests">Follow requests</string>
<string name="sk_accept_follow_request">Accept follow request</string>
<string name="sk_reject_follow_request">Reject follow request</string>
<string name="sk_lists_with_user">Lists with %s</string>
<string name="sk_settings_always_reveal_content_warnings">Always reveal content warnings</string>
<string name="sk_disable_marquee">Disable scrolling text in title bars</string>
<string name="sk_settings_contribute">Contribute to Megalodon</string>
<string name="sk_settings_show_federated_timeline">Show federated timeline</string>
<string name="sk_notification_type_status">Posts</string>
<string name="sk_notify_posts">Post notifications</string>
<string name="sk_settings_color_picker">Color theme</string>
<string name="sk_color_theme_material3">System</string>
<string name="sk_color_theme_pink">Pink</string>
<string name="sk_color_theme_purple">Purple</string>
<string name="sk_color_theme_green">Green</string>
<string name="sk_color_theme_blue">Blue</string>
<string name="sk_color_theme_brown">Brown</string>
<string name="sk_color_theme_red">Red</string>
<string name="sk_color_theme_yellow">Yellow</string>
<string name="sk_poll_allow_multiple">Allow multiple choices</string>
<string name="sk_translate_post">Translate</string>
<string name="sk_translate_show_original">Show original</string>
<string name="sk_translated_using">Translated using %s</string>
<string name="sk_post_language">Language: %s</string>
<string name="sk_available_languages">Available languages</string>
<string name="sk_language_name">%s (%s)</string>
<string name="sk_clear_recent_languages">Clear recently used languages</string>
<string name="sk_confirm_clear_recent_languages">Are you sure you want to clear your recently used languages?</string>
<string name="sk_welcome_title">Welcome!</string>
<string name="sk_welcome_text">The shark salutes you! To get started, please enter your home instances domain name below.</string>
<string name="sk_example_domain">example.social</string>
<string name="sk_app_username" translatable="false">\@megalodon</string>
<string name="sk_tabs_disable_swipe">Disable swiping between tabs</string>
</resources>