Merge "Fixed an issue where the roundness of a notification could be wrong" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
65cb06cfc5
@@ -88,6 +88,7 @@ import com.android.systemui.statusbar.stack.StackScrollState;
|
||||
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 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
private boolean mExpandAnimationRunning;
|
||||
private AboveShelfChangedListener mAboveShelfChangedListener;
|
||||
private HeadsUpManager mHeadsUpManager;
|
||||
private Consumer<Boolean> mHeadsUpAnimatingAwayListener;
|
||||
private View mHelperButton;
|
||||
private boolean mChildIsExpanding;
|
||||
|
||||
@@ -1115,13 +1117,21 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
|
||||
|
||||
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
|
||||
|
||||
@@ -332,6 +332,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
|
||||
row.setOnExpandClickListener(mPresenter);
|
||||
row.setInflationCallback(this);
|
||||
row.setLongPressListener(getNotificationLongClicker());
|
||||
mListContainer.bindRow(row);
|
||||
mRemoteInputManager.bindRow(row);
|
||||
|
||||
// Get the app name.
|
||||
|
||||
@@ -188,4 +188,11 @@ public interface NotificationListContainer {
|
||||
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) {}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,11 @@ class NotificationRoundnessManager implements OnHeadsUpChangedListener {
|
||||
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 */);
|
||||
|
||||
@@ -109,6 +109,7 @@ import java.util.Comparator;
|
||||
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.
|
||||
@@ -3021,6 +3022,12 @@ public class NotificationStackScrollLayout extends ViewGroup
|
||||
requestChildrenUpdate();
|
||||
}
|
||||
|
||||
@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());
|
||||
|
||||
@@ -40,17 +40,22 @@ import org.junit.Before;
|
||||
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 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@@ -61,7 +62,11 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase {
|
||||
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 @@ public class NotificationRoundnessManagerTest extends SysuiTestCase {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user