From 45832355a301d3516ebf738d4b679394077a1431 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Thu, 26 Jan 2023 20:15:50 -0300 Subject: [PATCH] Refactoring the enableHideFab option, and increasing the threshold for the fab popping up from 400 to 800 --- .../org/joinmastodon/android/GlobalUserPreferences.java | 6 +++--- .../android/fragments/BaseStatusListFragment.java | 4 ++-- .../joinmastodon/android/fragments/SettingsFragment.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 31eced774..288421072 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -33,7 +33,7 @@ public class GlobalUserPreferences{ public static boolean relocatePublishButton; public static boolean reduceMotion; public static boolean keepOnlyLatestNotification; - public static boolean disableFabAutoHide; + public static boolean enableFabAutoHide; public static String publishButtonText; public static ThemePreference theme; public static ColorPreference color; @@ -73,7 +73,7 @@ public class GlobalUserPreferences{ enableDeleteNotifications=prefs.getBoolean("enableDeleteNotifications", true); reduceMotion=prefs.getBoolean("reduceMotion", false); keepOnlyLatestNotification=prefs.getBoolean("keepOnlyLatestNotification", false); - disableFabAutoHide=prefs.getBoolean("disableFabAutoHide", false); + enableFabAutoHide =prefs.getBoolean("enableFabAutoHide", true); theme=ThemePreference.values()[prefs.getInt("theme", 0)]; recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>()); recentEmojis=fromJson(prefs.getString("recentEmojis", "{}"), recentEmojisType, new HashMap<>()); @@ -110,7 +110,7 @@ public class GlobalUserPreferences{ .putBoolean("enableDeleteNotifications", enableDeleteNotifications) .putBoolean("reduceMotion", reduceMotion) .putBoolean("keepOnlyLatestNotification", keepOnlyLatestNotification) - .putBoolean("disableFabAutoHide", disableFabAutoHide) + .putBoolean("enableFabAutoHide", enableFabAutoHide) .putString("publishButtonText", publishButtonText) .putInt("theme", theme.ordinal()) .putString("color", color.name()) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index acd61a03b..fab20a5f3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -285,7 +285,7 @@ public abstract class BaseStatusListFragment exten if(currentPhotoViewer!=null) currentPhotoViewer.offsetView(-dx, -dy); - if (fab!=null && GlobalUserPreferences.disableFabAutoHide) { + if (fab!=null && GlobalUserPreferences.enableFabAutoHide) { if (dy > 0 && fab.getVisibility() == View.VISIBLE) { TranslateAnimation animate = new TranslateAnimation( 0, @@ -298,7 +298,7 @@ public abstract class BaseStatusListFragment exten fab.setVisibility(View.INVISIBLE); scrollDiff = 0; } else if (dy < 0 && fab.getVisibility() != View.VISIBLE) { - if (scrollDiff > 400) { + if (scrollDiff > 800) { fab.setVisibility(View.VISIBLE); TranslateAnimation animate = new TranslateAnimation( 0, diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index 81fe364e3..808c8ec7a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -210,8 +210,8 @@ public class SettingsFragment extends MastodonToolbarFragment{ GlobalUserPreferences.save(); needAppRestart=true; })); - items.add(new SwitchItem(R.string.mo_hide_compose_button_while_scrolling_setting, R.drawable.ic_fluent_edit_24_regular, GlobalUserPreferences.disableFabAutoHide, i->{ - GlobalUserPreferences.disableFabAutoHide =i.checked; + items.add(new SwitchItem(R.string.mo_hide_compose_button_while_scrolling_setting, R.drawable.ic_fluent_edit_24_regular, GlobalUserPreferences.enableFabAutoHide, i->{ + GlobalUserPreferences.enableFabAutoHide =i.checked; GlobalUserPreferences.save(); needAppRestart=true; }));