Refactoring the enableHideFab option, and increasing the threshold for the fab popping up from 400 to 800

This commit is contained in:
LucasGGamerM 2023-01-26 20:15:50 -03:00
parent 51d4fd63db
commit 45832355a3
3 changed files with 7 additions and 7 deletions

View File

@ -33,7 +33,7 @@ public class GlobalUserPreferences{
public static boolean relocatePublishButton; public static boolean relocatePublishButton;
public static boolean reduceMotion; public static boolean reduceMotion;
public static boolean keepOnlyLatestNotification; public static boolean keepOnlyLatestNotification;
public static boolean disableFabAutoHide; public static boolean enableFabAutoHide;
public static String publishButtonText; public static String publishButtonText;
public static ThemePreference theme; public static ThemePreference theme;
public static ColorPreference color; public static ColorPreference color;
@ -73,7 +73,7 @@ public class GlobalUserPreferences{
enableDeleteNotifications=prefs.getBoolean("enableDeleteNotifications", true); enableDeleteNotifications=prefs.getBoolean("enableDeleteNotifications", true);
reduceMotion=prefs.getBoolean("reduceMotion", false); reduceMotion=prefs.getBoolean("reduceMotion", false);
keepOnlyLatestNotification=prefs.getBoolean("keepOnlyLatestNotification", false); keepOnlyLatestNotification=prefs.getBoolean("keepOnlyLatestNotification", false);
disableFabAutoHide=prefs.getBoolean("disableFabAutoHide", false); enableFabAutoHide =prefs.getBoolean("enableFabAutoHide", true);
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<>());
recentEmojis=fromJson(prefs.getString("recentEmojis", "{}"), recentEmojisType, new HashMap<>()); recentEmojis=fromJson(prefs.getString("recentEmojis", "{}"), recentEmojisType, new HashMap<>());
@ -110,7 +110,7 @@ public class GlobalUserPreferences{
.putBoolean("enableDeleteNotifications", enableDeleteNotifications) .putBoolean("enableDeleteNotifications", enableDeleteNotifications)
.putBoolean("reduceMotion", reduceMotion) .putBoolean("reduceMotion", reduceMotion)
.putBoolean("keepOnlyLatestNotification", keepOnlyLatestNotification) .putBoolean("keepOnlyLatestNotification", keepOnlyLatestNotification)
.putBoolean("disableFabAutoHide", disableFabAutoHide) .putBoolean("enableFabAutoHide", enableFabAutoHide)
.putString("publishButtonText", publishButtonText) .putString("publishButtonText", publishButtonText)
.putInt("theme", theme.ordinal()) .putInt("theme", theme.ordinal())
.putString("color", color.name()) .putString("color", color.name())

View File

@ -285,7 +285,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
if(currentPhotoViewer!=null) if(currentPhotoViewer!=null)
currentPhotoViewer.offsetView(-dx, -dy); currentPhotoViewer.offsetView(-dx, -dy);
if (fab!=null && GlobalUserPreferences.disableFabAutoHide) { if (fab!=null && GlobalUserPreferences.enableFabAutoHide) {
if (dy > 0 && fab.getVisibility() == View.VISIBLE) { if (dy > 0 && fab.getVisibility() == View.VISIBLE) {
TranslateAnimation animate = new TranslateAnimation( TranslateAnimation animate = new TranslateAnimation(
0, 0,
@ -298,7 +298,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
fab.setVisibility(View.INVISIBLE); fab.setVisibility(View.INVISIBLE);
scrollDiff = 0; scrollDiff = 0;
} else if (dy < 0 && fab.getVisibility() != View.VISIBLE) { } else if (dy < 0 && fab.getVisibility() != View.VISIBLE) {
if (scrollDiff > 400) { if (scrollDiff > 800) {
fab.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE);
TranslateAnimation animate = new TranslateAnimation( TranslateAnimation animate = new TranslateAnimation(
0, 0,

View File

@ -210,8 +210,8 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.save(); GlobalUserPreferences.save();
needAppRestart=true; 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->{ items.add(new SwitchItem(R.string.mo_hide_compose_button_while_scrolling_setting, R.drawable.ic_fluent_edit_24_regular, GlobalUserPreferences.enableFabAutoHide, i->{
GlobalUserPreferences.disableFabAutoHide =i.checked; GlobalUserPreferences.enableFabAutoHide =i.checked;
GlobalUserPreferences.save(); GlobalUserPreferences.save();
needAppRestart=true; needAppRestart=true;
})); }));