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

Commit 20a91cc8 authored by Lyn Han's avatar Lyn Han Committed by Android (Google) Code Review
Browse files

Merge "Fix HUN pinning in split shade" into main

parents 5522d654 9be62325
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ public class AmbientState implements Dumpable {
    private float mAppearFraction;
    private float mOverExpansion;
    private int mStackTopMargin;
    private boolean mUseSplitShade;

    /** Distance of top of notifications panel from top of screen. */
    private float mStackY = 0;
@@ -227,6 +228,20 @@ public class AmbientState implements Dumpable {
        mIsFlinging = isFlinging;
    }

    /**
     * @param useSplitShade True if we are showing split shade.
     */
    public void setUseSplitShade(boolean useSplitShade) {
        mUseSplitShade = useSplitShade;
    }

    /**
     * @return True if we are showing split shade.
     */
    public boolean getUseSplitShade() {
        return mUseSplitShade;
    }

    /**
     * @return Fraction of shade expansion.
     */
+1 −0
Original line number Diff line number Diff line
@@ -5690,6 +5690,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        boolean split = mSplitShadeStateController.shouldUseSplitNotificationShade(getResources());
        if (split != mShouldUseSplitNotificationShade) {
            mShouldUseSplitNotificationShade = split;
            mAmbientState.setUseSplitShade(split);
            updateDismissBehavior();
            updateUseRoundedRectClipping();
        }
+10 −5
Original line number Diff line number Diff line
@@ -572,7 +572,8 @@ public class StackScrollAlgorithm {

        float viewEnd = viewState.getYTranslation() + viewState.height + ambientState.getStackY();
        maybeUpdateHeadsUpIsVisible(viewState, ambientState.isShadeExpanded(),
                view.mustStayOnScreen(), /* topVisible */ viewState.getYTranslation() >= 0,
                view.mustStayOnScreen(),
                /* topVisible= */ viewState.getYTranslation() >= mNotificationScrimPadding,
                viewEnd, /* hunMax */ ambientState.getMaxHeadsUpTranslation()
        );
        if (view instanceof FooterView) {
@@ -777,8 +778,12 @@ public class StackScrollAlgorithm {
                if (shouldHunBeVisibleWhenScrolled(row.mustStayOnScreen(),
                        childState.headsUpIsVisible, row.showingPulsing(),
                        ambientState.isOnKeyguard(), row.getEntry().isStickyAndNotDemoted())) {
                    // Ensure that the heads up is always visible even when scrolled off
                    clampHunToTop(mQuickQsOffsetHeight, ambientState.getStackTranslation(),
                    // Ensure that the heads up is always visible even when scrolled off.
                    // NSSL y starts at top of screen in non-split-shade, but below the qs offset
                    // in split shade, so we only need to inset by the scrim padding in split shade.
                    final float clampInset = ambientState.getUseSplitShade()
                            ? mNotificationScrimPadding : mQuickQsOffsetHeight;
                    clampHunToTop(clampInset, ambientState.getStackTranslation(),
                            row.getCollapsedHeight(), childState);
                    if (isTopEntry && row.isAboveShelf()) {
                        // the first hun can't get off screen.
@@ -838,10 +843,10 @@ public class StackScrollAlgorithm {
     * Transition pinned collapsed HUN to full height when scrolling back up.
     */
    @VisibleForTesting
    void clampHunToTop(float quickQsOffsetHeight, float stackTranslation, float collapsedHeight,
    void clampHunToTop(float clampInset, float stackTranslation, float collapsedHeight,
                       ExpandableViewState viewState) {

        final float newTranslation = Math.max(quickQsOffsetHeight + stackTranslation,
        final float newTranslation = Math.max(clampInset + stackTranslation,
                viewState.getYTranslation());

        // Transition from collapsed pinned state to fully expanded state