Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c77e818e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update speedbump within NSSL"

parents 957c1d93 c98b6435
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -231,8 +231,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
     * The algorithm which calculates the properties for our children
     */
    private final StackScrollAlgorithm mStackScrollAlgorithm;

    private final AmbientState mAmbientState;

    private GroupMembershipManager mGroupMembershipManager;
    private GroupExpansionManager mGroupExpansionManager;
    private NotificationActivityStarter mNotificationActivityStarter;
@@ -1009,6 +1009,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        return mAmbientState.isPulseExpanding();
    }

    public int getSpeedBumpIndex() {
        return mAmbientState.getSpeedBumpIndex();
    }

    @Override
    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
@@ -1063,7 +1067,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    }

    @ShadeViewRefactor(RefactorComponent.ADAPTER)
    public void updateSpeedBumpIndex(int newIndex, boolean noAmbient) {
    private void setSpeedBumpIndex(int newIndex, boolean noAmbient) {
        mAmbientState.setSpeedBumpIndex(newIndex);
        mNoAmbient = noAmbient;
    }
@@ -4992,6 +4996,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            mController.updateShowEmptyShadeView();
            updateFooter();
        }

        updateSpeedBumpIndex();
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
@@ -5002,6 +5008,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            mController.updateShowEmptyShadeView();
            updateFooter();
        }

        updateSpeedBumpIndex();
    }

    public void addContainerViewAt(View v, int index) {
@@ -5011,6 +5019,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            mController.updateShowEmptyShadeView();
            updateFooter();
        }

        updateSpeedBumpIndex();
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
@@ -5237,6 +5247,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    protected void setStatusBarState(int statusBarState) {
        mStatusBarState = statusBarState;
        mAmbientState.setStatusBarState(statusBarState);
        updateSpeedBumpIndex();
    }

    void onStatePostChange(boolean fromShadeLocked) {
@@ -5777,7 +5788,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
  }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    public void updateSpeedBumpIndex() {
    private void updateSpeedBumpIndex() {
        int speedBumpIndex = 0;
        int currentIndex = 0;
        final int N = getChildCount();
@@ -5799,7 +5810,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            }
        }
        boolean noAmbient = speedBumpIndex == N;
        updateSpeedBumpIndex(speedBumpIndex, noAmbient);
        setSpeedBumpIndex(speedBumpIndex, noAmbient);
    }

    /** Updates the indices of the boundaries between sections. */
+0 −4
Original line number Diff line number Diff line
@@ -1035,10 +1035,6 @@ public class NotificationStackScrollLayoutController {
        mView.updateSectionBoundaries(reason);
    }

    public void updateSpeedBumpIndex() {
        mView.updateSpeedBumpIndex();
    }

    public void updateFooter() {
        mView.updateFooter();
    }
+0 −1
Original line number Diff line number Diff line
@@ -3069,7 +3069,6 @@ public class NotificationPanelViewController extends PanelViewController {
     */
    public void updateNotificationViews(String reason) {
        mNotificationStackScrollLayoutController.updateSectionBoundaries(reason);
        mNotificationStackScrollLayoutController.updateSpeedBumpIndex();
        mNotificationStackScrollLayoutController.updateFooter();

        mNotificationIconAreaController.updateNotificationIcons(createVisibleEntriesList());
+54 −0
Original line number Diff line number Diff line
@@ -449,6 +449,60 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
                .DISMISS_SILENT_NOTIFICATIONS_PANEL.getId(), mUiEventLoggerFake.eventId(0));
    }

    @Test
    public void testAddNotificationUpdatesSpeedBumpIndex() {
        // initial state == -1
        assertEquals(-1, mStackScroller.getSpeedBumpIndex());

        // add notification that's before the speed bump
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        NotificationEntry entry = mock(NotificationEntry.class);
        when(row.getEntry()).thenReturn(entry);
        when(entry.isAmbient()).thenReturn(false);
        mStackScroller.addContainerView(row);

        // speed bump = 1
        assertEquals(1, mStackScroller.getSpeedBumpIndex());
    }

    @Test
    public void testAddAmbientNotificationNoSpeedBumpUpdate() {
        // initial state == -1
        assertEquals(-1, mStackScroller.getSpeedBumpIndex());

        // add notification that's after the speed bump
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        NotificationEntry entry = mock(NotificationEntry.class);
        when(row.getEntry()).thenReturn(entry);
        when(entry.isAmbient()).thenReturn(true);
        mStackScroller.addContainerView(row);

        // speed bump is set to 0
        assertEquals(0, mStackScroller.getSpeedBumpIndex());
    }

    @Test
    public void testRemoveNotificationUpdatesSpeedBump() {
        // initial state == -1
        assertEquals(-1, mStackScroller.getSpeedBumpIndex());

        // add 3 notification that are after the speed bump
        ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
        NotificationEntry entry = mock(NotificationEntry.class);
        when(row.getEntry()).thenReturn(entry);
        when(entry.isAmbient()).thenReturn(false);
        mStackScroller.addContainerView(row);

        // speed bump is 1
        assertEquals(1, mStackScroller.getSpeedBumpIndex());

        // remove the notification that was before the speed bump
        mStackScroller.removeContainerView(row);

        // speed bump is now 0
        assertEquals(0, mStackScroller.getSpeedBumpIndex());
    }

    private void setBarStateForTest(int state) {
        // Can't inject this through the listener or we end up on the actual implementation
        // rather than the mock because the spy just coppied the anonymous inner /shruggie.