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

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

Merge "Remove scroll-up effect from lockscreen swipe-up and unlock hint"

parents 33416cd8 b5fe1d02
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -76,7 +76,10 @@ public class AmbientState {
    private float mHideAmount;
    private boolean mAppearing;
    private float mPulseHeight = MAX_PULSE_HEIGHT;

    /** How we much we are sleeping. 1f fully dozing (AOD), 0f fully awake (for all other states) */
    private float mDozeAmount = 0.0f;

    private Runnable mOnPulseHeightChangedListener;
    private ExpandableNotificationRow mTrackedHeadsUpRow;
    private float mAppearFraction;
@@ -96,6 +99,9 @@ public class AmbientState {
    /** Height of the notifications panel without top padding when expansion completes. */
    private float mStackEndHeight;

    /** Whether we are swiping up. */
    private boolean mIsSwipingUp;

    /**
     * @return Height of the notifications panel without top padding when expansion completes.
     */
@@ -132,6 +138,20 @@ public class AmbientState {
        mExpansionFraction = expansionFraction;
    }

    /**
     * @param isSwipingUp Whether we are swiping up.
     */
    public void setSwipingUp(boolean isSwipingUp) {
        mIsSwipingUp = isSwipingUp;
    }

    /**
     * @return Whether we are swiping up.
     */
    public boolean isSwipingUp() {
        return mIsSwipingUp;
    }

    /**
     * @return Fraction of shade expansion.
     */
+42 −17
Original line number Diff line number Diff line
@@ -203,6 +203,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    private float mQsExpansionFraction;
    private final int mSplitShadeMinContentHeight;

    /** Whether we are flinging the shade open or closed. */
    private boolean mIsFlinging;

    /**
     * The algorithm which calculates the properties for our children
     */
@@ -1269,6 +1272,16 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        updateStackPosition(false /* listenerNeedsAnimation */);
    }

    /**
     * @return Whether we should skip stack height update for lockscreen swipe-up or unlock hint.
     */
    private boolean shouldSkipHeightUpdate() {
        // After the user swipes up on lockscreen and lets go,
        // {@link PanelViewController) flings the shade back down.
        return mAmbientState.isOnKeyguard() && (
                mAmbientState.isUnlockHintRunning() || mAmbientState.isSwipingUp() || mIsFlinging);
    }

    /**
     * Apply expansion fraction to the y position and height of the notifications panel.
     * @param listenerNeedsAnimation does the listener need to animate?
@@ -1283,7 +1296,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        if (mOnStackYChanged != null) {
            mOnStackYChanged.accept(listenerNeedsAnimation);
        }
        if (mQsExpansionFraction <= 0) {
        if (mQsExpansionFraction <= 0 && !shouldSkipHeightUpdate()) {
            final float endHeight = updateStackEndHeight(
                    getHeight(), getEmptyBottomMargin(), mTopPadding);
            updateStackHeight(endHeight, fraction);
@@ -1325,10 +1338,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
    @ShadeViewRefactor(RefactorComponent.COORDINATOR)
    public void setExpandedHeight(float height) {
        final float shadeBottom = getHeight() - getEmptyBottomMargin();
        final boolean skipHeightUpdate = shouldSkipHeightUpdate();
        if (!skipHeightUpdate) {
            final float expansionFraction = MathUtils.saturate(height / shadeBottom);
            mAmbientState.setExpansionFraction(expansionFraction);
        }
        updateStackPosition();

        if (!skipHeightUpdate) {
            mExpandedHeight = height;
            setIsExpanded(height > 0);
            int minExpansionHeight = getMinExpansionHeight();
@@ -1342,6 +1359,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            } else {
                setRequestedClipBounds(null);
            }
        }
        int stackHeight;
        float translationY;
        float appearEndPosition = getAppearEndPosition();
@@ -1368,7 +1386,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                    }
                }
            } else {
                stackHeight = (int) height;
                stackHeight = (int) (skipHeightUpdate ? mExpandedHeight : height);
            }
        } else {
            appearFraction = calculateAppearFraction(height);
@@ -1386,7 +1404,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
            }
        }
        mAmbientState.setAppearFraction(appearFraction);
        if (stackHeight != mCurrentStackHeight) {
        if (stackHeight != mCurrentStackHeight && !skipHeightUpdate) {
            mCurrentStackHeight = stackHeight;
            updateAlgorithmHeightAndPadding();
            requestChildrenUpdate();
@@ -5001,6 +5019,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        mAmbientState.setUnlockHintRunning(running);
    }

    /**
     * @param isFlinging Whether we are flinging the shade open or closed.
     */
    public void setIsFlinging(boolean isFlinging) {
        mIsFlinging = isFlinging;
    }

    @ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
    public void setHeadsUpGoingAwayAnimationsAllowed(boolean headsUpGoingAwayAnimationsAllowed) {
        mHeadsUpGoingAwayAnimationsAllowed = headsUpGoingAwayAnimationsAllowed;
+7 −0
Original line number Diff line number Diff line
@@ -1195,6 +1195,13 @@ public class NotificationStackScrollLayoutController {
        mView.setUnlockHintRunning(running);
    }

    /**
     * @param isFlinging Whether we are flinging the shade open or close.
     */
    public void setIsFlinging(boolean isFlinging) {
        mView.setIsFlinging(isFlinging);
    }

    public boolean isFooterViewNotGone() {
        return mView.isFooterViewNotGone();
    }
+7 −0
Original line number Diff line number Diff line
@@ -1885,9 +1885,16 @@ public class NotificationPanelViewController extends PanelViewController
        mHeadsUpTouchHelper.notifyFling(!expand);
        mKeyguardStateController.notifyPanelFlingStart(!expand /* flingingToDismiss */);
        setClosingWithAlphaFadeout(!expand && !isOnKeyguard() && getFadeoutAlpha() == 1.0f);
        mNotificationStackScrollLayoutController.setIsFlinging(true);
        super.flingToHeight(vel, expand, target, collapseSpeedUpFactor, expandBecauseOfFalsing);
    }

    @Override
    protected void onFlingEnd(boolean cancelled) {
        super.onFlingEnd(cancelled);
        mNotificationStackScrollLayoutController.setIsFlinging(false);
    }

    private boolean onQsIntercept(MotionEvent event) {
        int pointerIndex = event.findPointerIndex(mTrackingPointer);
        if (pointerIndex < 0) {
+6 −2
Original line number Diff line number Diff line
@@ -461,7 +461,7 @@ public abstract class PanelViewController {
            boolean expands = onEmptySpaceClick(mInitialTouchX);
            onTrackingStopped(expands);
        }

        mAmbientState.setSwipingUp(false);
        mVelocityTracker.clear();
    }

@@ -708,7 +708,7 @@ public abstract class PanelViewController {
        animator.start();
    }

    private void onFlingEnd(boolean cancelled) {
    void onFlingEnd(boolean cancelled) {
        mIsFlinging = false;
        // No overshoot when the animation ends
        setOverExpansionInternal(0, false /* isFromGesture */);
@@ -1393,6 +1393,10 @@ public abstract class PanelViewController {
                        mUpwardsWhenThresholdReached = isDirectionUpwards(x, y);
                    }
                    if ((!mGestureWaitForTouchSlop || mTracking) && !isTrackingBlocked()) {
                        // Count h==0 as part of swipe-up,
                        // otherwise {@link NotificationStackScrollLayout}
                        // wrongly enables stack height updates at the start of lockscreen swipe-up
                        mAmbientState.setSwipingUp(h <= 0);
                        setExpandedHeightInternal(newHeight);
                    }
                    break;