add option to reduce motion

This commit is contained in:
sk 2022-12-31 02:00:40 +01:00
parent 579794d7e0
commit 5f0986d03b
5 changed files with 16 additions and 3 deletions

View File

@ -29,6 +29,7 @@ public class GlobalUserPreferences{
public static boolean enableDeleteNotifications;
public static boolean translateButtonOpenedOnly;
public static boolean uniformNotificationIcon;
public static boolean reduceMotion;
public static String publishButtonText;
public static ThemePreference theme;
public static ColorPreference color;
@ -62,6 +63,7 @@ public class GlobalUserPreferences{
enableDeleteNotifications=prefs.getBoolean("enableDeleteNotifications", false);
translateButtonOpenedOnly=prefs.getBoolean("translateButtonOpenedOnly", false);
uniformNotificationIcon=prefs.getBoolean("uniformNotificationIcon", false);
reduceMotion=prefs.getBoolean("reduceMotion", false);
publishButtonText=prefs.getString("publishButtonText", "");
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>());
@ -90,6 +92,7 @@ public class GlobalUserPreferences{
.putBoolean("enableDeleteNotifications", enableDeleteNotifications)
.putBoolean("translateButtonOpenedOnly", translateButtonOpenedOnly)
.putBoolean("uniformNotificationIcon", uniformNotificationIcon)
.putBoolean("reduceMotion", reduceMotion)
.putString("publishButtonText", publishButtonText)
.putInt("theme", theme.ordinal())
.putString("color", color.name())

View File

@ -574,9 +574,11 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
scrollView.post(() -> {
int bottom = scrollView.getChildAt(0).getBottom();
int delta = bottom - (scrollView.getScrollY() + scrollView.getHeight());
int space = Math.min(V.dp(150), delta);
int space = GlobalUserPreferences.reduceMotion ? 0 : Math.min(V.dp(150), delta);
scrollView.scrollBy(0, delta - space);
scrollView.postDelayed(() -> scrollView.smoothScrollBy(0, space), 150);
if (!GlobalUserPreferences.reduceMotion) {
scrollView.postDelayed(() -> scrollView.smoothScrollBy(0, space), 150);
}
});
}
}

View File

@ -158,7 +158,11 @@ public class SettingsFragment extends MastodonToolbarFragment{
});
}));
items.add(new SwitchItem(R.string.sk_settings_uniform_icon_for_notifications, R.drawable.ic_ntf_logo, GlobalUserPreferences.uniformNotificationIcon, i->{
GlobalUserPreferences.uniformNotificationIcon =i.checked;
GlobalUserPreferences.uniformNotificationIcon=i.checked;
GlobalUserPreferences.save();
}));
items.add(new SwitchItem(R.string.sk_settings_reduce_motion, R.drawable.ic_fluent_star_emphasis_24_regular, GlobalUserPreferences.reduceMotion, i->{
GlobalUserPreferences.reduceMotion=i.checked;
GlobalUserPreferences.save();
}));

View File

@ -0,0 +1,3 @@
<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="M13.209 3.102c-0.495-1.003-1.926-1.003-2.421 0L8.43 7.88 3.157 8.646c-1.107 0.16-1.55 1.522-0.748 2.303l3.815 3.719-0.9 5.25c-0.19 1.104 0.968 1.945 1.958 1.424l4.716-2.48 4.716 2.48c0.99 0.52 2.148-0.32 1.96-1.423l-0.902-5.251 3.816-3.72c0.8-0.78 0.359-2.141-0.748-2.302L15.567 7.88l-2.358-4.778zM9.74 8.614l2.258-4.576 2.259 4.576c0.196 0.399 0.577 0.675 1.016 0.739l5.05 0.734-3.654 3.562c-0.318 0.31-0.463 0.757-0.388 1.195l0.862 5.029-4.516-2.375c-0.394-0.207-0.864-0.207-1.257 0l-4.516 2.375 0.862-5.03c0.075-0.438-0.07-0.884-0.388-1.194l-3.654-3.562 5.05-0.734c0.44-0.064 0.82-0.34 1.016-0.739zM1.164 3.781C0.906 4.104 0.958 4.576 1.282 4.835l2.5 2c0.323 0.259 0.795 0.207 1.054-0.117 0.258-0.323 0.206-0.795-0.117-1.054l-2.5-2C1.895 3.405 1.423 3.458 1.164 3.78zm21.672 14.437c0.259-0.323 0.206-0.795-0.117-1.054l-2.5-2c-0.324-0.259-0.796-0.206-1.055 0.117-0.258 0.323-0.206 0.795 0.117 1.054l2.5 2c0.324 0.259 0.796 0.206 1.055-0.117zM1.282 17.164c-0.324 0.259-0.376 0.73-0.118 1.054 0.26 0.323 0.731 0.376 1.055 0.117l2.5-2c0.323-0.259 0.375-0.73 0.117-1.054-0.26-0.323-0.731-0.376-1.055-0.117l-2.5 2zM22.835 3.78c0.259 0.323 0.206 0.795-0.117 1.054l-2.5 2c-0.324 0.259-0.796 0.207-1.055-0.117-0.258-0.323-0.206-0.795 0.117-1.054l2.5-2c0.324-0.259 0.796-0.206 1.055 0.117z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@ -124,4 +124,5 @@
<string name="sk_schedule_or_draft">Schedule or draft</string>
<string name="sk_compose_no_schedule">Dont schedule</string>
<string name="sk_compose_no_draft">Dont draft</string>
<string name="sk_settings_reduce_motion">Reduce motion in animations</string>
</resources>