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

Commit a941522a authored by Shawn Lee's avatar Shawn Lee Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Fix HUN animation and sizing in QS" into main

parents 6f18dcbc dfb513d3
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -130,8 +130,8 @@ object Notifications {
fun SceneScope.HeadsUpNotificationSpace(
    stackScrollView: NotificationScrollView,
    viewModel: NotificationsPlaceholderViewModel,
    useHunBounds: () -> Boolean = { true },
    modifier: Modifier = Modifier,
    isPeekFromBottom: Boolean = false,
) {
    Box(
        modifier =
@@ -141,6 +141,12 @@ fun SceneScope.HeadsUpNotificationSpace(
                .notificationHeadsUpHeight(stackScrollView)
                .debugBackground(viewModel, DEBUG_HUN_COLOR)
                .onGloballyPositioned { coordinates: LayoutCoordinates ->
                    // This element is sometimes opted out of the shared element system, so there
                    // can be multiple instances of it during a transition. Thus we need to
                    // determine which instance should feed its bounds to NSSL to avoid providing
                    // conflicting values
                    val useBounds = useHunBounds()
                    if (useBounds) {
                        val positionInWindow = coordinates.positionInWindow()
                        val boundsInWindow = coordinates.boundsInWindow()
                        debugLog(viewModel) {
@@ -148,11 +154,13 @@ fun SceneScope.HeadsUpNotificationSpace(
                                " size=${coordinates.size}" +
                                " bounds=$boundsInWindow"
                        }
                    // Note: boundsInWindow doesn't scroll off the screen, so use positionInWindow
                        // Note: boundsInWindow doesn't scroll off the screen, so use
                        // positionInWindow
                        // for top bound, which can scroll off screen while snoozing
                        stackScrollView.setHeadsUpTop(positionInWindow.y)
                        stackScrollView.setHeadsUpBottom(boundsInWindow.bottom)
                    }
                }
    )
}

+5 −1
Original line number Diff line number Diff line
@@ -416,11 +416,11 @@ private fun SceneScope.QuickSettingsScene(
        HeadsUpNotificationSpace(
            stackScrollView = notificationStackScrollView,
            viewModel = notificationsPlaceholderViewModel,
            useHunBounds = { shouldUseQuickSettingsHunBounds(layoutState.transitionState) },
            modifier =
                Modifier.align(Alignment.BottomCenter)
                    .navigationBarsPadding()
                    .padding(horizontal = shadeHorizontalPadding),
            isPeekFromBottom = true,
        )
        NotificationScrollingStack(
            shadeSession = shadeSession,
@@ -446,3 +446,7 @@ private fun SceneScope.QuickSettingsScene(
        )
    }
}

private fun shouldUseQuickSettingsHunBounds(state: TransitionState): Boolean {
    return state is TransitionState.Idle && state.currentScene == Scenes.QuickSettings
}
+4 −0
Original line number Diff line number Diff line
@@ -77,6 +77,10 @@ val SceneContainerTransitions = transitions {
    }
    from(Scenes.Lockscreen, to = Scenes.QuickSettings) { lockscreenToQuickSettingsTransition() }
    from(Scenes.Lockscreen, to = Scenes.Gone) { lockscreenToGoneTransition() }
    from(Scenes.QuickSettings, to = Scenes.Shade) {
        reversed { shadeToQuickSettingsTransition() }
        sharedElement(Notifications.Elements.HeadsUpNotificationPlaceholder, enabled = false)
    }
    from(Scenes.Shade, to = Scenes.QuickSettings) { shadeToQuickSettingsTransition() }

    // Overlay transitions
+17 −4
Original line number Diff line number Diff line
@@ -106,7 +106,8 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
    @VisibleForTesting
    public final ArraySet<NotificationEntry> mEntriesToRemoveWhenReorderingAllowed
            = new ArraySet<>();
    private boolean mIsExpanded;
    private boolean mIsShadeOrQsExpanded;
    private boolean mIsQsExpanded;
    private int mStatusBarState;
    private AnimationStateHandler mAnimationStateHandler;

@@ -178,6 +179,10 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
        });
        javaAdapter.alwaysCollectFlow(shadeInteractor.isAnyExpanded(),
                    this::onShadeOrQsExpanded);
        if (SceneContainerFlag.isEnabled()) {
            javaAdapter.alwaysCollectFlow(shadeInteractor.isQsExpanded(),
                    this::onQsExpanded);
        }
        if (NotificationThrottleHun.isEnabled()) {
            mVisualStabilityProvider.addPersistentReorderingBannedListener(
                    mOnReorderingBannedListener);
@@ -287,14 +292,19 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
    }

    private void onShadeOrQsExpanded(Boolean isExpanded) {
        if (isExpanded != mIsExpanded) {
            mIsExpanded = isExpanded;
        if (isExpanded != mIsShadeOrQsExpanded) {
            mIsShadeOrQsExpanded = isExpanded;
            if (!SceneContainerFlag.isEnabled() && isExpanded) {
                mHeadsUpAnimatingAway.setValue(false);
            }
        }
    }

    private void onQsExpanded(Boolean isQsExpanded) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        if (isQsExpanded != mIsQsExpanded) mIsQsExpanded = isQsExpanded;
    }

    /**
     * Set that we are exiting the headsUp pinned mode, but some notifications might still be
     * animating out. This is used to keep the touchable regions in a reasonable state.
@@ -490,7 +500,10 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements

    @Override
    protected boolean shouldHeadsUpBecomePinned(NotificationEntry entry) {
        boolean pin = mStatusBarState == StatusBarState.SHADE && !mIsExpanded;
        boolean pin = mStatusBarState == StatusBarState.SHADE && !mIsShadeOrQsExpanded;
        if (SceneContainerFlag.isEnabled()) {
            pin |= mIsQsExpanded;
        }
        if (mBypassController.getBypassEnabled()) {
            pin |= mStatusBarState == StatusBarState.KEYGUARD;
        }
+1 −0
Original line number Diff line number Diff line
@@ -1260,6 +1260,7 @@ public class NotificationStackScrollLayout
    @Override
    public void setHeadsUpBottom(float headsUpBottom) {
        mAmbientState.setHeadsUpBottom(headsUpBottom);
        mStateAnimator.setHeadsUpAppearHeightBottom(Math.round(headsUpBottom));
    }

    @Override