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

Commit 4edcd5f2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I9a5db6a2,Idc097603 into main

* changes:
  [SB][Notif] Refactor HeadsUpAppearanceController to use PinnedStatus.
  [SB][Notif] Small cleanups of HeadsUpAppearanceController.
parents 38818737 61bf466a
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.phone;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isNull;
@@ -35,7 +36,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;
import com.android.systemui.flags.FakeFeatureFlagsClassic;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shade.ShadeHeadsUpTracker;
@@ -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;
@@ -87,7 +86,6 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
    private KeyguardStateController mKeyguardStateController;
    private CommandQueue mCommandQueue;
    private NotificationRoundnessManager mNotificationRoundnessManager;
    private final FakeFeatureFlagsClassic mFeatureFlags = new FakeFeatureFlagsClassic();

    @Before
    public void setUp() throws Exception {
@@ -124,7 +122,6 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
                mNotificationRoundnessManager,
                mHeadsUpStatusBarView,
                new Clock(mContext, null),
                mFeatureFlags,
                mock(HeadsUpNotificationIconInteractor.class),
                Optional.of(mOperatorNameView));
        mHeadsUpAppearanceController.setAppearFraction(0.0f, 0.0f);
@@ -141,21 +138,21 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
        mRow.setPinnedStatus(PinnedStatus.NotPinned);
        when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(false);
        mHeadsUpAppearanceController.onHeadsUpUnPinned(mEntry);
        assertEquals(null, mHeadsUpStatusBarView.getShowingEntry());
        assertNull(mHeadsUpStatusBarView.getShowingEntry());
    }

    @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
@@ -210,7 +207,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
                mNotificationRoundnessManager,
                mHeadsUpStatusBarView,
                new Clock(mContext, null),
                mFeatureFlags, mock(HeadsUpNotificationIconInteractor.class),
                mock(HeadsUpNotificationIconInteractor.class),
                Optional.empty());

        assertEquals(expandedHeight, newController.mExpandedHeight, 0.0f);
@@ -227,7 +224,7 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
        mHeadsUpAppearanceController.onViewDetached();

        verify(mHeadsUpManager).removeListener(any());
        verify(mDarkIconDispatcher).removeDarkReceiver((DarkIconDispatcher.DarkReceiver) any());
        verify(mDarkIconDispatcher).removeDarkReceiver(any());
        verify(mShadeHeadsUpTracker).removeTrackingHeadsUpListener(any());
        verify(mShadeHeadsUpTracker).setHeadsUpAppearanceController(isNull());
        verify(mStackScrollerController).removeOnExpandedHeightChangedListener(any());
+25 −26
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import androidx.annotation.NonNull;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.widget.ViewClippingUtil;
import com.android.systemui.dagger.qualifiers.DisplaySpecific;
import com.android.systemui.flags.FeatureFlagsClassic;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.res.R;
@@ -44,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;
@@ -98,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
@@ -108,7 +108,6 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
            };
    private boolean mAnimationsEnabled = true;
    private final KeyguardStateController mKeyguardStateController;
    private final FeatureFlagsClassic mFeatureFlags;
    private final HeadsUpNotificationIconInteractor mHeadsUpNotificationIconInteractor;

    @VisibleForTesting
@@ -127,7 +126,6 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
            NotificationRoundnessManager notificationRoundnessManager,
            HeadsUpStatusBarView headsUpStatusBarView,
            Clock clockView,
            FeatureFlagsClassic featureFlags,
            HeadsUpNotificationIconInteractor headsUpNotificationIconInteractor,
            @Named(OPERATOR_NAME_FRAME_VIEW) Optional<View> operatorNameViewOptional) {
        super(headsUpStatusBarView);
@@ -145,7 +143,6 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar

        mStackScrollerController = stackScrollerController;
        mShadeViewController = shadeViewController;
        mFeatureFlags = featureFlags;
        mHeadsUpNotificationIconInteractor = headsUpNotificationIconInteractor;
        mStackScrollerController.setHeadsUpAppearanceController(this);
        mClockView = clockView;
@@ -157,7 +154,7 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
            public void onLayoutChange(View v, int left, int top, int right, int bottom,
                    int oldLeft, int oldTop, int oldRight, int oldBottom) {
                if (shouldBeVisible()) {
                    updateTopEntry("onLayoutChange");
                    updateTopEntry();

                    // trigger scroller to notify the latest panel translation
                    mStackScrollerController.requestLayout();
@@ -207,7 +204,7 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar

    @Override
    public void onHeadsUpPinned(NotificationEntry entry) {
        updateTopEntry("onHeadsUpPinned");
        updateTopEntry();
        updateHeader(entry);
        updateHeadsUpAndPulsingRoundness(entry);
    }
@@ -218,7 +215,7 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
        mPhoneStatusBarTransitions.onHeadsUpStateChanged(isHeadsUp);
    }

    private void updateTopEntry(String reason) {
    private void updateTopEntry() {
        NotificationEntry newEntry = null;
        if (shouldBeVisible()) {
            newEntry = mHeadsUpManager.getTopEntry();
@@ -226,27 +223,29 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
        NotificationEntry previousEntry = mView.getShowingEntry();
        mView.setEntry(newEntry);
        if (newEntry != previousEntry) {
            boolean animateIsolation = false;
            if (newEntry == null) {
                // no heads up anymore, lets start the disappear animation

                setShown(false);
                animateIsolation = !isExpanded();
                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);
                animateIsolation = !isExpanded();
                setPinnedStatus(PinnedStatus.PinnedBySystem);
            }

            String isolatedIconKey;
            if (newEntry != null) {
                isolatedIconKey = newEntry.getRepresentativeEntry().getKey();
            } else {
                isolatedIconKey = null;
            }
            mHeadsUpNotificationIconInteractor.setIsolatedIconNotificationKey(
                    newEntry == null ? null : newEntry.getRepresentativeEntry().getKey());
            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);
@@ -330,8 +329,8 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
    }

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

    /**
@@ -355,7 +354,7 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar

    @Override
    public void onHeadsUpUnPinned(NotificationEntry entry) {
        updateTopEntry("onHeadsUpUnPinned");
        updateTopEntry();
        updateHeader(entry);
        updateHeadsUpAndPulsingRoundness(entry);
    }
@@ -373,7 +372,7 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
            updateHeadsUpHeaders();
        }
        if (isExpanded() != oldIsExpanded) {
            updateTopEntry("setAppearFraction");
            updateTopEntry();
        }
    }

@@ -447,11 +446,11 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
    }

    public void onStateChanged() {
        updateTopEntry("onStateChanged");
        updateTopEntry();
    }

    @Override
    public void onFullyHiddenChanged(boolean isFullyHidden) {
        updateTopEntry("onFullyHiddenChanged");
        updateTopEntry();
    }
}