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

Commit db167370 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fully removed the bottom stack

Moved the ambient notifications into the shelf
instead of having them behave with their own
physics. Previously the ambient notifications
were stuck in the old world behind the shelf,
but this doesn't make sense anymore.

This also fixed a bug where the notifications were
wrongly positioned on the lockscreen since the shelf
counted as a view that wasn't gone.

Test: add low-priority notifications, observe scrolling
Bug: 32437839
Change-Id: I3921ea9f80a06f1b6330315423b012174269ac8e
parent 2e5a3fac
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -273,16 +273,10 @@
    <!-- Default distance from each snap target that GlowPadView considers a "hit" -->
    <dimen name="glowpadview_inner_radius">15dip</dimen>

    <!-- Space reserved for the cards behind the top card in the bottom stack -->
    <dimen name="bottom_stack_peek_amount">12dp</dimen>

    <!-- bottom_stack_peek_amount + notification_min_height
         + notification_collapse_second_card_padding -->
    <dimen name="min_stack_height">104dp</dimen>

    <!-- The height of the area before the bottom stack in which the notifications slow down -->
    <dimen name="bottom_stack_slow_down_length">12dp</dimen>

    <!-- Z distance between notifications if they are in the stack -->
    <dimen name="z_distance_between_notifications">0.5dp</dimen>

+19 −9
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import com.android.systemui.R;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.statusbar.notification.FakeShadowView;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.stack.ExpandableViewState;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator;

@@ -132,7 +131,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    private final int mLegacyColor;
    private final int mNormalColor;
    private final int mLowPriorityColor;
    private boolean mIsBelowShelf;
    private boolean mIsBelowSpeedBump;
    private FalsingManager mFalsingManager;
    private boolean mTrackTouch;

@@ -444,14 +443,25 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
    }

    @Override
    public void setBelowShelf(boolean below) {
        super.setBelowShelf(below);
        if (below != mIsBelowShelf) {
            mIsBelowShelf = below;
    public void setBelowSpeedBump(boolean below) {
        super.setBelowSpeedBump(below);
        if (below != mIsBelowSpeedBump) {
            mIsBelowSpeedBump = below;
            updateBackgroundTint();
            onBelowSpeedBumpChanged();
        }
    }

    protected void onBelowSpeedBumpChanged() {
    }

    /**
     * @return whether we are below the speed bump
     */
    public boolean isBelowSpeedBump() {
        return mIsBelowSpeedBump;
    }

    /**
     * Sets the tint color of the background
     */
@@ -857,7 +867,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
            return mBgTint;
        } else if (mShowingLegacyBackground) {
            return mLegacyColor;
        } else if (mIsBelowShelf) {
        } else if (mIsBelowSpeedBump) {
            return mLowPriorityColor;
        } else {
            return mNormalColor;
@@ -869,7 +879,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
            return mTintedRippleColor;
        } else if (mShowingLegacyBackground) {
            return mTintedRippleColor;
        } else if (mIsBelowShelf) {
        } else if (mIsBelowSpeedBump) {
            return mLowPriorityRippleColor;
        } else {
            return mNormalRippleColor;
@@ -915,7 +925,7 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView
        setTintColor(0);
        resetBackgroundAlpha();
        setShowingLegacyBackground(false);
        setBelowShelf(false);
        setBelowSpeedBump(false);
    }

    public boolean hasSameBgColor(ActivatableNotificationView otherView) {
+11 −6
Original line number Diff line number Diff line
@@ -413,6 +413,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        if (mNotificationParent != null) {
            mNotificationParent.updateBackgroundForGroupState();
        }
        updateIconVisibilities();
    }

    @Override
@@ -847,6 +848,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        }
    }

    @Override
    protected void onBelowSpeedBumpChanged() {
        updateIconVisibilities();
    }

    private void updateContentFadeOut() {
        if (!isChildInGroup()) {
            float contentAlpha = 1.0f - mIconTransformationAmount;
@@ -866,12 +872,11 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    }

    private void updateIconVisibilities() {
        if (!isChildInGroup()) {
            mPublicLayout.setIconsVisible(mIconsVisible);
            mPrivateLayout.setIconsVisible(mIconsVisible);
        boolean visible = isChildInGroup() || isBelowSpeedBump() || mIconsVisible;
        mPublicLayout.setIconsVisible(visible);
        mPrivateLayout.setIconsVisible(visible);
        if (mChildrenContainer != null) {
                mChildrenContainer.setIconsVisible(mIconsVisible);
            }
            mChildrenContainer.setIconsVisible(visible);
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -283,10 +283,10 @@ public abstract class ExpandableView extends FrameLayout {
    public abstract void performAddAnimation(long delay, long duration);

    /**
     * Set the notification appearance to be below the shelf.
     * Set the notification appearance to be below the speed bump.
     * @param below true if it is below.
     */
    public void setBelowShelf(boolean below) {
    public void setBelowSpeedBump(boolean below) {
    }

    public int getPinnedHeadsUpHeight() {
+50 −49
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import com.android.systemui.statusbar.stack.AmbientState;
import com.android.systemui.statusbar.stack.AnimationProperties;
import com.android.systemui.statusbar.stack.ExpandableViewState;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackScrollAlgorithm;
import com.android.systemui.statusbar.stack.StackScrollState;

import java.util.ArrayList;
@@ -131,13 +130,11 @@ public class NotificationShelf extends ActivatableNotificationView {
    }

    public void updateState(StackScrollState resultState,
            StackScrollAlgorithm.StackScrollAlgorithmState algorithmState,
            AmbientState ambientState) {
        int shelfIndex = ambientState.getShelfIndex() - 1;
        if (shelfIndex != -1) {
        View lastView = ambientState.getLastVisibleBackgroundChild();
        if (lastView != null) {
            float maxShelfEnd = ambientState.getInnerHeight() + ambientState.getTopPadding()
                    + ambientState.getStackTranslation();
            ExpandableView lastView = algorithmState.visibleChildren.get(shelfIndex);
            ExpandableViewState lastViewState = resultState.getViewStateForView(lastView);
            float viewEnd = lastViewState.yTranslation + lastViewState.height;
            mShelfState.copyFrom(lastViewState);
@@ -151,7 +148,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            mShelfState.openedAmount = openedAmount;
            mShelfState.clipTopAmount = 0;
            mShelfState.alpha = 1.0f;
            mShelfState.belowShelf = false;
            mShelfState.belowSpeedBump = false;
            mShelfState.shadowAlpha = 1.0f;
            mShelfState.isBottomClipped = false;
            mShelfState.hideSensitive = false;
@@ -174,8 +171,8 @@ public class NotificationShelf extends ActivatableNotificationView {
    public void updateAppearance() {
        WeakHashMap<View, NotificationIconContainer.IconState> iconStates =
                mShelfIcons.resetViewStates();
        float numIconsInShelf = 0.0f;
        int shelfIndex = mAmbientState.getShelfIndex();
        float numViewsInShelf = 0.0f;
        View lastChild = mAmbientState.getLastVisibleBackgroundChild();
        mNotGoneIndex = -1;
        float interpolationStart = mMaxLayoutHeight - getIntrinsicHeight() * 2;
        float expandAmount = 0.0f;
@@ -185,8 +182,12 @@ public class NotificationShelf extends ActivatableNotificationView {
        }
        //  find the first view that doesn't overlap with the shelf
        int notificationIndex = 0;
        int notGoneNotifications = 0;
        while (notGoneNotifications < shelfIndex) {
        int notGoneIndex = 0;
        boolean backgroundForceHidden = false;
        if (mHideBackground && !mShelfState.hasItemsInStableShelf) {
            backgroundForceHidden = true;
        }
        while (notificationIndex < mHostLayout.getChildCount()) {
            ExpandableView child = (ExpandableView) mHostLayout.getChildAt(notificationIndex);
            notificationIndex++;
            if (!(child instanceof ExpandableNotificationRow)
@@ -199,7 +200,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            float notificationClipEnd;
            float shelfStart = getTranslationY();
            boolean aboveShelf = row.getTranslationZ() > mAmbientState.getBaseZHeight();
            if (notGoneNotifications == shelfIndex - 1 || aboveShelf) {
            if (child == lastChild || aboveShelf || backgroundForceHidden) {
                notificationClipEnd = shelfStart + getIntrinsicHeight();
            } else {
                notificationClipEnd = shelfStart - mPaddingBetweenElements;
@@ -212,34 +213,25 @@ public class NotificationShelf extends ActivatableNotificationView {
                }
            }
            updateNotificationClipHeight(row, notificationClipEnd);
            updateIconAppearance(row, iconState, icon, expandAmount);
            numIconsInShelf += iconState.iconAppearAmount;
            numViewsInShelf += updateIconAppearance(row, iconState, icon, expandAmount);
            if (row.getTranslationY() >= getTranslationY() && mNotGoneIndex == -1) {
                mNotGoneIndex = notGoneNotifications;
                mNotGoneIndex = notGoneIndex;
            }
            if (notGoneNotifications != 0 || !aboveShelf) {
            if (notGoneIndex != 0 || !aboveShelf) {
                row.setAboveShelf(false);
            }
            notGoneNotifications++;
        }
        while (notificationIndex < mHostLayout.getChildCount()) {
            // We need to reset the clipping in case a notification switches from high to low
            // priority.
            ExpandableView child = (ExpandableView) mHostLayout.getChildAt(notificationIndex);
            if (child.getClipBottomAmount() != 0) {
                child.setClipBottomAmount(0);
            }
            if (child instanceof ExpandableNotificationRow) {
                ExpandableNotificationRow row = (ExpandableNotificationRow) child;
                row.setIconTransformationAmount(0);
            }
            notificationIndex++;
            notGoneIndex++;
        }
        mShelfIcons.calculateIconTranslations();
        mShelfIcons.applyIconStates();
        setVisibility(numIconsInShelf == 0.0f || !mAmbientState.isShadeExpanded() ? INVISIBLE
                : VISIBLE);
        setHideBackground(numIconsInShelf < 1.0f);
        setVisibility(numViewsInShelf != 0.0f && mAmbientState.isShadeExpanded()
                ? VISIBLE
                : INVISIBLE);
        boolean hideBackground = numViewsInShelf < 1.0f;
        setHideBackground(hideBackground || backgroundForceHidden);
        if (mNotGoneIndex == -1) {
            mNotGoneIndex = notGoneIndex;
        }
    }

    private void updateNotificationClipHeight(ExpandableNotificationRow row,
@@ -254,13 +246,16 @@ public class NotificationShelf extends ActivatableNotificationView {
        }
    }

    private void updateIconAppearance(ExpandableNotificationRow row,
    private float updateIconAppearance(ExpandableNotificationRow row,
            NotificationIconContainer.IconState iconState, StatusBarIconView icon,
            float expandAmount) {
        // Let calculate how much the view is in the shelf
        float viewStart = row.getTranslationY();
        int transformHeight = row.getActualHeight() + mPaddingBetweenElements;
        float viewEnd = viewStart + transformHeight;
        float iconAppearAmount;
        float yTranslation;
        float alpha = 1.0f;
        if (viewEnd >= getTranslationY() && (mAmbientState.isShadeExpanded()
                || (!row.isPinned() && !row.isHeadsUpAnimatingAway()))) {
            if (viewStart < getTranslationY()) {
@@ -269,12 +264,12 @@ public class NotificationShelf extends ActivatableNotificationView {
                        linearAmount);
                interpolatedAmount = NotificationUtils.interpolate(
                        interpolatedAmount, linearAmount, expandAmount);
                iconState.iconAppearAmount = 1.0f - interpolatedAmount;
                iconAppearAmount = 1.0f - interpolatedAmount;
            } else {
                iconState.iconAppearAmount = 1.0f;
                iconAppearAmount = 1.0f;
            }
        } else {
            iconState.iconAppearAmount = 0.0f;
            iconAppearAmount = 0.0f;
        }

        // Lets now calculate how much of the transformation has already happened. This is different
@@ -300,12 +295,12 @@ public class NotificationShelf extends ActivatableNotificationView {
                || (!mAmbientState.isShadeExpanded()
                        && (row.isPinned() || row.isHeadsUpAnimatingAway()))) {
            // We simply place it on the icon of the notification
            iconState.yTranslation = notificationIconPosition - shelfIconPosition;
            yTranslation = notificationIconPosition - shelfIconPosition;
        } else {
            transitionAmount = (viewStart - transformationStartPosition)
                    / transitionDistance;
            float startPosition = transformationStartPosition + iconTopPadding;
            iconState.yTranslation = NotificationUtils.interpolate(
            yTranslation = NotificationUtils.interpolate(
                    startPosition - shelfIconPosition, 0, transitionAmount);
            // If we are merging into the shelf, lets make sure the shelf is at least on our height,
            // otherwise the icons won't be visible.
@@ -314,16 +309,20 @@ public class NotificationShelf extends ActivatableNotificationView {
        float shelfIconSize = icon.getHeight() * icon.getIconScale();
        if (!row.isShowingIcon()) {
            // The view currently doesn't have an icon, lets transform it in!
            iconState.alpha = transitionAmount;
            alpha = transitionAmount;
            notificationIconSize = shelfIconSize / 2.0f;
        }
        // The notification size is different from the size in the shelf / statusbar
        float newSize = NotificationUtils.interpolate(notificationIconSize, shelfIconSize,
                transitionAmount);
        row.setIconTransformationAmount(transitionAmount);
        if (iconState != null) {
            iconState.scaleX = newSize / icon.getHeight() / icon.getIconScale();
            iconState.scaleY = iconState.scaleX;
            iconState.hidden = transitionAmount == 0.0f;
        row.setIconTransformationAmount(transitionAmount);
            iconState.iconAppearAmount = iconAppearAmount;
            iconState.alpha = alpha;
            iconState.yTranslation = yTranslation;
            icon.setVisibility(transitionAmount == 0.0f ? INVISIBLE : VISIBLE);
            if (row.isInShelf() && !row.isTransformingIntoShelf()) {
                iconState.iconAppearAmount = 1.0f;
@@ -333,6 +332,8 @@ public class NotificationShelf extends ActivatableNotificationView {
                iconState.hidden = false;
            }
        }
        return iconAppearAmount;
    }

    private float getFullyClosedTranslation() {
        return - (getIntrinsicHeight() - mStatusBarHeight) / 2;
Loading