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

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

Merge "Fade in shelf icons (replaces y-translation/scale/color-inversion)" into sc-dev

parents a8456872 1b498c87
Loading
Loading
Loading
Loading
+15 −54
Original line number Diff line number Diff line
@@ -527,7 +527,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
        handleCustomTransformHeight(view, expandingAnimated, iconState);

        float fullTransitionAmount;
        float transitionAmount;
        float iconTransitionAmount;
        float contentTransformationAmount;
        float shelfStart = getTranslationY();
        boolean fullyInOrOut = true;
@@ -549,18 +549,19 @@ public class NotificationShelf extends ActivatableNotificationView implements
                fullTransitionAmount = 1.0f - interpolatedAmount;

                if (isLastChild) {
                    // If it's the last child we should use all of the notification to transform
                    // instead of just to the icon, since that can be quite low.
                    transitionAmount = (shelfStart - viewStart) / transformDistance;
                    // Reduce icon transform distance to completely fade in shelf icon
                    // by the time the notification icon fades out, and vice versa
                    iconTransitionAmount = (shelfStart - viewStart)
                            / (iconTransformStart - viewStart);
                } else {
                    transitionAmount = (shelfStart - iconTransformStart) / transformDistance;
                    iconTransitionAmount = (shelfStart - iconTransformStart) / transformDistance;
                }
                transitionAmount = MathUtils.constrain(transitionAmount, 0.0f, 1.0f);
                transitionAmount = 1.0f - transitionAmount;
                iconTransitionAmount = MathUtils.constrain(iconTransitionAmount, 0.0f, 1.0f);
                iconTransitionAmount = 1.0f - iconTransitionAmount;
                fullyInOrOut = false;
            } else {
                fullTransitionAmount = 1.0f;
                transitionAmount = 1.0f;
                iconTransitionAmount = 1.0f;
            }

            // Transforming the content
@@ -569,7 +570,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
            contentTransformationAmount = 1.0f - contentTransformationAmount;
        } else {
            fullTransitionAmount = 0.0f;
            transitionAmount = 0.0f;
            iconTransitionAmount = 0.0f;
            contentTransformationAmount = 0.0f;
        }
        if (iconState != null && fullyInOrOut && !expandingAnimated && iconState.isLastExpandIcon) {
@@ -585,7 +586,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
        view.setContentTransformationAmount(contentTransformationAmount, isLastChild);

        // Update the positioning of the icon
        updateIconPositioning(view, transitionAmount, fullTransitionAmount,
        updateIconPositioning(view, iconTransitionAmount, fullTransitionAmount,
                transformDistance, scrolling, scrollingFast, expandingAnimated, isLastChild);

        return fullTransitionAmount;
@@ -679,8 +680,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
                || iconState.useLinearTransitionAmount) {
            transitionAmount = iconTransitionAmount;
        } else {
            // We take the clamped position instead
            transitionAmount = clampedAmount;
            transitionAmount = iconTransitionAmount;
            iconState.needsCannedAnimation = iconState.clampedAppearAmount != clampedAmount
                    && !mNoAnimationsInThisFrame;
        }
@@ -689,8 +689,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
                ? fullTransitionAmount
                : transitionAmount;
        iconState.clampedAppearAmount = clampedAmount;
        setIconTransformationAmount(view, transitionAmount, iconTransformDistance,
                clampedAmount != transitionAmount, isLastChild);
        setIconTransformationAmount(view, transitionAmount, isLastChild);
    }

    private boolean isTargetClipped(ExpandableView view) {
@@ -708,7 +707,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
    }

    private void setIconTransformationAmount(ExpandableView view,
            float transitionAmount, float iconTransformDistance, boolean usingLinearInterpolation,
            float transitionAmount,
            boolean isLastChild) {
        if (!(view instanceof ExpandableNotificationRow)) {
            return;
@@ -720,42 +719,13 @@ public class NotificationShelf extends ActivatableNotificationView implements
        View rowIcon = row.getShelfTransformationTarget();

        // Let's resolve the relative positions of the icons
        float notificationIconSize = 0.0f;
        int iconTopPadding;
        int iconStartPadding;
        if (rowIcon != null) {
            iconTopPadding = row.getRelativeTopPadding(rowIcon);
            iconStartPadding = row.getRelativeStartPadding(rowIcon);
            notificationIconSize = rowIcon.getHeight();
        } else {
            iconTopPadding = mIconAppearTopPadding;
            iconStartPadding = 0;
        }

        float shelfIconSize = mAmbientState.isFullyHidden() ? mHiddenShelfIconSize : mIconSize;
        shelfIconSize = shelfIconSize * icon.getIconScale();

        // Get the icon correctly positioned in Y
        float notificationIconPositionY = row.getTranslationY() + row.getContentTranslation();
        float targetYPosition = 0;
        boolean stayingInShelf = row.isInShelf() && !row.isTransformingIntoShelf();
        if (usingLinearInterpolation && !stayingInShelf) {
            // If we interpolate from the notification position, this might lead to a slightly
            // odd interpolation, since the notification position changes as well.
            // Let's instead interpolate directly to the top left of the notification
            targetYPosition =  NotificationUtils.interpolate(
                    Math.min(notificationIconPositionY + mIconAppearTopPadding
                            - getTranslationY(), 0),
                    0,
                    transitionAmount);
        }
        notificationIconPositionY += iconTopPadding;
        float shelfIconPositionY = getTranslationY() + icon.getTop();
        shelfIconPositionY += (icon.getHeight() - shelfIconSize) / 2.0f;
        float iconYTranslation = NotificationUtils.interpolate(
                notificationIconPositionY - shelfIconPositionY,
                targetYPosition,
                transitionAmount);

        // Get the icon correctly positioned in X
        // Even in RTL it's the left, since we're inverting the location in post
@@ -767,28 +737,19 @@ public class NotificationShelf extends ActivatableNotificationView implements
                transitionAmount);

        // Let's handle the case that there's no Icon
        float alpha = 1.0f;
        boolean noIcon = !row.isShowingIcon();
        if (noIcon) {
            // The view currently doesn't have an icon, lets transform it in!
            alpha = transitionAmount;
            notificationIconSize = shelfIconSize / 2.0f;
            iconXTranslation = mShelfIcons.getActualPaddingStart();
        }
        // The notification size is different from the size in the shelf / statusbar
        float newSize = NotificationUtils.interpolate(notificationIconSize, shelfIconSize,
                transitionAmount);
        if (iconState != null) {
            iconState.scaleX = newSize / shelfIconSize;
            iconState.scaleY = iconState.scaleX;
            iconState.hidden = transitionAmount == 0.0f && !iconState.isAnimating(icon);
            boolean isAppearing = row.isDrawingAppearAnimation() && !row.isInShelf();
            if (isAppearing) {
                iconState.hidden = true;
                iconState.iconAppearAmount = 0.0f;
            }
            iconState.alpha = alpha;
            iconState.yTranslation = iconYTranslation;
            iconState.alpha = transitionAmount;
            iconState.xTranslation = iconXTranslation;
            if (stayingInShelf) {
                iconState.iconAppearAmount = 1.0f;
+0 −3
Original line number Diff line number Diff line
@@ -180,9 +180,6 @@ class ConversationNotificationManager @Inject constructor(
                                }
                        if (changed) {
                            notificationGroupManager.updateIsolation(entry)
                            // ensure that the conversation icon isn't hidden
                            // (ex: if it was showing in the shelf)
                            entry.row?.updateIconVisibilities()
                        }
                    }
                }
+0 −15
Original line number Diff line number Diff line
@@ -176,7 +176,6 @@ public final class NotificationEntry extends ListEntry {
    private int mBucket = BUCKET_ALERTING;
    @Nullable private Long mPendingAnimationDuration;
    private boolean mIsMarkedForUserTriggeredMovement;
    private boolean mShelfIconVisible;
    private boolean mIsAlerting;

    public boolean mRemoteEditImeVisible;
@@ -417,7 +416,6 @@ public final class NotificationEntry extends ListEntry {
    //TODO: This will go away when we have a way to bind an entry to a row
    public void setRow(ExpandableNotificationRow row) {
        this.row = row;
        updateShelfIconVisibility();
    }

    public ExpandableNotificationRowController getRowController() {
@@ -938,19 +936,6 @@ public final class NotificationEntry extends ListEntry {
        return mIsMarkedForUserTriggeredMovement;
    }

    /** Whether or not the icon for this notification is visible in the shelf. */
    public void setShelfIconVisible(boolean shelfIconVisible) {
        if (row == null) return;
        mShelfIconVisible = shelfIconVisible;
        updateShelfIconVisibility();
    }

    private void updateShelfIconVisibility() {
        if (row != null) {
            row.setShelfIconVisible(mShelfIconVisible);
        }
    }

    /**
     * Mark this entry for movement triggered by a user action (ex: changing the priorirty of a
     * conversation). This can then be used for custom animations.
+0 −5
Original line number Diff line number Diff line
@@ -95,11 +95,6 @@ class IconManager @Inject constructor(
        // Construct the shelf icon view.
        val shelfIcon = iconBuilder.createIconView(entry)
        shelfIcon.scaleType = ImageView.ScaleType.CENTER_INSIDE

        // TODO: This doesn't belong here
        shelfIcon.setOnVisibilityChangedListener { newVisibility: Int ->
            entry.setShelfIconVisible(newVisibility == View.VISIBLE)
        }
        shelfIcon.visibility = View.INVISIBLE

        // Construct the aod icon view.
+0 −30
Original line number Diff line number Diff line
@@ -331,7 +331,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private boolean mHeadsupDisappearRunning;
    private View mChildAfterViewWhenDismissed;
    private View mGroupParentWhenDismissed;
    private boolean mShelfIconVisible;
    private boolean mAboveShelf;
    private OnUserInteractionCallback mOnUserInteractionCallback;
    private NotificationGutsManager mNotificationGutsManager;
@@ -568,7 +567,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        // The public layouts expand button is always visible
        mPublicLayout.updateExpandButtons(true);
        updateLimits();
        updateIconVisibilities();
        updateShelfIconColor();
        updateRippleAllowed();
        if (mUpdateBackgroundOnUpdate) {
@@ -883,7 +881,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            setDistanceToTopRoundness(NO_ROUNDNESS);
            mNotificationParent.updateBackgroundForGroupState();
        }
        updateIconVisibilities();
        updateBackgroundClipping();
    }

@@ -1481,21 +1478,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        return getShelfTransformationTarget() != null;
    }

    /**
     * Set the icons to be visible of this notification.
     */
    public void setShelfIconVisible(boolean iconVisible) {
        if (iconVisible != mShelfIconVisible) {
            mShelfIconVisible = iconVisible;
            updateIconVisibilities();
        }
    }

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

    @Override
    protected void updateContentTransformation() {
        if (mExpandAnimationRunning) {
@@ -1522,18 +1504,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
    }

    /** Refreshes the visibility of notification icons */
    public void updateIconVisibilities() {
        // The shelf icon is never hidden for children in groups
        boolean visible = !isChildInGroup() && mShelfIconVisible;
        for (NotificationContentView l : mLayouts) {
            l.setShelfIconVisible(visible);
        }
        if (mChildrenContainer != null) {
            mChildrenContainer.setShelfIconVisible(visible);
        }
    }

    public void setIsLowPriority(boolean isLowPriority) {
        mIsLowPriority = isLowPriority;
        mPrivateLayout.setIsLowPriority(isLowPriority);
Loading