Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect system animation setting #1165

Merged

Conversation

michaelschattgen
Copy link
Member

@michaelschattgen michaelschattgen commented Aug 20, 2023

This pull request adds logic to properly respect the systems animation settings. Since I had to go through all the different animations we currently have in our app there is a possibility I might have missed one, let me know in case I did.

Fixes #930.

Copy link
Member

@alexbakker alexbakker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch gets us closer, but we're still not fully respecting the animation settings. For each of these animations, I think we should simply multiply the duration by ANIMATOR_DURATION_SCALE. This way the animations get disabled if the setting is set to 0 and in other cases the duration is properly scaled. We already do this for the TotpProgressBar and I think it makes sense to do the same here.

The exception being the preference transition animations. I think it's correct to multiply by TRANSITION_ANIMATION_SCALE instead there. Figuring out how to change the duration there was a bit of a Google rabbit hole, but adding the following to PreferencesFragment and IconPacksManagerFragment seems to do the trick:

@Override
@Nullable
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    if (nextAnim != 0) {
        Animation anim = AnimationUtils.loadAnimation(getActivity(), nextAnim);
        float amimDurationScale = Settings.Global.getFloat(requireContext().getContentResolver(), Settings.Global.TRANSITION_ANIMATION_SCALE, 1.0f);
        float duration = anim.getDuration() * amimDurationScale;
        anim.setDuration((long) duration);
        return anim;
    }
    return super.onCreateAnimation(transit, enter, nextAnim);
}

Also, I think the intro slide transition animations are not covered yet.

@michaelschattgen
Copy link
Member Author

You're right, for some reason I thought my first commit would cover the issue. I've changed everything to a more generic way where the current scale gets taken into account instead of a 'on' or 'off' state.

As for the intro slides I've decided to let that rest for a bit since that requires more effort that I initially thought.

Co-authored-by: Alexander Bakker <[email protected]>
@alexbakker alexbakker merged commit c19692b into beemdevelopment:master Aug 30, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Remove animations" accessibility setting not respected
2 participants