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

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

Merge changes from topic "fade-whole-notifications"

* changes:
  Clip view before shelf and leave the rest unclipped
  Fade in notifications one by one
parents 0b28f5f3 8f3ba5ab
Loading
Loading
Loading
Loading
+29 −2
Original line number Diff line number Diff line
@@ -204,6 +204,30 @@ public class NotificationShelf extends ActivatableNotificationView implements
        }
    }

    /**
     * @return whether to clip bottom of given view
     */
    private boolean shouldClipBottom(ExpandableView view) {
        final boolean showShelf = ((ShelfState) getViewState()).hasItemsInStableShelf;
        if (showShelf) {
            if (mAmbientState.isShadeOpening()) {
                final float viewEnd = view.getTranslationY()
                        + view.getActualHeight()
                        + mPaddingBetweenElements;
                final float finalShelfStart = mMaxLayoutHeight - getIntrinsicHeight();
                // While the shade is opening, only clip view if it overlaps with shelf;
                // otherwise leave view unclipped.
                if (viewEnd < finalShelfStart) {
                    return false;
                }
            }
            // Clip for scrolling.
            return true;
        }
        // Don't clip since we have enough space to show all views.
        return false;
    }

    /**
     * Update the shelf appearance based on the other notifications around it. This transforms
     * the icons from the notification area into the shelf.
@@ -345,7 +369,9 @@ public class NotificationShelf extends ActivatableNotificationView implements
        clipTransientViews();

        setClipTopAmount(clipTopAmount);
        boolean isHidden = getViewState().hidden || clipTopAmount >= getIntrinsicHeight();
        boolean isHidden = getViewState().hidden
                || clipTopAmount >= getIntrinsicHeight()
                || mAmbientState.isShadeOpening();
        if (mShowNotificationShelf) {
            setVisibility(isHidden ? View.INVISIBLE : View.VISIBLE);
        }
@@ -468,7 +494,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
        } else {
            shouldClipOwnTop = view.showingPulsing();
        }
        if (viewEnd > notificationClipEnd && !shouldClipOwnTop
        if (shouldClipBottom(view)
                && viewEnd > notificationClipEnd && !shouldClipOwnTop
                && (mAmbientState.isShadeExpanded() || !isPinned)) {
            int clipBottomAmount = (int) (viewEnd - notificationClipEnd);
            if (isPinned) {
+6 −0
Original line number Diff line number Diff line
@@ -614,6 +614,12 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable {
        }
    }

    public void setShouldFadeForShadeOpen(boolean shouldFade) {
        if (!mViewState.gone) {
            mViewState.setShouldFadeForShadeOpen(shouldFade);
        }
    }

    /**
     * @return whether the current view doesn't add height to the overall content. This means that
     * if it is added to a list of items, its content will still have the same height.
+10 −0
Original line number Diff line number Diff line
@@ -88,6 +88,12 @@ public class ExpandableViewState extends ViewState {
    public boolean hideSensitive;
    public boolean belowSpeedBump;
    public boolean inShelf;
    public boolean shouldFadeForShadeOpen;

    @Override
    boolean shouldAnimateAlpha() {
        return shouldFadeForShadeOpen;
    }

    /**
     * A state indicating whether a headsup is currently fully visible, even when not scrolled.
@@ -171,6 +177,10 @@ public class ExpandableViewState extends ViewState {
        }
    }

    public void setShouldFadeForShadeOpen(boolean shouldFade) {
        shouldFadeForShadeOpen = shouldFade;
    }

    @Override
    public void animateTo(View child, AnimationProperties properties) {
        super.animateTo(child, properties);
+1 −0
Original line number Diff line number Diff line
@@ -3947,6 +3947,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        int numChildren = getChildCount();
        for (int i = 0; i < numChildren; i++) {
            ExpandableView child = (ExpandableView) getChildAt(i);
            child.setShouldFadeForShadeOpen(mAmbientState.isShadeOpening());
            child.applyViewState();
        }

+8 −5
Original line number Diff line number Diff line
@@ -568,11 +568,14 @@ public class StackScrollAlgorithm {
            // Add padding before sections for overscroll effect.
            childViewState.yTranslation += ambientState.getSectionPadding();
        }
        if (childViewState.yTranslation >= shelfStart) {
            childViewState.hidden = !child.isExpandAnimationRunning() && !child.hasExpandingChild();
            childViewState.inShelf = true;
            childViewState.headsUpIsVisible = false;
        }
        boolean show = childViewState.yTranslation < shelfStart
                && !ambientState.isAppearing();
        childViewState.hidden = !show
                && !child.isExpandAnimationRunning()
                && !child.hasExpandingChild();
        childViewState.inShelf = !show;
        childViewState.headsUpIsVisible = show;
        childViewState.alpha = show ? 1f : 0f;
    }

    protected int getMaxAllowedChildHeight(View child) {
Loading