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

Commit 03c4f296 authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "Build an isHeadsUpAnimatingAway signal from the NSSL" into main

parents 4e302655 f578afd6
Loading
Loading
Loading
Loading
+37 −10
Original line number Diff line number Diff line
@@ -191,6 +191,7 @@ import com.android.systemui.statusbar.notification.PropertyAnimator;
import com.android.systemui.statusbar.notification.ViewGroupFadeHelper;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor;
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationInteractor;
import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefactor;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
@@ -438,6 +439,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    private boolean mExpandingFromHeadsUp;
    private boolean mCollapsedOnDown;
    private boolean mClosingWithAlphaFadeOut;
    private boolean mHeadsUpVisible;
    private boolean mHeadsUpAnimatingAway;
    private final FalsingManager mFalsingManager;
    private final FalsingCollector mFalsingCollector;
@@ -605,6 +607,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    private final PrimaryBouncerToGoneTransitionViewModel mPrimaryBouncerToGoneTransitionViewModel;
    private final SharedNotificationContainerInteractor mSharedNotificationContainerInteractor;
    private final ActiveNotificationsInteractor mActiveNotificationsInteractor;
    private final HeadsUpNotificationInteractor mHeadsUpNotificationInteractor;
    private final KeyguardTransitionInteractor mKeyguardTransitionInteractor;
    private final KeyguardInteractor mKeyguardInteractor;
    private final PowerInteractor mPowerInteractor;
@@ -770,6 +773,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
            ActivityStarter activityStarter,
            SharedNotificationContainerInteractor sharedNotificationContainerInteractor,
            ActiveNotificationsInteractor activeNotificationsInteractor,
            HeadsUpNotificationInteractor headsUpNotificationInteractor,
            ShadeAnimationInteractor shadeAnimationInteractor,
            KeyguardViewConfigurator keyguardViewConfigurator,
            DeviceEntryFaceAuthInteractor deviceEntryFaceAuthInteractor,
@@ -804,6 +808,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        mKeyguardTransitionInteractor = keyguardTransitionInteractor;
        mSharedNotificationContainerInteractor = sharedNotificationContainerInteractor;
        mActiveNotificationsInteractor = activeNotificationsInteractor;
        mHeadsUpNotificationInteractor = headsUpNotificationInteractor;
        mKeyguardInteractor = keyguardInteractor;
        mPowerInteractor = powerInteractor;
        mKeyguardViewConfigurator = keyguardViewConfigurator;
@@ -1216,6 +1221,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
                    }
                },
                mMainDispatcher);

        if (NotificationsHeadsUpRefactor.isEnabled()) {
            collectFlow(mView, mHeadsUpNotificationInteractor.isHeadsUpOrAnimatingAway(),
                    setHeadsUpVisible(), mMainDispatcher);
        }
    }

    @VisibleForTesting
@@ -3055,7 +3065,21 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        mPanelAlphaEndAction = r;
    }

    private Consumer<Boolean> setHeadsUpVisible() {
        return (Boolean isHeadsUpVisible) -> {
            mHeadsUpVisible = isHeadsUpVisible;

            if (isHeadsUpVisible) {
                updateNotificationTranslucency();
            }
            updateExpansionAndVisibility();
            updateGestureExclusionRect();
            mKeyguardStatusBarViewController.updateForHeadsUp();
        };
    }

    private void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
        NotificationsHeadsUpRefactor.assertInLegacyMode();
        mHeadsUpAnimatingAway = headsUpAnimatingAway;
        mNotificationStackScrollLayoutController.setHeadsUpAnimatingAway(headsUpAnimatingAway);
        updateVisibility();
@@ -3071,13 +3095,16 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    }

    private boolean shouldPanelBeVisible() {
        boolean headsUpVisible = mHeadsUpAnimatingAway || mHeadsUpPinnedMode;
        boolean headsUpVisible = NotificationsHeadsUpRefactor.isEnabled() ? mHeadsUpVisible
                : (mHeadsUpAnimatingAway || mHeadsUpPinnedMode);
        return headsUpVisible || isExpanded() || mBouncerShowing;
    }

    private void setHeadsUpManager(HeadsUpManager headsUpManager) {
        mHeadsUpManager = headsUpManager;
        if (!NotificationsHeadsUpRefactor.isEnabled()) {
            mHeadsUpManager.addListener(mOnHeadsUpChangedListener);
        }
        mHeadsUpTouchHelper = new HeadsUpTouchHelper(
                headsUpManager,
                mStatusBarService,
@@ -3165,8 +3192,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    }

    private boolean isPanelVisibleBecauseOfHeadsUp() {
        return (mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpAnimatingAway)
                && mBarState == StatusBarState.SHADE;
        boolean headsUpVisible = NotificationsHeadsUpRefactor.isEnabled() ? mHeadsUpVisible
                : (mHeadsUpManager.hasPinnedHeadsUp() || mHeadsUpAnimatingAway);
        return headsUpVisible && mBarState == StatusBarState.SHADE;
    }

    private boolean isPanelVisibleBecauseScrimIsAnimatingOff() {
@@ -3479,6 +3507,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        ipw.print("mExpandingFromHeadsUp="); ipw.println(mExpandingFromHeadsUp);
        ipw.print("mCollapsedOnDown="); ipw.println(mCollapsedOnDown);
        ipw.print("mClosingWithAlphaFadeOut="); ipw.println(mClosingWithAlphaFadeOut);
        ipw.print("mHeadsUpVisible="); ipw.println(mHeadsUpVisible);
        ipw.print("mHeadsUpAnimatingAway="); ipw.println(mHeadsUpAnimatingAway);
        ipw.print("mShowIconsWhenExpanded="); ipw.println(mShowIconsWhenExpanded);
        ipw.print("mIndicationBottomPadding="); ipw.println(mIndicationBottomPadding);
@@ -4384,6 +4413,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
    private final class ShadeHeadsUpChangedListener implements OnHeadsUpChangedListener {
        @Override
        public void onHeadsUpPinnedModeChanged(final boolean inPinnedMode) {
            NotificationsHeadsUpRefactor.assertInLegacyMode();

            if (inPinnedMode) {
                mHeadsUpExistenceChangedRunnable.run();
                updateNotificationTranslucency();
@@ -4400,9 +4431,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump

        @Override
        public void onHeadsUpPinned(NotificationEntry entry) {
            if (NotificationsHeadsUpRefactor.isEnabled()) {
                return;
            }
            NotificationsHeadsUpRefactor.assertInLegacyMode();

            if (!isKeyguardShowing()) {
                mNotificationStackScrollLayoutController.generateHeadsUpAnimation(entry, true);
@@ -4411,9 +4440,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump

        @Override
        public void onHeadsUpUnPinned(NotificationEntry entry) {
            if (NotificationsHeadsUpRefactor.isEnabled()) {
                return;
            }
            NotificationsHeadsUpRefactor.assertInLegacyMode();

            // When we're unpinning the notification via active edge they remain heads-upped,
            // we need to make sure that an animation happens in this case, otherwise the
+4 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.data.repository

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow

/**
 * A repository of currently displayed heads up notifications.
@@ -31,11 +32,13 @@ interface HeadsUpRepository {
     * True if we are exiting the headsUp pinned mode, and some notifications might still be
     * animating out. This is used to keep their view container visible.
     */
    val isHeadsUpAnimatingAway: Flow<Boolean>
    val isHeadsUpAnimatingAway: StateFlow<Boolean>

    /** The heads up row that should be displayed on top. */
    val topHeadsUpRow: Flow<HeadsUpRowRepository?>

    /** Set of currently active top-level heads up rows to be displayed. */
    val activeHeadsUpRows: Flow<Set<HeadsUpRowRepository>>

    fun setHeadsUpAnimatingAway(animatingAway: Boolean)
}
+4 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map

class HeadsUpNotificationInteractor @Inject constructor(repository: HeadsUpRepository) {
class HeadsUpNotificationInteractor @Inject constructor(private val repository: HeadsUpRepository) {

    val topHeadsUpRow: Flow<HeadsUpRowKey?> = repository.topHeadsUpRow

@@ -67,6 +67,9 @@ class HeadsUpNotificationInteractor @Inject constructor(repository: HeadsUpRepos
    fun headsUpRow(key: HeadsUpRowKey): HeadsUpRowInteractor =
        HeadsUpRowInteractor(key as HeadsUpRowRepository)
    fun elementKeyFor(key: HeadsUpRowKey) = (key as HeadsUpRowRepository).elementKey
    fun setHeadsUpAnimatingAway(animatingAway: Boolean) {
        repository.setHeadsUpAnimatingAway(animatingAway)
    }
}

class HeadsUpRowInteractor(repository: HeadsUpRowRepository)
+37 −3
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ import com.android.systemui.statusbar.notification.row.ActivatableNotificationVi
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.row.StackScrollerDecorView;
import com.android.systemui.statusbar.notification.shared.NotificationsHeadsUpRefactor;
import com.android.systemui.statusbar.notification.shared.NotificationsImprovedHunAnimation;
import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor;
import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds;
@@ -450,7 +451,9 @@ public class NotificationStackScrollLayout
    private boolean mIsClipped;
    private Rect mRequestedClipBounds;
    private boolean mInHeadsUpPinnedMode;
    private boolean mHeadsUpAnimatingAway;
    @VisibleForTesting
    boolean mHeadsUpAnimatingAway;
    private Consumer<Boolean> mHeadsUpAnimatingAwayListener;
    private int mStatusBarState;
    private int mUpcomingStatusBarState;
    private boolean mHeadsUpGoingAwayAnimationsAllowed = true;
@@ -4084,7 +4087,14 @@ public class NotificationStackScrollLayout
        mSwipeHelper.setIsExpanded(isExpanded);
        if (changed) {
            mWillExpand = false;
            if (!mIsExpanded) {
            if (mIsExpanded) {
                // Resetting headsUpAnimatingAway on Shade expansion avoids delays caused by
                // waiting for all child animations to finish.
                // TODO(b/328390331) Do we need to reset this on QS expanded as well?
                if (NotificationsHeadsUpRefactor.isEnabled()) {
                    setHeadsUpAnimatingAway(false);
                }
            } else {
                mGroupExpansionManager.collapseGroups();
                mExpandHelper.cancelImmediately();
                if (!mIsExpansionChanging) {
@@ -4190,6 +4200,9 @@ public class NotificationStackScrollLayout

    void onChildAnimationFinished() {
        setAnimationRunning(false);
        if (NotificationsHeadsUpRefactor.isEnabled()) {
            setHeadsUpAnimatingAway(false);
        }
        requestChildrenUpdate();
        runAnimationFinishedRunnables();
        clearTransient();
@@ -4717,6 +4730,7 @@ public class NotificationStackScrollLayout
    }

    public void generateHeadsUpAnimation(NotificationEntry entry, boolean isHeadsUp) {
        NotificationsHeadsUpRefactor.assertInLegacyMode();
        ExpandableNotificationRow row = entry.getHeadsUpAnimationView();
        generateHeadsUpAnimation(row, isHeadsUp);
    }
@@ -4750,6 +4764,9 @@ public class NotificationStackScrollLayout
            mNeedsAnimation = true;
            if (!mIsExpanded && !mWillExpand && !isHeadsUp) {
                row.setHeadsUpAnimatingAway(true);
                if (NotificationsHeadsUpRefactor.isEnabled()) {
                    setHeadsUpAnimatingAway(true);
                }
            }
            requestChildrenUpdate();
        }
@@ -4939,11 +4956,28 @@ public class NotificationStackScrollLayout
        updateClipping();
    }

    /** TODO(b/328390331) make this private, when {@link NotificationsHeadsUpRefactor} is removed */
    public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
        if (mHeadsUpAnimatingAway != headsUpAnimatingAway) {
            mHeadsUpAnimatingAway = headsUpAnimatingAway;
            if (mHeadsUpAnimatingAwayListener != null) {
                mHeadsUpAnimatingAwayListener.accept(headsUpAnimatingAway);
            }
        }
        updateClipping();
    }

    /**
     * Sets a listener to be notified about the heads up disappear animation state changes. If there
     * are overlapping animations, it will receive updates when the first disappar animation has
     * started, and when the last has finished.
     *
     * @param headsUpAnimatingAwayListener to be notified about disappear animation state changes.
     */
    public void setHeadsUpAnimatingAwayListener(
            Consumer<Boolean> headsUpAnimatingAwayListener) {
        mHeadsUpAnimatingAwayListener = headsUpAnimatingAwayListener;
    }
    @VisibleForTesting
    public void setStatusBarState(int statusBarState) {
        mStatusBarState = statusBarState;
+1 −0
Original line number Diff line number Diff line
@@ -1482,6 +1482,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
    }

    public void setHeadsUpAnimatingAway(boolean headsUpAnimatingAway) {
        NotificationsHeadsUpRefactor.assertInLegacyMode();
        mView.setHeadsUpAnimatingAway(headsUpAnimatingAway);
    }

Loading