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

Commit 459aee3d authored by Selim Cinek's avatar Selim Cinek
Browse files

Made sure the disappear animation for pulsing works correctly

Previously it was clipped and the shelf was visible.
Also made sure that the wakeup animation from pulsing looks
good.

Test: atest SystemUITests
Bug: 125942236
Change-Id: If850be294d89a8dd11f68fd64ef82d5f077a11f5
parent 4fc661e7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ public class AmbientPulseManager extends AlertingNotificationManager {
         * @param entry the entry that changed
         * @param isPulsing true if the entry is now pulsing, false otherwise
         */
        void onAmbientStateChanged(NotificationEntry entry, boolean isPulsing);
        void onAmbientStateChanged(@NonNull NotificationEntry entry, boolean isPulsing);
    }

    private final class AmbientEntry extends AlertEntry {
+4 −5
Original line number Diff line number Diff line
@@ -232,8 +232,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
            openedAmount = Math.min(1.0f, openedAmount);
            viewState.openedAmount = openedAmount;
            viewState.clipTopAmount = 0;
            viewState.alpha = mAmbientState.hasPulsingNotifications()
                    && !mAmbientState.isPulseExpanding() ? 0 : 1;
            viewState.alpha = 1;
            viewState.belowSpeedBump = mAmbientState.getSpeedBumpIndex() == 0;
            viewState.hideSensitive = false;
            viewState.xTranslation = getTranslationX();
@@ -501,7 +500,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
        float viewEnd = row.getTranslationY() + row.getActualHeight();
        boolean isPinned = (row.isPinned() || row.isHeadsUpAnimatingAway())
                && !mAmbientState.isDozingAndNotPulsing(row);
        boolean shouldClipOwnTop = row.isAmbientPulsing()
        boolean shouldClipOwnTop = row.showingAmbientPulsing()
                || (mAmbientState.isPulseExpanding() && childIndex == 0);
        if (viewEnd > notificationClipEnd && !shouldClipOwnTop
                && (mAmbientState.isShadeExpanded() || !isPinned)) {
@@ -671,7 +670,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
                ? fullTransitionAmount
                : transitionAmount;
        iconState.clampedAppearAmount = clampedAmount;
        float contentTransformationAmount = !mAmbientState.isAboveShelf(row)
        float contentTransformationAmount = !row.isAboveShelf()
                    && (isLastChild || iconState.translateContent)
                ? iconTransitionAmount
                : 0.0f;
@@ -740,7 +739,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
                iconState.scaleY = 1.0f;
                iconState.hidden = false;
            }
            if (mAmbientState.isAboveShelf(row) || (!row.isInShelf() && (isLastChild && row.areGutsExposed()
            if (row.isAboveShelf() || (!row.isInShelf() && (isLastChild && row.areGutsExposed()
                    || row.getTranslationZ() > mAmbientState.getBaseZHeight()))) {
                iconState.hidden = true;
            }
+34 −10
Original line number Diff line number Diff line
@@ -55,7 +55,8 @@ class NotificationWakeUpCoordinator @Inject constructor(
    private var mDarkAnimator: ObjectAnimator? = null
    private var mVisibilityAmount = 0.0f
    private var mLinearVisibilityAmount = 0.0f
    private var mPulsing: Boolean = false
    private var mWakingUp = false
    private val mEntrySetToClearWhenFinished = mutableSetOf<NotificationEntry>()

    init {
        mAmbientPulseManager.addListener(this)
@@ -77,9 +78,11 @@ class NotificationWakeUpCoordinator @Inject constructor(
    }

    private fun updateNotificationVisibility(animate: Boolean, increaseSpeed: Boolean) {
        var visible = false
        if (mPulsing) {
            visible = mNotificationsVisibleForExpansion || mAmbientPulseManager.hasNotifications()
        var visible = mNotificationsVisibleForExpansion || mAmbientPulseManager.hasNotifications()
        if (!visible && mNotificationsVisible && mWakingUp && mDozeAmount != 0.0f) {
            // let's not make notifications invisible while waking up, otherwise the animation
            // is strange
            return;
        }
        setNotificationsVisible(visible, animate, increaseSpeed)
    }
@@ -104,6 +107,11 @@ class NotificationWakeUpCoordinator @Inject constructor(
        mDozeAmount = interpolatedAmount
        mStackScroller.setDozeAmount(mDozeAmount)
        updateDarkAmount()
        if (linearAmount == 0.0f) {
            setNotificationsVisible(visible = false, animate = false, increaseSpeed = false);
            setNotificationsVisibleForExpansion(visible = false, animate = false,
                    increaseSpeed = false)
        }
    }

    private fun startVisibilityAnimation(increaseSpeed: Boolean) {
@@ -129,9 +137,16 @@ class NotificationWakeUpCoordinator @Inject constructor(
        mLinearVisibilityAmount = visibilityAmount
        mVisibilityAmount = mVisibilityInterpolator.getInterpolation(
                visibilityAmount)
        handleAnimationFinished();
        updateDarkAmount()
    }

    private fun handleAnimationFinished() {
        if (mLinearDozeAmount == 0.0f || mLinearVisibilityAmount == 0.0f) {
            mEntrySetToClearWhenFinished.forEach { it.setAmbientGoingAway(false) }
        }
    }

    fun getWakeUpHeight() : Float {
        return mStackScroller.wakeUpHeight
    }
@@ -148,8 +163,7 @@ class NotificationWakeUpCoordinator @Inject constructor(

    fun setDozing(dozing: Boolean, animate: Boolean) {
        if (dozing) {
            mNotificationsVisible = false
            mNotificationsVisibleForExpansion = false
            setNotificationsVisible(visible = false, animate = false, increaseSpeed = false)
        }
        if (animate) {
            notifyAnimationStart(!dozing)
@@ -160,12 +174,22 @@ class NotificationWakeUpCoordinator @Inject constructor(
        return mStackScroller.setPulseHeight(height)
    }

    fun setPulsing(pulsing: Boolean) {
        mPulsing = pulsing;
        updateNotificationVisibility(animate = true, increaseSpeed = false)
    fun setWakingUp(wakingUp: Boolean) {
        mWakingUp = wakingUp
        if (wakingUp && mNotificationsVisible && !mNotificationsVisibleForExpansion) {
            // We're waking up while pulsing, let's make sure the animation looks nice
            mStackScroller.wakeUpFromPulse();
        }
    }

    override fun onAmbientStateChanged(entry: NotificationEntry?, isPulsing: Boolean) {
    override fun onAmbientStateChanged(entry: NotificationEntry, isPulsing: Boolean) {
        if (!isPulsing && mLinearDozeAmount != 0.0f) {
            entry.setAmbientGoingAway(true)
            mEntrySetToClearWhenFinished.add(entry)
        } else if (isPulsing && mEntrySetToClearWhenFinished.contains(entry)) {
            mEntrySetToClearWhenFinished.remove(entry)
            entry.setAmbientGoingAway(false)
        }
        updateNotificationVisibility(animate = true, increaseSpeed = false)
    }
}
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -112,8 +112,8 @@ public class NotificationData {
            } else if (isHeadsUp) {
                // Provide consistent ranking with headsUpManager
                return mHeadsUpManager.compare(a, b);
            } else if (a.getRow().isAmbientPulsing() != b.getRow().isAmbientPulsing()) {
                return a.getRow().isAmbientPulsing() ? -1 : 1;
            } else if (a.getRow().showingAmbientPulsing() != b.getRow().showingAmbientPulsing()) {
                return a.getRow().showingAmbientPulsing() ? -1 : 1;
            } else if (aMedia != bMedia) {
                // Upsort current media notification.
                return aMedia ? -1 : 1;
+6 −0
Original line number Diff line number Diff line
@@ -571,6 +571,12 @@ public final class NotificationEntry {
        if (row != null) row.setHeadsUp(shouldHeadsUp);
    }


    public void setAmbientGoingAway(boolean goingAway) {
        if (row != null) row.setAmbientGoingAway(goingAway);
    }


    public boolean mustStayOnScreen() {
        return row != null && row.mustStayOnScreen();
    }
Loading