From 9a82d124628350e64a835043baffced59ffcd143 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Mon, 27 Mar 2017 16:41:24 -0400 Subject: [PATCH] QS: Don't animate first state change Test: runtest systemui Change-Id: I151af59665c74ca04839f7d33153fb8c90ddd996 Fixes: 36076790 (cherry picked from commit 2b48aa3f71403f41f6d6b90cfe437ee4bdce160f) --- .../com/android/systemui/qs/tileimpl/QSIconViewImpl.java | 2 +- .../android/systemui/qs/tileimpl/QSIconViewImplTest.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java index a567f6b037be..6e2add493779 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java @@ -116,7 +116,7 @@ public class QSIconViewImpl extends QSIconView { if (state.state != mState) { int color = getColor(state.state); mState = state.state; - if (iv.isShown()) { + if (iv.isShown() && mTint != 0) { animateGrayScale(mTint, color, iv); mTint = color; } else { diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java index bb4571c7413a..59483f2df5bb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java @@ -15,12 +15,15 @@ package com.android.systemui.qs.tileimpl; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; +import android.service.quicksettings.Tile; import android.testing.AndroidTestingRunner; import android.testing.UiThreadTest; import android.widget.ImageView; @@ -32,6 +35,7 @@ import com.android.systemui.plugins.qs.QSTile.State; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentMatcher; @RunWith(AndroidTestingRunner.class) @UiThreadTest @@ -64,4 +68,16 @@ public class QSIconViewImplTest extends SysuiTestCase { verify(s.icon).getDrawable(any()); verify(s.icon, never()).getInvisibleDrawable(any()); } + + @Test + public void testNoFirstFade() { + ImageView iv = mock(ImageView.class); + State s = new State(); + s.state = Tile.STATE_ACTIVE; + int desiredColor = mIconView.getColor(s.state); + when(iv.isShown()).thenReturn(true); + + mIconView.setIcon(iv, s); + verify(iv).setImageTintList(argThat(stateList -> stateList.getColors()[0] == desiredColor)); + } } -- 2.11.0