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

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

Modified heads up experience

When dragging down, the shelf is now hidden behind the notification
until it was fully revealed once.

Test: Add heads-up, drag down on it.
Bug: 32437839
Change-Id: I85133855428777a606a3039e26acf53e6e63a3bb
parent 25b5291e
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -192,6 +192,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
    private boolean mRefocusOnDismiss;
    private float mIconTransformationAmount;
    private boolean mIconsVisible = true;
    private boolean mAboveShelf;

    public boolean isGroupExpansionChanging() {
        if (isChildInGroup()) {
@@ -342,6 +343,9 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        if (intrinsicBefore != getIntrinsicHeight()) {
            notifyHeightChanged(false  /* needsAnimation */);
        }
        if (isHeadsUp) {
            setAboveShelf(true);
        }
    }

    public void setGroupManager(NotificationGroupManager groupManager) {
@@ -529,12 +533,17 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        return mIsPinned;
    }

    @Override
    public int getPinnedHeadsUpHeight() {
        return getPinnedHeadsUpHeight(true /* atLeastMinHeight */);
    }

    /**
     * @param atLeastMinHeight should the value returned be at least the minimum height.
     *                         Used to avoid cyclic calls
     * @return the height of the heads up notification when pinned
     */
    public int getPinnedHeadsUpHeight(boolean atLeastMinHeight) {
    private int getPinnedHeadsUpHeight(boolean atLeastMinHeight) {
        if (mIsSummaryWithChildren) {
            return mChildrenContainer.getIntrinsicHeight();
        }
@@ -1778,6 +1787,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView {
        return new NotificationViewState(stackScrollState);
    }

    @Override
    public boolean isAboveShelf() {
        return mIsPinned || mHeadsupDisappearRunning || (mIsHeadsUp && mAboveShelf);
    }

    public void setAboveShelf(boolean aboveShelf) {
        mAboveShelf = aboveShelf;
    }

    public class NotificationViewState extends ExpandableViewState {

        private final StackScrollState mOverallState;
+9 −0
Original line number Diff line number Diff line
@@ -289,6 +289,11 @@ public abstract class ExpandableView extends FrameLayout {
    public void setBelowShelf(boolean below) {
    }

    public int getPinnedHeadsUpHeight() {
        return getIntrinsicHeight();
    }


    /**
     * Sets the translation of the view.
     */
@@ -500,6 +505,10 @@ public abstract class ExpandableView extends FrameLayout {
        return mTransformingInShelf;
    }

    public boolean isAboveShelf() {
        return false;
    }

    /**
     * A listener notifying when {@link #getActualHeight} changes.
     */
+23 −14
Original line number Diff line number Diff line
@@ -143,8 +143,7 @@ public class NotificationShelf extends ActivatableNotificationView {
            mShelfState.copyFrom(lastViewState);
            mShelfState.height = getIntrinsicHeight();
            mShelfState.yTranslation = Math.min(viewEnd, maxShelfEnd) - mShelfState.height;
            mShelfState.zTranslation = Math.max(mShelfState.zTranslation,
                    ambientState.getBaseZHeight());
            mShelfState.zTranslation = ambientState.getBaseZHeight();
            float openedAmount = (mShelfState.yTranslation - getFullyClosedTranslation())
                    / (getIntrinsicHeight() * 2);
            openedAmount = Math.min(1.0f, openedAmount);
@@ -192,7 +191,8 @@ public class NotificationShelf extends ActivatableNotificationView {
            IconState iconState = iconStates.get(icon);
            float notificationClipEnd;
            float shelfStart = getTranslationY();
            if (notGoneNotifications == shelfIndex - 1) {
            boolean aboveShelf = row.getTranslationZ() > mAmbientState.getBaseZHeight();
            if (notGoneNotifications == shelfIndex - 1 || aboveShelf) {
                notificationClipEnd = shelfStart + getIntrinsicHeight();
            } else {
                notificationClipEnd = shelfStart - mPaddingBetweenElements;
@@ -205,11 +205,14 @@ public class NotificationShelf extends ActivatableNotificationView {
                }
            }
            updateNotificationClipHeight(row, notificationClipEnd);
            updateIconAppearance(shelfStart, row, iconState, icon);
            updateIconAppearance(row, iconState, icon);
            numIconsInShelf += iconState.iconAppearAmount;
            if (row.getTranslationY() >= getTranslationY() && mNotGoneIndex == -1) {
                mNotGoneIndex = notGoneNotifications;
            }
            if (notGoneNotifications != 0 || !aboveShelf) {
                row.setAboveShelf(false);
            }
            notGoneNotifications++;
        }
        while (notificationIndex < mHostLayout.getChildCount()) {
@@ -227,31 +230,33 @@ public class NotificationShelf extends ActivatableNotificationView {
        }
        mNotificationIconContainer.calculateIconTranslations();
        mNotificationIconContainer.applyIconStates();
        setVisibility(numIconsInShelf == 0.0f ? INVISIBLE : VISIBLE);
        setVisibility(numIconsInShelf == 0.0f || !mAmbientState.isShadeExpanded() ? INVISIBLE
                : VISIBLE);
        setHideBackground(numIconsInShelf < 1.0f);
    }

    private void updateNotificationClipHeight(ExpandableNotificationRow row,
            float notificationClipEnd) {
        float viewEnd = row.getTranslationY() + row.getActualHeight();
        if (viewEnd > notificationClipEnd && !row.isPinned() && !row.isHeadsUpAnimatingAway()) {
            // TODO: handle heads up clipping correctly when closing.
        if (viewEnd > notificationClipEnd
                && (mAmbientState.isShadeExpanded()
                        || (!row.isPinned() && !row.isHeadsUpAnimatingAway()))) {
            row.setClipBottomAmount((int) (viewEnd - notificationClipEnd));
        } else {
            row.setClipBottomAmount(0);
        }
    }

    private void updateIconAppearance(float shelfTransformationStart, ExpandableNotificationRow row,
    private void updateIconAppearance(ExpandableNotificationRow row,
            IconState iconState, StatusBarIconView icon) {
        // Let calculate how much the view is in the shelf
        float viewStart = row.getTranslationY();
        int transformHeight = row.getActualHeight() + mPaddingBetweenElements;
        float viewEnd = viewStart + transformHeight;
        if (viewEnd >= shelfTransformationStart && !row.isPinned()
                && !row.isHeadsUpAnimatingAway()) {
            if (viewStart < shelfTransformationStart) {
                float linearAmount = (shelfTransformationStart - viewStart) / transformHeight;
        if (viewEnd >= getTranslationY() && (mAmbientState.isShadeExpanded()
                || (!row.isPinned() && !row.isHeadsUpAnimatingAway()))) {
            if (viewStart < getTranslationY()) {
                float linearAmount = (getTranslationY() - viewStart) / transformHeight;
                float interpolatedAmount =  Interpolators.ACCELERATE_DECELERATE.getInterpolation(
                        linearAmount);
                float interpolationStart = mMaxLayoutHeight - getIntrinsicHeight() * 2;
@@ -289,8 +294,9 @@ public class NotificationShelf extends ActivatableNotificationView {
        float transitionDistance = getIntrinsicHeight() * 1.5f;
        float transformationStartPosition = getTranslationY() - transitionDistance;
        float transitionAmount = 0.0f;
        if (viewStart < transformationStartPosition || row.isPinned()
                || row.isHeadsUpAnimatingAway()) {
        if (viewStart < transformationStartPosition
                || (!mAmbientState.isShadeExpanded()
                        && (row.isPinned() || row.isHeadsUpAnimatingAway()))) {
            // We simply place it on the icon of the notification
            iconState.yTranslation = notificationIconPosition - shelfIconPosition;
        } else {
@@ -299,6 +305,9 @@ public class NotificationShelf extends ActivatableNotificationView {
            float startPosition = transformationStartPosition + iconTopPadding;
            iconState.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.
            setTranslationZ(Math.max(getTranslationZ(), row.getTranslationZ()));
        }
        float shelfIconSize = icon.getHeight() * icon.getIconScale();
        if (!row.isShowingIcon()) {
+2 −1
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
    private boolean mWaitingOnCollapseWhenGoingAway;
    private boolean mIsObserving;
    private boolean mRemoteInputActive;
    private float mExpandedHeight;

    public HeadsUpManager(final Context context, View statusBarWindowView,
                          NotificationGroupManager groupManager) {
@@ -513,7 +514,7 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
                row = groupSummary;
            }
        }
        return row.getPinnedHeadsUpHeight(true /* atLeastMinHeight */);
        return row.getPinnedHeadsUpHeight();
    }

    /**
+8 −4
Original line number Diff line number Diff line
@@ -760,6 +760,13 @@ public class NotificationStackScrollLayout extends ViewGroup
     *         Measured in absolute height.
     */
    private float getAppearStartPosition() {
        if (mTrackingHeadsUp && mFirstVisibleBackgroundChild != null) {
            if (mFirstVisibleBackgroundChild.isAboveShelf()) {
                // If we ever expanded beyond the first notification, it's allowed to merge into
                // the shelf
                return mFirstVisibleBackgroundChild.getPinnedHeadsUpHeight();
            }
        }
        return getMinExpansionHeight();
    }

@@ -4002,10 +4009,7 @@ public class NotificationStackScrollLayout extends ViewGroup
    }

    public int getMinExpansionHeight() {
        return mTrackingHeadsUp
                ? mHeadsUpManager.getTopHeadsUpPinnedHeight()
                : mShelf.getIntrinsicHeight()
                        - (mShelf.getIntrinsicHeight() - mStatusBarHeight) / 2;
        return mShelf.getIntrinsicHeight() - (mShelf.getIntrinsicHeight() - mStatusBarHeight) / 2;
    }

    public void setInHeadsUpPinnedMode(boolean inHeadsUpPinnedMode) {
Loading