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

Commit 1ec71012 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Animate QS alpha on split shade pull down

When pulling down the shade in split mode, the quick settings alpha
should be directly connected to the drag down gesture and the same that
we have for the notification shade.

Test: manual
Bug: 200804740
Fixes: 196722669
Change-Id: I6532c8a78826a5b60609dc66557abc49a3f140c5
Merged-In: I6532c8a78826a5b60609dc66557abc49a3f140c5
parent 7efbb60d
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -200,10 +200,10 @@ public class Interpolators {
    /**
     * Interpolate alpha for notifications background scrim during shade expansion.
     * @param fraction Shade expansion fraction
     * @param forNotification If we want the alpha of the notification shade or the scrim.
     * @param forUiContent If we want the alpha of the scrims, or ui that's on top of them.
     */
    public static float getNotificationScrimAlpha(float fraction, boolean forNotification) {
        if (forNotification) {
    public static float getNotificationScrimAlpha(float fraction, boolean forUiContent) {
        if (forUiContent) {
            fraction = MathUtils.constrainedMap(0f, 1f, 0.3f, 1f, fraction);
        } else {
            fraction = MathUtils.constrainedMap(0f, 1f, 0f, 0.5f, fraction);
+12 −3
Original line number Diff line number Diff line
@@ -53,7 +53,16 @@ public interface QS extends FragmentBase {
    boolean isShowingDetail();
    void closeDetail();
    void animateHeaderSlidingOut();
    void setQsExpansion(float qsExpansionFraction, float headerTranslation);

    /**
     * Asks QS to update its presentation, according to {@code NotificationPanelViewController}.
     *
     * @param qsExpansionFraction How much each UI element in QS should be expanded (QQS to QS.)
     * @param panelExpansionFraction Whats the expansion of the whole shade.
     * @param headerTranslation How much we should vertically translate QS.
     */
    void setQsExpansion(float qsExpansionFraction, float panelExpansionFraction,
            float headerTranslation);
    void setHeaderListening(boolean listening);
    void notifyCustomizeChanged();
    void setContainer(ViewGroup container);
@@ -76,13 +85,13 @@ public interface QS extends FragmentBase {
    /**
     * If QS should translate as we pull it down, or if it should be static.
     */
    void setTranslateWhileExpanding(boolean shouldTranslate);
    void setInSplitShade(boolean shouldTranslate);

    /**
     * Set the amount of pixels we have currently dragged down if we're transitioning to the full
     * shade. 0.0f means we're not transitioning yet.
     */
    default void setTransitionToFullShadeAmount(float pxAmount, boolean animated) {}
    default void setTransitionToFullShadeAmount(float pxAmount, float progress) {}

    /**
     * A rounded corner clipping that makes QS feel as if it were behind everything.
+0 −14
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import com.android.systemui.qs.TouchAnimator.Builder;
import com.android.systemui.qs.TouchAnimator.Listener;
import com.android.systemui.qs.dagger.QSScope;
import com.android.systemui.qs.tileimpl.HeightOverrideable;
import com.android.systemui.statusbar.CrossFadeHelper;
import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
import com.android.wm.shell.animation.Interpolators;
@@ -170,19 +169,6 @@ public class QSAnimator implements Callback, PageListener, Listener, OnLayoutCha
        }
    }

    void startAlphaAnimation(boolean show) {
        if (show == mToShowing) {
            return;
        }
        mToShowing = show;
        if (show) {
            CrossFadeHelper.fadeIn(mQs.getView(), QQS_FADE_IN_DURATION, 0 /* delay */);
        } else {
            CrossFadeHelper.fadeOut(mQs.getView(), QQS_FADE_OUT_DURATION, 0 /* delay */,
                    null /* endRunnable */);
        }
    }

    /**
     * Sets whether or not the keyguard is currently being shown with a collapsed header.
     */
+34 −17
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
    private int mLayoutDirection;
    private QSFooter mFooter;
    private float mLastQSExpansion = -1;
    private float mLastPanelFraction;
    private boolean mQsDisabled;
    private ImageView mQsDragHandler;

@@ -120,7 +121,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
     * When true, QS will translate from outside the screen. It will be clipped with parallax
     * otherwise.
     */
    private boolean mTranslateWhileExpanding;
    private boolean mInSplitShade;
    private boolean mPulseExpanding;

    /**
@@ -135,6 +136,12 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca

    private DumpManager mDumpManager;

    /**
     * Progress of pull down from the center of the lock screen.
     * @see com.android.systemui.statusbar.LockscreenShadeTransitionController
     */
    private float mFullShadeProgress;

    @Inject
    public QSFragment(RemoteInputQuickSettingsDisabler remoteInputQsDisabler,
            InjectionInflationController injectionInflater, QSTileHost qsTileHost,
@@ -226,7 +233,8 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
                (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
                    boolean sizeChanged = (oldTop - oldBottom) != (top - bottom);
                    if (sizeChanged) {
                        setQsExpansion(mLastQSExpansion, mLastHeaderTranslation);
                        setQsExpansion(mLastQSExpansion, mLastPanelFraction,
                                mLastHeaderTranslation);
                    }
                });
        mQSPanelController.setUsingHorizontalLayoutChangeListener(
@@ -410,7 +418,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
                mQSAnimator.setShowCollapsedOnKeyguard(showCollapsed);
            }
            if (!showCollapsed && isKeyguardState()) {
                setQsExpansion(mLastQSExpansion, 0);
                setQsExpansion(mLastQSExpansion, mLastPanelFraction, 0);
            }
        }
    }
@@ -478,33 +486,30 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
    }

    @Override
    public void setTranslateWhileExpanding(boolean shouldTranslate) {
        mTranslateWhileExpanding = shouldTranslate;
        mQSAnimator.setTranslateWhileExpanding(shouldTranslate);
    public void setInSplitShade(boolean inSplitShade) {
        mInSplitShade = inSplitShade;
        mQSAnimator.setTranslateWhileExpanding(inSplitShade);
    }

    @Override
    public void setTransitionToFullShadeAmount(float pxAmount, boolean animated) {
    public void setTransitionToFullShadeAmount(float pxAmount, float progress) {
        boolean isTransitioningToFullShade = pxAmount > 0;
        if (isTransitioningToFullShade != mTransitioningToFullShade) {
            mTransitioningToFullShade = isTransitioningToFullShade;
            updateShowCollapsedOnKeyguard();
            setQsExpansion(mLastQSExpansion, mLastHeaderTranslation);
        }
        mFullShadeProgress = progress;
        setQsExpansion(mLastQSExpansion, mLastPanelFraction, mLastHeaderTranslation);
    }

    @Override
    public void setQsExpansion(float expansion, float proposedTranslation) {
        if (DEBUG) Log.d(TAG, "setQSExpansion " + expansion + " " + proposedTranslation);
    public void setQsExpansion(float expansion, float panelExpansionFraction,
            float proposedTranslation) {
        float headerTranslation = mTransitioningToFullShade ? 0 : proposedTranslation;
        if (mQSAnimator != null) {
            final boolean showQSOnLockscreen = expansion > 0;
            final boolean showQSUnlocked = headerTranslation == 0 || !mTranslateWhileExpanding;
            mQSAnimator.startAlphaAnimation(showQSOnLockscreen || showQSUnlocked
                    || mTransitioningToFullShade);
        }
        float progress = mTransitioningToFullShade ? mFullShadeProgress : panelExpansionFraction;
        setAlphaAnimationProgress(mInSplitShade ? progress : 1);
        mContainer.setExpansion(expansion);
        final float translationScaleY = (mTranslateWhileExpanding
        final float translationScaleY = (mInSplitShade
                ? 1 : QSAnimator.SHORT_PARALLAX_AMOUNT) * (expansion - 1);
        boolean onKeyguardAndExpanded = isKeyguardState() && !mShowCollapsedOnKeyguard;
        if (!mHeaderAnimating && !headerWillBeAnimating()) {
@@ -521,6 +526,7 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
            return;
        }
        mLastHeaderTranslation = headerTranslation;
        mLastPanelFraction = panelExpansionFraction;
        mLastQSExpansion = expansion;
        mLastKeyguardAndExpanded = onKeyguardAndExpanded;
        mLastViewHeight = currentHeight;
@@ -562,6 +568,17 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca
        updateMediaPositions();
    }

    private void setAlphaAnimationProgress(float progress) {
        final View view = getView();
        if (progress == 0 && view.getVisibility() != View.INVISIBLE) {
            view.setVisibility(View.INVISIBLE);
        } else if (progress > 0 && view.getVisibility() != View.VISIBLE) {
            view.setVisibility((View.VISIBLE));
        }
        float alpha = Interpolators.getNotificationScrimAlpha(progress, true /* uiContent */);
        view.setAlpha(alpha);
    }

    private void updateQsBounds() {
        if (mLastQSExpansion == 1.0f) {
            // Fully expanded, let's set the layout bounds as clip bounds. This is necessary because
+2 −3
Original line number Diff line number Diff line
@@ -298,9 +298,8 @@ class LockscreenShadeTransitionController @Inject constructor(
                    nsslController.setTransitionToFullShadeAmount(field)
                    notificationPanelController.setTransitionToFullShadeAmount(field,
                            false /* animate */, 0 /* delay */)
                    // TODO: appear qs also in split shade
                    val qsAmount = if (useSplitShade) 0f else field
                    qS.setTransitionToFullShadeAmount(qsAmount, false /* animate */)
                    val progress = MathUtils.saturate(dragDownAmount / scrimTransitionDistance)
                    qS.setTransitionToFullShadeAmount(field, progress)
                    // TODO: appear media also in split shade
                    val mediaAmount = if (useSplitShade) 0f else field
                    mediaHierarchyManager.setTransitionToFullShadeAmount(mediaAmount)
Loading