Merge "Fixed an issue where the roundness of a notification could be wrong" into pi-dev
am: 65cb06cfc5
Change-Id: I0800723e0c6b1b4b0b277d1a2b69859bb0e791cd
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 9bd8080..6b9567d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -88,6 +88,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.function.BooleanSupplier;
+import java.util.function.Consumer;
public class ExpandableNotificationRow extends ActivatableNotificationView
implements PluginListener<NotificationMenuRowPlugin> {
@@ -179,6 +180,7 @@
private boolean mExpandAnimationRunning;
private AboveShelfChangedListener mAboveShelfChangedListener;
private HeadsUpManager mHeadsUpManager;
+ private Consumer<Boolean> mHeadsUpAnimatingAwayListener;
private View mHelperButton;
private boolean mChildIsExpanding;
@@ -1115,13 +1117,21 @@
public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
boolean wasAboveShelf = isAboveShelf();
+ boolean changed = headsUpAnimatingAway != mHeadsupDisappearRunning;
mHeadsupDisappearRunning = headsUpAnimatingAway;
mPrivateLayout.setHeadsUpAnimatingAway(headsUpAnimatingAway);
+ if (changed && mHeadsUpAnimatingAwayListener != null) {
+ mHeadsUpAnimatingAwayListener.accept(headsUpAnimatingAway);
+ }
if (isAboveShelf() != wasAboveShelf) {
mAboveShelfChangedListener.onAboveShelfStateChanged(!wasAboveShelf);
}
}
+ public void setHeadsUpAnimatingAwayListener(Consumer<Boolean> listener) {
+ mHeadsUpAnimatingAwayListener = listener;
+ }
+
/**
* @return if the view was just heads upped and is now animating away. During such a time the
* layout needs to be kept consistent
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
index 48828ab..7a7cc99 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
@@ -332,6 +332,7 @@
row.setOnExpandClickListener(mPresenter);
row.setInflationCallback(this);
row.setLongPressListener(getNotificationLongClicker());
+ mListContainer.bindRow(row);
mRemoteInputManager.bindRow(row);
// Get the app name.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListContainer.java
index 0c19ec0..af9a3a3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListContainer.java
@@ -188,4 +188,11 @@
default void applyExpandAnimationParams(ExpandAnimationParameters params) {}
default void setExpandingNotification(ExpandableNotificationRow row) {}
+
+ /**
+ * Bind a newly created row.
+ *
+ * @param row The notification to bind.
+ */
+ default void bindRow(ExpandableNotificationRow row) {}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationRoundnessManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationRoundnessManager.java
index a36c966..f98b3d9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationRoundnessManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationRoundnessManager.java
@@ -47,6 +47,11 @@
updateRounding(headsUp, true /* animate */);
}
+ public void onHeadsupAnimatingAwayChanged(ExpandableNotificationRow row,
+ boolean isAnimatingAway) {
+ updateRounding(row, false /* animate */);
+ }
+
private void updateRounding(ActivatableNotificationView view, boolean animate) {
float topRoundness = getRoundness(view, true /* top */);
float bottomRoundness = getRoundness(view, false /* top */);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index a572450..51273de 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -109,6 +109,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.function.BiConsumer;
+import java.util.function.Consumer;
/**
* A layout which handles a dynamic amount of notifications and presents them in a scrollable stack.
@@ -3022,6 +3023,12 @@
}
@Override
+ public void bindRow(ExpandableNotificationRow row) {
+ row.setHeadsUpAnimatingAwayListener(animatingAway
+ -> mRoundnessManager.onHeadsupAnimatingAwayChanged(row, animatingAway));
+ }
+
+ @Override
public void applyExpandAnimationParams(ExpandAnimationParameters params) {
mAmbientState.setExpandAnimationTopChange(params == null ? 0 : params.getTopChange());
requestChildrenUpdate();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java
index 34e444e..231a1866 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java
@@ -40,17 +40,22 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.function.Consumer;
+
@SmallTest
@RunWith(AndroidJUnit4.class)
public class ExpandableNotificationRowTest extends SysuiTestCase {
private ExpandableNotificationRow mGroup;
private NotificationTestHelper mNotificationTestHelper;
+ boolean mHeadsUpAnimatingAway = false;
@Before
public void setUp() throws Exception {
mNotificationTestHelper = new NotificationTestHelper(mContext);
mGroup = mNotificationTestHelper.createGroup();
+ mGroup.setHeadsUpAnimatingAwayListener(
+ animatingAway -> mHeadsUpAnimatingAway = animatingAway);
}
@Test
@@ -195,4 +200,12 @@
mGroup.getAppOpsOnClickListener().onClick(view);
verify(l, times(1)).onClick(any(), anyInt(), anyInt(), any());
}
+
+ @Test
+ public void testHeadsUpAnimatingAwayListener() {
+ mGroup.setHeadsUpAnimatingAway(true);
+ Assert.assertEquals(true, mHeadsUpAnimatingAway);
+ mGroup.setHeadsUpAnimatingAway(false);
+ Assert.assertEquals(false, mHeadsUpAnimatingAway);
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationRoundnessManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationRoundnessManagerTest.java
index 1d2c01d..28d1aff 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationRoundnessManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationRoundnessManagerTest.java
@@ -46,6 +46,7 @@
import org.junit.runner.RunWith;
import java.util.HashSet;
+import java.util.function.Consumer;
@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -61,7 +62,11 @@
public void setUp() throws Exception {
NotificationTestHelper testHelper = new NotificationTestHelper(getContext());
mFirst = testHelper.createRow();
+ mFirst.setHeadsUpAnimatingAwayListener(animatingAway
+ -> mRoundnessManager.onHeadsupAnimatingAwayChanged(mFirst, animatingAway));
mSecond = testHelper.createRow();
+ mSecond.setHeadsUpAnimatingAwayListener(animatingAway
+ -> mRoundnessManager.onHeadsupAnimatingAwayChanged(mSecond, animatingAway));
mRoundnessManager.setOnRoundingChangedCallback(mRoundnessCallback);
mRoundnessManager.setAnimatedChildren(mAnimatedChildren);
mRoundnessManager.setFirstAndLastBackgroundChild(mFirst, mFirst);
@@ -153,4 +158,24 @@
Assert.assertEquals(0.0f, mFirst.getCurrentBottomRoundness(), 0.0f);
Assert.assertEquals(0.0f, mFirst.getCurrentTopRoundness(), 0.0f);
}
+
+ @Test
+ public void testRoundingUpdatedWhenAnimatingAwayTrue() {
+ mRoundnessManager.setExpanded(0.0f, 0.0f);
+ mRoundnessManager.setFirstAndLastBackgroundChild(mSecond, mSecond);
+ mFirst.setHeadsUpAnimatingAway(true);
+ Assert.assertEquals(1.0f, mFirst.getCurrentBottomRoundness(), 0.0f);
+ Assert.assertEquals(1.0f, mFirst.getCurrentTopRoundness(), 0.0f);
+ }
+
+
+ @Test
+ public void testRoundingUpdatedWhenAnimatingAwayFalse() {
+ mRoundnessManager.setExpanded(0.0f, 0.0f);
+ mRoundnessManager.setFirstAndLastBackgroundChild(mSecond, mSecond);
+ mFirst.setHeadsUpAnimatingAway(true);
+ mFirst.setHeadsUpAnimatingAway(false);
+ Assert.assertEquals(0.0f, mFirst.getCurrentBottomRoundness(), 0.0f);
+ Assert.assertEquals(0.0f, mFirst.getCurrentTopRoundness(), 0.0f);
+ }
}