summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jason Monk <jmonk@google.com> 2017-03-27 15:18:23 -0400
committer Jason Monk <jmonk@google.com> 2017-03-28 18:04:22 +0000
commitda9395e681bfaa21692bcb4a7a249b1d7ff2e2d3 (patch)
tree8f072f0b4b01a201b8becfe7c1e161f7d21c5937
parent64b214ea16c787fdcf2bb44ad81b1336cafebafe (diff)
Fix QS getting stuck in weird animation during recreate
Don't animate on first state change in QS, no reason to animate on bootup or recreate. Test: runtest systemui Change-Id: Ib1ceddd708fdc922224b57dbfe12d2f9a76fcee3 Fixes: 35116271 (cherry picked from commit 2da4619b12a4c65a645534079057e7d2bb0bae21)
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java67
2 files changed, 70 insertions, 1 deletions
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 5be1ec6ef4e8..a567f6b037be 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java
@@ -84,8 +84,10 @@ public class QSIconViewImpl extends QSIconView {
protected void updateIcon(ImageView iv, State state) {
if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))) {
+ boolean shouldAnimate = iv.isShown() && mAnimationEnabled
+ && iv.getDrawable() != null;
Drawable d = state.icon != null
- ? iv.isShown() && mAnimationEnabled ? state.icon.getDrawable(mContext)
+ ? shouldAnimate ? state.icon.getDrawable(mContext)
: state.icon.getInvisibleDrawable(mContext) : null;
int padding = state.icon != null ? state.icon.getPadding() : 0;
if (d != null) {
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
new file mode 100644
index 000000000000..bb4571c7413a
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.systemui.qs.tileimpl;
+
+import static org.mockito.ArgumentMatchers.any;
+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.graphics.drawable.Drawable;
+import android.testing.AndroidTestingRunner;
+import android.testing.UiThreadTest;
+import android.widget.ImageView;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.plugins.qs.QSTile.Icon;
+import com.android.systemui.plugins.qs.QSTile.State;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidTestingRunner.class)
+@UiThreadTest
+public class QSIconViewImplTest extends SysuiTestCase {
+
+ private QSIconViewImpl mIconView;
+
+ @Before
+ public void setup() {
+ mIconView = new QSIconViewImpl(mContext);
+ }
+
+ @Test
+ public void testNoFirstAnimation() {
+ ImageView iv = mock(ImageView.class);
+ State s = new State();
+ when(iv.isShown()).thenReturn(true);
+
+ // No current icon, only the static drawable should be used.
+ s.icon = mock(Icon.class);
+ when(iv.getDrawable()).thenReturn(null);
+ mIconView.updateIcon(iv, s);
+ verify(s.icon, never()).getDrawable(any());
+ verify(s.icon).getInvisibleDrawable(any());
+
+ // Has icon, should use the standard (animated) form.
+ s.icon = mock(Icon.class);
+ when(iv.getDrawable()).thenReturn(mock(Drawable.class));
+ mIconView.updateIcon(iv, s);
+ verify(s.icon).getDrawable(any());
+ verify(s.icon, never()).getInvisibleDrawable(any());
+ }
+}