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

Commit cffff723 authored by 0's avatar 0 Committed by Shawn Lee
Browse files

[flexiglass] Fix HUN alpha during Gone -> Shade transition

In Flexiglass we need a new way of getting the tracked row object from HeadsUpTouchHelper to NSSL, as the legacy path was through NPVC. This can now be done through NSSLC. In addition, we need the Z translation of the HUN to fade gradually as the shade expands, and remain higher than the rest of the stack throughout the transition to maintain the correct alpha.

Bug: 357661886
Test: manually verified that the HUN alpha is correct and drop shadow transitions gradually during the scene transition to Shade
Flag: com.android.systemui.scene_container
Change-Id: I3379d978019476972f78e1813f4f1c12bbf15c37
parent 0544978e
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -139,6 +139,9 @@ public class AmbientState implements Dumpable {
    /** Fraction of shade expansion. */
    private float mExpansionFraction;

    /** Fraction of QS expansion. 0 when in shade, 1 when in QS. */
    private float mQsExpansionFraction;

    /** Height of the notifications panel when expansion completes. */
    private float mStackEndHeight;

@@ -207,6 +210,14 @@ public class AmbientState implements Dumpable {
        mExpansionFraction = expansionFraction;
    }

    /**
     * @param expansionFraction Fraction of QS expansion.
     */
    public void setQsExpansionFraction(float expansionFraction) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        mQsExpansionFraction = expansionFraction;
    }

    /**
     * @param isSwipingUp Whether we are swiping up.
     */
@@ -257,6 +268,14 @@ public class AmbientState implements Dumpable {
        return mExpansionFraction;
    }

    /**
     * @return Fraction of QS expansion.
     */
    public float getQsExpansionFraction() {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0f;
        return mQsExpansionFraction;
    }

    /**
     * @see #getStackHeight()
     */
@@ -837,6 +856,7 @@ public class AmbientState implements Dumpable {
        pw.println("mAppearFraction=" + mAppearFraction);
        pw.println("mAppearing=" + mAppearing);
        pw.println("mExpansionFraction=" + mExpansionFraction);
        pw.println("mQsExpansionFraction=" + mQsExpansionFraction);
        pw.println("mExpandingVelocity=" + mExpandingVelocity);
        pw.println("mOverScrollTopAmount=" + mOverScrollTopAmount);
        pw.println("mOverScrollBottomAmount=" + mOverScrollBottomAmount);
+6 −0
Original line number Diff line number Diff line
@@ -1556,6 +1556,12 @@ public class NotificationStackScrollLayout
        }
    }

    @Override
    public void setQsExpandFraction(float expandFraction) {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return;
        mAmbientState.setQsExpansionFraction(expandFraction);
    }

    /**
     * Update the height of the panel.
     *
+28 −1
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ import com.android.systemui.statusbar.notification.stack.ui.viewbinder.Notificat
import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
import com.android.systemui.statusbar.phone.HeadsUpNotificationViewControllerEmptyImpl;
import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
import com.android.systemui.statusbar.phone.HeadsUpTouchHelper.HeadsUpNotificationViewController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener;
@@ -773,7 +774,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                    mHeadsUpManager,
                    statusBarService.get(),
                    getHeadsUpCallback(),
                    new HeadsUpNotificationViewControllerEmptyImpl()
                    getHeadsUpNotificationViewController()
            );
        }
        mNotificationRoundnessManager = notificationRoundnessManager;
@@ -1850,6 +1851,32 @@ public class NotificationStackScrollLayoutController implements Dumpable {
        return mTouchHandler;
    }

    private HeadsUpNotificationViewController getHeadsUpNotificationViewController() {
        HeadsUpNotificationViewController headsUpViewController;
        if (SceneContainerFlag.isEnabled()) {
            headsUpViewController = new HeadsUpNotificationViewController() {
                @Override
                public void setHeadsUpDraggingStartingHeight(int startHeight) {
                    // do nothing
                }

                @Override
                public void setTrackedHeadsUp(ExpandableNotificationRow expandableNotificationRow) {
                    setTrackingHeadsUp(expandableNotificationRow);
                }

                @Override
                public void startExpand(float newX, float newY, boolean startTracking,
                        float expandedHeight) {
                    // do nothing
                }
            };
        } else {
            headsUpViewController = new HeadsUpNotificationViewControllerEmptyImpl();
        }
        return headsUpViewController;
    }

    @Override
    public void dump(@NonNull PrintWriter pw, @NonNull String[] args) {
        pw.println("mMaxAlphaFromView=" + mMaxAlphaFromView);
+25 −9
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.systemui.statusbar.notification.stack;

import static androidx.core.math.MathUtils.clamp;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
@@ -890,7 +888,14 @@ public class StackScrollAlgorithm {
                continue;
            }
            ExpandableViewState childState = row.getViewState();
            if (topHeadsUpEntry == null && row.mustStayOnScreen() && !childState.headsUpIsVisible) {
            boolean shouldSetTopHeadsUpEntry;
            if (SceneContainerFlag.isEnabled()) {
                shouldSetTopHeadsUpEntry = row.isHeadsUp();
            } else {
                shouldSetTopHeadsUpEntry = row.mustStayOnScreen();
            }
            if (topHeadsUpEntry == null && shouldSetTopHeadsUpEntry
                    && !childState.headsUpIsVisible) {
                topHeadsUpEntry = row;
                childState.location = ExpandableViewState.LOCATION_FIRST_HUN;
            }
@@ -898,7 +903,7 @@ public class StackScrollAlgorithm {
            float unmodifiedEndLocation = childState.getYTranslation() + childState.height;
            if (mIsExpanded) {
                if (SceneContainerFlag.isEnabled()) {
                    if (shouldHunBeVisibleWhenScrolled(row.mustStayOnScreen(),
                    if (shouldHunBeVisibleWhenScrolled(row.isHeadsUp(),
                            childState.headsUpIsVisible, row.showingPulsing(),
                            ambientState.isOnKeyguard(), row.getEntry().isStickyAndNotDemoted())) {
                        // the height of this child before clamping it to the top
@@ -909,10 +914,19 @@ public class StackScrollAlgorithm {
                                /* viewState = */ childState
                        );
                        float baseZ = ambientState.getBaseZHeight();
                        if (headsUpTranslation < ambientState.getStackTop()) {
                            // HUN displayed above the stack top, it needs a fix shadow
                            childState.setZTranslation(baseZ + mPinnedZTranslationExtra);
                        } else {
                        if (headsUpTranslation > ambientState.getStackTop()
                                && row.isAboveShelf()) {
                            // HUN displayed outside of the stack during transition from Gone/LS;
                            // add a shadow that corresponds to the transition progress.
                            float fraction = 1 - ambientState.getExpansionFraction();
                            childState.setZTranslation(baseZ + fraction * mPinnedZTranslationExtra);
                        } else if (headsUpTranslation < ambientState.getStackTop()
                                && row.isAboveShelf()) {
                            // HUN displayed outside of the stack during transition from QS;
                            // add a shadow that corresponds to the transition progress.
                            float fraction = ambientState.getQsExpansionFraction();
                            childState.setZTranslation(baseZ + fraction * mPinnedZTranslationExtra);
                        } else if (headsUpTranslation > ambientState.getStackTop()) {
                            // HUN displayed within the stack, add a shadow if it overlaps with
                            // other elements.
                            //
@@ -927,6 +941,8 @@ public class StackScrollAlgorithm {
                                    /* baseZ = */ baseZ,
                                    /* viewState = */ childState
                            );
                        } else {
                            childState.setZTranslation(baseZ);
                        }
                        if (isTopEntry && row.isAboveShelf()) {
                            clampHunToMaxTranslation(
@@ -1081,7 +1097,7 @@ public class StackScrollAlgorithm {
        if (scrollingContentTopPadding > 0f) {
            // scrollingContentTopPadding makes a gap between the bottom of the HUN and the top
            // of the scrolling content. Use this to animate to the full shadow.
            shadowFraction = clamp(overlap / scrollingContentTopPadding, 0f, 1f);
            shadowFraction = Math.clamp(overlap / scrollingContentTopPadding, 0f, 1f);
        }

        if (overlap > 0.0f) {
+3 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ interface NotificationScrollView {
    /** sets the current expand fraction */
    fun setExpandFraction(expandFraction: Float)

    /** sets the current QS expand fraction */
    fun setQsExpandFraction(expandFraction: Float)

    /** Sets whether the view is displayed in doze mode. */
    fun setDozing(dozing: Boolean)

Loading