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

Commit 9be62325 authored by Lyn's avatar Lyn
Browse files

Fix HUN pinning in split shade

When notifications are scrolled in split shade,
for incoming HUNs that get pinned, fix:
1) Wrong inset
2) Flicker when scrollY goes back to 0

Fixes: 288553563
Test: in split shade, scroll notifications up, send delayed HUN
      => collapsed HUN pinned to correct inset

      scroll notifications down so that scrollY=0
      => HUN expands in place with no flickering

      do the above in non-split shade
      => no regressions

Flag: NONE
Change-Id: Ibf843e8c195aa7140c00dde0dacdf00eb3654af9
parent c46f6012
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
@@ -5702,6 +5702,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