Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2ee8bbf authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Do not animate icons in tiles that shouldn't

Respect the shouldAnimate flag for icon animations.

Test: atest QSIconViewImplTest
Test: manual, Edit mode
Fixes: 251143747
Change-Id: I82fa278910c91fd9574bac606a523726a2613b4b
parent 268f0020
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ public class QSIconViewImpl extends QSIconView {
            iv.setTag(R.id.qs_icon_tag, icon);
            iv.setTag(R.id.qs_slash_tag, state.slash);
            iv.setPadding(0, padding, 0, padding);
            if (d instanceof Animatable2) {
            if (shouldAnimate && d instanceof Animatable2) {
                Animatable2 a = (Animatable2) d;
                a.start();
                if (state.isTransient) {
+15 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
import android.service.quicksettings.Tile;
import android.testing.AndroidTestingRunner;
@@ -136,6 +137,20 @@ public class QSIconViewImplTest extends SysuiTestCase {
        assertEquals(mIconView.getColor(s1), mIconView.getColor(s2));
    }

    @Test
    public void testIconNotAnimatedWhenAllowAnimationsFalse() {
        ImageView iv = new ImageView(mContext);
        AnimatedVectorDrawable d = mock(AnimatedVectorDrawable.class);
        State s = new State();
        s.icon = mock(Icon.class);
        when(s.icon.getDrawable(any())).thenReturn(d);
        when(s.icon.getInvisibleDrawable(any())).thenReturn(d);

        mIconView.updateIcon(iv, s, false);

        verify(d, never()).start();
    }

    private static Drawable.ConstantState fakeConstantState(Drawable otherDrawable) {
        return new Drawable.ConstantState() {
            @Override