Merge "Add reset PULSING roundness on NotificationEntry removed" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b08cafd991
@@ -22,6 +22,8 @@ import android.graphics.Rect;
|
|||||||
import android.util.MathUtils;
|
import android.util.MathUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.widget.ViewClippingUtil;
|
import com.android.internal.widget.ViewClippingUtil;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -197,6 +199,11 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
|
|||||||
updateHeadsUpAndPulsingRoundness(entry);
|
updateHeadsUpAndPulsingRoundness(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHeadsUpStateChanged(@NonNull NotificationEntry entry, boolean isHeadsUp) {
|
||||||
|
updateHeadsUpAndPulsingRoundness(entry);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateTopEntry() {
|
private void updateTopEntry() {
|
||||||
NotificationEntry newEntry = null;
|
NotificationEntry newEntry = null;
|
||||||
if (shouldBeVisible()) {
|
if (shouldBeVisible()) {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.phone;
|
package com.android.systemui.statusbar.phone;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.isNull;
|
import static org.mockito.ArgumentMatchers.isNull;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -33,12 +35,14 @@ import androidx.test.filters.SmallTest;
|
|||||||
|
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.flags.FeatureFlags;
|
import com.android.systemui.flags.FeatureFlags;
|
||||||
|
import com.android.systemui.flags.Flags;
|
||||||
import com.android.systemui.plugins.DarkIconDispatcher;
|
import com.android.systemui.plugins.DarkIconDispatcher;
|
||||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||||
import com.android.systemui.shade.NotificationPanelViewController;
|
import com.android.systemui.shade.NotificationPanelViewController;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
import com.android.systemui.statusbar.HeadsUpStatusBarView;
|
import com.android.systemui.statusbar.HeadsUpStatusBarView;
|
||||||
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
|
import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
|
||||||
|
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||||
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
|
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
|
||||||
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
|
import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
|
||||||
import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager;
|
import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager;
|
||||||
@@ -64,7 +68,9 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
|||||||
mock(NotificationPanelViewController.class);
|
mock(NotificationPanelViewController.class);
|
||||||
private final DarkIconDispatcher mDarkIconDispatcher = mock(DarkIconDispatcher.class);
|
private final DarkIconDispatcher mDarkIconDispatcher = mock(DarkIconDispatcher.class);
|
||||||
private HeadsUpAppearanceController mHeadsUpAppearanceController;
|
private HeadsUpAppearanceController mHeadsUpAppearanceController;
|
||||||
private ExpandableNotificationRow mFirst;
|
private NotificationTestHelper mTestHelper;
|
||||||
|
private ExpandableNotificationRow mRow;
|
||||||
|
private NotificationEntry mEntry;
|
||||||
private HeadsUpStatusBarView mHeadsUpStatusBarView;
|
private HeadsUpStatusBarView mHeadsUpStatusBarView;
|
||||||
private HeadsUpManagerPhone mHeadsUpManager;
|
private HeadsUpManagerPhone mHeadsUpManager;
|
||||||
private View mOperatorNameView;
|
private View mOperatorNameView;
|
||||||
@@ -79,11 +85,12 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
allowTestableLooperAsMainThread();
|
allowTestableLooperAsMainThread();
|
||||||
NotificationTestHelper testHelper = new NotificationTestHelper(
|
mTestHelper = new NotificationTestHelper(
|
||||||
mContext,
|
mContext,
|
||||||
mDependency,
|
mDependency,
|
||||||
TestableLooper.get(this));
|
TestableLooper.get(this));
|
||||||
mFirst = testHelper.createRow();
|
mRow = mTestHelper.createRow();
|
||||||
|
mEntry = mRow.getEntry();
|
||||||
mHeadsUpStatusBarView = new HeadsUpStatusBarView(mContext, mock(View.class),
|
mHeadsUpStatusBarView = new HeadsUpStatusBarView(mContext, mock(View.class),
|
||||||
mock(TextView.class));
|
mock(TextView.class));
|
||||||
mHeadsUpManager = mock(HeadsUpManagerPhone.class);
|
mHeadsUpManager = mock(HeadsUpManagerPhone.class);
|
||||||
@@ -95,6 +102,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
|||||||
mCommandQueue = mock(CommandQueue.class);
|
mCommandQueue = mock(CommandQueue.class);
|
||||||
mNotificationRoundnessManager = mock(NotificationRoundnessManager.class);
|
mNotificationRoundnessManager = mock(NotificationRoundnessManager.class);
|
||||||
mFeatureFlag = mock(FeatureFlags.class);
|
mFeatureFlag = mock(FeatureFlags.class);
|
||||||
|
when(mFeatureFlag.isEnabled(Flags.USE_ROUNDNESS_SOURCETYPES)).thenReturn(true);
|
||||||
mHeadsUpAppearanceController = new HeadsUpAppearanceController(
|
mHeadsUpAppearanceController = new HeadsUpAppearanceController(
|
||||||
mock(NotificationIconAreaController.class),
|
mock(NotificationIconAreaController.class),
|
||||||
mHeadsUpManager,
|
mHeadsUpManager,
|
||||||
@@ -116,60 +124,60 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShowinEntryUpdated() {
|
public void testShowinEntryUpdated() {
|
||||||
mFirst.setPinned(true);
|
mRow.setPinned(true);
|
||||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
|
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
|
||||||
when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
|
when(mHeadsUpManager.getTopEntry()).thenReturn(mEntry);
|
||||||
mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry());
|
mHeadsUpAppearanceController.onHeadsUpPinned(mEntry);
|
||||||
Assert.assertEquals(mFirst.getEntry(), mHeadsUpStatusBarView.getShowingEntry());
|
assertEquals(mRow.getEntry(), mHeadsUpStatusBarView.getShowingEntry());
|
||||||
|
|
||||||
mFirst.setPinned(false);
|
mRow.setPinned(false);
|
||||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
|
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
|
||||||
mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry());
|
mHeadsUpAppearanceController.onHeadsUpUnPinned(mEntry);
|
||||||
Assert.assertEquals(null, mHeadsUpStatusBarView.getShowingEntry());
|
assertEquals(null, mHeadsUpStatusBarView.getShowingEntry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShownUpdated() {
|
public void testShownUpdated() {
|
||||||
mFirst.setPinned(true);
|
mRow.setPinned(true);
|
||||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
|
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
|
||||||
when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
|
when(mHeadsUpManager.getTopEntry()).thenReturn(mEntry);
|
||||||
mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry());
|
mHeadsUpAppearanceController.onHeadsUpPinned(mEntry);
|
||||||
Assert.assertTrue(mHeadsUpAppearanceController.isShown());
|
assertTrue(mHeadsUpAppearanceController.isShown());
|
||||||
|
|
||||||
mFirst.setPinned(false);
|
mRow.setPinned(false);
|
||||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
|
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
|
||||||
mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry());
|
mHeadsUpAppearanceController.onHeadsUpUnPinned(mEntry);
|
||||||
Assert.assertFalse(mHeadsUpAppearanceController.isShown());
|
Assert.assertFalse(mHeadsUpAppearanceController.isShown());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHeaderUpdated() {
|
public void testHeaderUpdated() {
|
||||||
mFirst.setPinned(true);
|
mRow.setPinned(true);
|
||||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
|
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
|
||||||
when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
|
when(mHeadsUpManager.getTopEntry()).thenReturn(mEntry);
|
||||||
mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry());
|
mHeadsUpAppearanceController.onHeadsUpPinned(mEntry);
|
||||||
Assert.assertEquals(mFirst.getHeaderVisibleAmount(), 0.0f, 0.0f);
|
assertEquals(mRow.getHeaderVisibleAmount(), 0.0f, 0.0f);
|
||||||
|
|
||||||
mFirst.setPinned(false);
|
mRow.setPinned(false);
|
||||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
|
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
|
||||||
mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry());
|
mHeadsUpAppearanceController.onHeadsUpUnPinned(mEntry);
|
||||||
Assert.assertEquals(mFirst.getHeaderVisibleAmount(), 1.0f, 0.0f);
|
assertEquals(mRow.getHeaderVisibleAmount(), 1.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOperatorNameViewUpdated() {
|
public void testOperatorNameViewUpdated() {
|
||||||
mHeadsUpAppearanceController.setAnimationsEnabled(false);
|
mHeadsUpAppearanceController.setAnimationsEnabled(false);
|
||||||
|
|
||||||
mFirst.setPinned(true);
|
mRow.setPinned(true);
|
||||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
|
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
|
||||||
when(mHeadsUpManager.getTopEntry()).thenReturn(mFirst.getEntry());
|
when(mHeadsUpManager.getTopEntry()).thenReturn(mEntry);
|
||||||
mHeadsUpAppearanceController.onHeadsUpPinned(mFirst.getEntry());
|
mHeadsUpAppearanceController.onHeadsUpPinned(mEntry);
|
||||||
Assert.assertEquals(View.INVISIBLE, mOperatorNameView.getVisibility());
|
assertEquals(View.INVISIBLE, mOperatorNameView.getVisibility());
|
||||||
|
|
||||||
mFirst.setPinned(false);
|
mRow.setPinned(false);
|
||||||
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
|
when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
|
||||||
mHeadsUpAppearanceController.onHeadsUpUnPinned(mFirst.getEntry());
|
mHeadsUpAppearanceController.onHeadsUpUnPinned(mEntry);
|
||||||
Assert.assertEquals(View.VISIBLE, mOperatorNameView.getVisibility());
|
assertEquals(View.VISIBLE, mOperatorNameView.getVisibility());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -196,8 +204,8 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
|||||||
new Clock(mContext, null),
|
new Clock(mContext, null),
|
||||||
Optional.empty());
|
Optional.empty());
|
||||||
|
|
||||||
Assert.assertEquals(expandedHeight, newController.mExpandedHeight, 0.0f);
|
assertEquals(expandedHeight, newController.mExpandedHeight, 0.0f);
|
||||||
Assert.assertEquals(appearFraction, newController.mAppearFraction, 0.0f);
|
assertEquals(appearFraction, newController.mAppearFraction, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -215,4 +223,68 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
|
|||||||
verify(mPanelView).setHeadsUpAppearanceController(isNull());
|
verify(mPanelView).setHeadsUpAppearanceController(isNull());
|
||||||
verify(mStackScrollerController).removeOnExpandedHeightChangedListener(any());
|
verify(mStackScrollerController).removeOnExpandedHeightChangedListener(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPulsingRoundness_onUpdateHeadsUpAndPulsingRoundness() {
|
||||||
|
// Pulsing: Enable flag and dozing
|
||||||
|
when(mNotificationRoundnessManager.shouldRoundNotificationPulsing()).thenReturn(true);
|
||||||
|
when(mTestHelper.getStatusBarStateController().isDozing()).thenReturn(true);
|
||||||
|
|
||||||
|
// Pulsing: Enabled
|
||||||
|
mRow.setHeadsUp(true);
|
||||||
|
mHeadsUpAppearanceController.updateHeadsUpAndPulsingRoundness(mEntry);
|
||||||
|
|
||||||
|
String debugString = mRow.getRoundableState().debugString();
|
||||||
|
assertEquals(
|
||||||
|
"If Pulsing is enabled, roundness should be set to 1. Value: " + debugString,
|
||||||
|
/* expected = */ 1,
|
||||||
|
/* actual = */ mRow.getTopRoundness(),
|
||||||
|
/* delta = */ 0.001
|
||||||
|
);
|
||||||
|
assertTrue(debugString.contains("Pulsing"));
|
||||||
|
|
||||||
|
// Pulsing: Disabled
|
||||||
|
mRow.setHeadsUp(false);
|
||||||
|
mHeadsUpAppearanceController.updateHeadsUpAndPulsingRoundness(mEntry);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"If Pulsing is disabled, roundness should be set to 0. Value: "
|
||||||
|
+ mRow.getRoundableState().debugString(),
|
||||||
|
/* expected = */ 0,
|
||||||
|
/* actual = */ mRow.getTopRoundness(),
|
||||||
|
/* delta = */ 0.001
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPulsingRoundness_onHeadsUpStateChanged() {
|
||||||
|
// Pulsing: Enable flag and dozing
|
||||||
|
when(mNotificationRoundnessManager.shouldRoundNotificationPulsing()).thenReturn(true);
|
||||||
|
when(mTestHelper.getStatusBarStateController().isDozing()).thenReturn(true);
|
||||||
|
|
||||||
|
// Pulsing: Enabled
|
||||||
|
mEntry.setHeadsUp(true);
|
||||||
|
mHeadsUpAppearanceController.onHeadsUpStateChanged(mEntry, true);
|
||||||
|
|
||||||
|
String debugString = mRow.getRoundableState().debugString();
|
||||||
|
assertEquals(
|
||||||
|
"If Pulsing is enabled, roundness should be set to 1. Value: " + debugString,
|
||||||
|
/* expected = */ 1,
|
||||||
|
/* actual = */ mRow.getTopRoundness(),
|
||||||
|
/* delta = */ 0.001
|
||||||
|
);
|
||||||
|
assertTrue(debugString.contains("Pulsing"));
|
||||||
|
|
||||||
|
// Pulsing: Disabled
|
||||||
|
mEntry.setHeadsUp(false);
|
||||||
|
mHeadsUpAppearanceController.onHeadsUpStateChanged(mEntry, false);
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
"If Pulsing is disabled, roundness should be set to 0. Value: "
|
||||||
|
+ mRow.getRoundableState().debugString(),
|
||||||
|
/* expected = */ 0,
|
||||||
|
/* actual = */ mRow.getTopRoundness(),
|
||||||
|
/* delta = */ 0.001
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user