add option to reduce motion

This commit is contained in:
sk 2022-12-30 22:00:40 -03:00 committed by LucasGGamerM
parent 120585954f
commit c97e8fffc4
5 changed files with 61 additions and 8 deletions

View File

@ -29,8 +29,10 @@ public class GlobalUserPreferences{
public static boolean disableDividers;
public static boolean voteButtonForSingleChoice;
public static boolean showUniformPushNoticationIcons;
public static boolean relocatePublishButton;
public static boolean enableDeleteNotifications;
public static boolean relocatePublishButton;
public static boolean reduceMotion;
public static String publishButtonText;
public static ThemePreference theme;
public static ColorPreference color;
@ -96,6 +98,8 @@ public class GlobalUserPreferences{
.putBoolean("relocatePublishButton", relocatePublishButton)
.putBoolean("showUniformPushNotificationIcons", showUniformPushNoticationIcons)
.putBoolean("enableDeleteNotifications", enableDeleteNotifications)
.putBoolean("reduceMotion", reduceMotion)
.putString("publishButtonText", publishButtonText)
.putInt("theme", theme.ordinal())
.putString("color", color.name())
.putString("recentLanguages", gson.toJson(recentLanguages))

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

@ -93,6 +93,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
accountID=getArguments().getString("account");
AccountSession session=AccountSessionManager.getInstance().getAccount(accountID);
Instance instance = AccountSessionManager.getInstance().getInstanceInfo(session.domain);
String instanceName = UiUtils.getInstanceName(accountID);
if(GithubSelfUpdater.needSelfUpdating()){
GithubSelfUpdater updater=GithubSelfUpdater.getInstance();
@ -129,6 +130,41 @@ public class SettingsFragment extends MastodonToolbarFragment{
});
}));
items.add(new SwitchItem(R.string.sk_settings_uniform_icon_for_notifications, R.drawable.ic_ntf_logo, GlobalUserPreferences.showUniformPushNoticationIcons, this::onNotificationStyleChanged));
items.add(new ButtonItem(R.string.sk_settings_publish_button_text, R.drawable.ic_fluent_send_24_regular, b->{
updatePublishText(b);
b.setOnClickListener(l->{
FrameLayout inputWrap = new FrameLayout(getContext());
EditText input = new EditText(getContext());
input.setHint(R.string.publish);
input.setText(GlobalUserPreferences.publishButtonText.trim());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.setMargins(V.dp(16), V.dp(4), V.dp(16), V.dp(16));
input.setLayoutParams(params);
inputWrap.addView(input);
new M3AlertDialogBuilder(getContext()).setTitle(R.string.sk_settings_publish_button_text_title).setView(inputWrap)
.setPositiveButton(R.string.save, (d, which) -> {
GlobalUserPreferences.publishButtonText = input.getText().toString().trim();
GlobalUserPreferences.save();
updatePublishText(b);
})
.setNeutralButton(R.string.clear, (d, which) -> {
GlobalUserPreferences.publishButtonText = "";
GlobalUserPreferences.save();
updatePublishText(b);
})
.setNegativeButton(R.string.cancel, (d, which) -> {})
.show();
});
}));
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.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();
}));
items.add(new HeaderItem(R.string.settings_behavior));
items.add(new SwitchItem(R.string.sk_settings_show_federated_timeline, R.drawable.ic_fluent_earth_24_regular, GlobalUserPreferences.showFederatedTimeline, i->{
@ -171,6 +207,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
items.add(new SwitchItem(R.string.sk_relocate_publish_button, R.drawable.ic_fluent_arrow_autofit_down_24_regular, GlobalUserPreferences.relocatePublishButton, i->{
GlobalUserPreferences.relocatePublishButton=i.checked;
GlobalUserPreferences.save();
needAppRestart=true;
}));
// items.add(new SwitchItem(R.string.sk_settings_hide_translate_in_timeline, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{
// GlobalUserPreferences.translateButtonOpenedOnly=i.checked;
@ -201,12 +238,13 @@ public class SettingsFragment extends MastodonToolbarFragment{
items.add(new SwitchItem(R.string.notify_mention, R.drawable.ic_fluent_mention_24_regular, pushSubscription.alerts.mention, i->onNotificationsChanged(PushNotification.Type.MENTION, i.checked)));
items.add(new SwitchItem(R.string.sk_notify_posts, R.drawable.ic_fluent_alert_24_regular, pushSubscription.alerts.status, i->onNotificationsChanged(PushNotification.Type.STATUS, i.checked)));
items.add(new HeaderItem(R.string.settings_boring));
items.add(new TextItem(R.string.settings_account, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/auth/edit")));
items.add(new TextItem(R.string.settings_tos, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms")));
items.add(new TextItem(R.string.settings_privacy_policy, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/terms")));
items.add(new HeaderItem(R.string.settings_account));
items.add(new TextItem(R.string.sk_settings_profile, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/profile"), R.drawable.ic_fluent_open_24_regular));
items.add(new TextItem(R.string.sk_settings_posting, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/preferences/other"), R.drawable.ic_fluent_open_24_regular));
items.add(new TextItem(R.string.sk_settings_filters, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/filters"), R.drawable.ic_fluent_open_24_regular));
items.add(new TextItem(R.string.sk_settings_auth, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/auth/edit"), R.drawable.ic_fluent_open_24_regular));
items.add(new HeaderItem(instance != null ? instance.title : session.domain));
items.add(new HeaderItem(instanceName));
items.add(new TextItem(R.string.sk_settings_rules, ()->{
Bundle args=new Bundle();
args.putParcelable("instance", Parcels.wrap(instance));
@ -240,6 +278,11 @@ public class SettingsFragment extends MastodonToolbarFragment{
items.add(new FooterItem(getString(R.string.sk_settings_app_version, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE)));
}
private void updatePublishText(Button btn) {
if (GlobalUserPreferences.publishButtonText.isBlank()) btn.setText(R.string.publish);
else btn.setText(GlobalUserPreferences.publishButtonText);
}
@Override
public void onAttach(Activity activity){
super.onAttach(activity);

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

@ -129,4 +129,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>