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

Commit 61bf466a authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB][Notif] Refactor HeadsUpAppearanceController to use PinnedStatus.

No functional changes in this CL. This CL just updates
HeadsUpAppearanceController's internals to use PinnedStatus instead of a
boolean to keep track of the current heads up status. This will be used
in a future CL, where a notification could be pinned in different ways.

Bug: 364653005
Flag: EXEMPT refactor
Test: trigger HUN -> verify status bar behavior
Test: atest HeadsUpAppearanceControllerTest
Change-Id: I9a5db6a2b95ef8779a2bc6ed3302412ed2591d29
parent c6823fcc
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.statusbar.notification.headsup.HeadsUpManager;
import com.android.systemui.statusbar.policy.KeyguardStateController;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -143,17 +142,17 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
    }

    @Test
    public void testShownUpdated() {
    public void testPinnedStatusUpdated() {
        mRow.setPinnedStatus(PinnedStatus.PinnedBySystem);
        when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true);
        when(mHeadsUpManager.getTopEntry()).thenReturn(mEntry);
        mHeadsUpAppearanceController.onHeadsUpPinned(mEntry);
        assertTrue(mHeadsUpAppearanceController.isShown());
        assertEquals(PinnedStatus.PinnedBySystem, mHeadsUpAppearanceController.getPinnedStatus());

        mRow.setPinnedStatus(PinnedStatus.NotPinned);
        when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
        mHeadsUpAppearanceController.onHeadsUpUnPinned(mEntry);
        Assert.assertFalse(mHeadsUpAppearanceController.isShown());
        assertEquals(PinnedStatus.NotPinned, mHeadsUpAppearanceController.getPinnedStatus());
    }

    @Test
+18 −11
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationIconInteractor;
import com.android.systemui.statusbar.notification.headsup.HeadsUpManager;
import com.android.systemui.statusbar.notification.headsup.OnHeadsUpChangedListener;
import com.android.systemui.statusbar.notification.headsup.PinnedStatus;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation;
import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager;
@@ -97,7 +98,7 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
    @VisibleForTesting
    float mAppearFraction;
    private ExpandableNotificationRow mTrackedChild;
    private boolean mShown;
    private PinnedStatus mPinnedStatus = PinnedStatus.NotPinned;
    private final ViewClippingUtil.ClippingParameters mParentClippingParams =
            new ViewClippingUtil.ClippingParameters() {
                @Override
@@ -224,21 +225,27 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
        if (newEntry != previousEntry) {
            if (newEntry == null) {
                // no heads up anymore, lets start the disappear animation
                setShown(false);
                setPinnedStatus(PinnedStatus.NotPinned);
            } else if (previousEntry == null) {
                // We now have a headsUp and didn't have one before. Let's start the disappear
                // animation
                setShown(true);
                setPinnedStatus(PinnedStatus.PinnedBySystem);
            }
            mHeadsUpNotificationIconInteractor.setIsolatedIconNotificationKey(
                    newEntry == null ? null : newEntry.getRepresentativeEntry().getKey());

            String isolatedIconKey;
            if (newEntry != null) {
                isolatedIconKey = newEntry.getRepresentativeEntry().getKey();
            } else {
                isolatedIconKey = null;
            }
            mHeadsUpNotificationIconInteractor.setIsolatedIconNotificationKey(isolatedIconKey);
        }
    }

    private void setShown(boolean isShown) {
        if (mShown != isShown) {
            mShown = isShown;
            if (isShown) {
    private void setPinnedStatus(PinnedStatus pinnedStatus) {
        if (mPinnedStatus != pinnedStatus) {
            mPinnedStatus = pinnedStatus;
            if (pinnedStatus.isPinned()) {
                updateParentClipping(false /* shouldClip */);
                mView.setVisibility(View.VISIBLE);
                show(mView);
@@ -322,8 +329,8 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
    }

    @VisibleForTesting
    public boolean isShown() {
        return mShown;
    public PinnedStatus getPinnedStatus() {
        return mPinnedStatus;
    }

    /**