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

Commit 34518f66 authored by Selim Cinek's avatar Selim Cinek
Browse files

Follow up addressing comments of pulsing refactor

Because of various rebases, this is much easier.

Test: atest SystemUITests
Fixes: 125942236
Change-Id: I169a0ee1843b8a34d29289cc70eaf650bade6997
parent 3af11b2a
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ import kotlin.math.max
class PulseExpansionHandler @Inject
constructor(context: Context,
            private val mWakeUpCoordinator: NotificationWakeUpCoordinator) : Gefingerpoken {
    companion object {
        private val RUBBERBAND_FACTOR_STATIC = 0.25f
        private val SPRING_BACK_ANIMATION_LENGTH_MS = 375
    }
    private val mPowerManager: PowerManager?
    private var mShadeController: ShadeController? = null

@@ -265,10 +269,4 @@ constructor(context: Context,
    interface ExpansionCallback {
        fun setEmptyDragAmount(amount: Float)
    }

    companion object {
        private val RUBBERBAND_FACTOR_STATIC = 0.25f

        private val SPRING_BACK_ANIMATION_LENGTH_MS = 375
    }
}
+24 −13
Original line number Diff line number Diff line
@@ -18,9 +18,10 @@ package com.android.systemui.statusbar.notification

import android.animation.ObjectAnimator
import android.util.FloatProperty
import android.view.animation.Interpolator
import com.android.systemui.Interpolators
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.AmbientPulseManager
import com.android.systemui.statusbar.SysuiStatusBarStateController
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
@@ -30,8 +31,9 @@ import javax.inject.Singleton

@Singleton
class NotificationWakeUpCoordinator @Inject constructor(
        private val mAmbientPulseManager: AmbientPulseManager)
    : AmbientPulseManager.OnAmbientChangedListener {
        private val mAmbientPulseManager: AmbientPulseManager,
        private val mStatusBarStateController: StatusBarStateController)
    : AmbientPulseManager.OnAmbientChangedListener, StatusBarStateController.StateListener {

    private val mNotificationVisibility
            = object : FloatProperty<NotificationWakeUpCoordinator>("notificationVisibility") {
@@ -60,6 +62,7 @@ class NotificationWakeUpCoordinator @Inject constructor(

    init {
        mAmbientPulseManager.addListener(this)
        mStatusBarStateController.addCallback(this)
    }

    fun setStackScroller(stackScroller: NotificationStackScrollLayout) {
@@ -75,6 +78,12 @@ class NotificationWakeUpCoordinator @Inject constructor(
                                                    increaseSpeed: Boolean) {
        mNotificationsVisibleForExpansion = visible
        updateNotificationVisibility(animate, increaseSpeed)
        if (!visible && mNotificationsVisible) {
            // If we stopped expanding and we're still visible because we had a pulse that hasn't
            // times out, let's release them all to make sure were not stuck in a state where
            // notifications are visible
            mAmbientPulseManager.releaseAllImmediately()
        }
    }

    private fun updateNotificationVisibility(animate: Boolean, increaseSpeed: Boolean) {
@@ -102,12 +111,17 @@ class NotificationWakeUpCoordinator @Inject constructor(
        }
    }

    fun setDozeAmount(linearAmount: Float, interpolatedAmount: Float) {
        mLinearDozeAmount = linearAmount
        mDozeAmount = interpolatedAmount
    override fun onDozeAmountChanged(linear: Float, eased: Float) {
        if (linear != 1.0f && linear != 0.0f
                && (mLinearDozeAmount == 0.0f || mLinearDozeAmount == 1.0f)) {
            // Let's notify the scroller that an animation started
            notifyAnimationStart(mLinearDozeAmount == 1.0f)
        }
        mLinearDozeAmount = linear
        mDozeAmount = eased
        mStackScroller.setDozeAmount(mDozeAmount)
        updateDarkAmount()
        if (linearAmount == 0.0f) {
        if (linear == 0.0f) {
            setNotificationsVisible(visible = false, animate = false, increaseSpeed = false);
            setNotificationsVisibleForExpansion(visible = false, animate = false,
                    increaseSpeed = false)
@@ -148,7 +162,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
    }

    fun getWakeUpHeight() : Float {
        return mStackScroller.wakeUpHeight
        return mStackScroller.pulseHeight
    }

    private fun updateDarkAmount() {
@@ -161,13 +175,10 @@ class NotificationWakeUpCoordinator @Inject constructor(
        mStackScroller.notifyDarkAnimationStart(!awake)
    }

    fun setDozing(dozing: Boolean, animate: Boolean) {
        if (dozing) {
    override fun onDozingChanged(isDozing: Boolean) {
        if (isDozing) {
            setNotificationsVisible(visible = false, animate = false, increaseSpeed = false)
        }
        if (animate) {
            notifyAnimationStart(!dozing)
        }
    }

    fun setPulseHeight(height: Float): Float {
+6 −3
Original line number Diff line number Diff line
@@ -583,12 +583,15 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        }
    }

    public float getWakeUpHeight() {
    /**
     * @return the height at which we will wake up when pulsing
     */
    public float getPulseHeight() {
        ActivatableNotificationView firstChild = getFirstChildWithBackground();
        if (firstChild != null) {
            return firstChild.getCollapsedHeight();
        }
        return 0;
        return 0f;
    }

    @Override
@@ -5651,7 +5654,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
    }

    public void wakeUpFromPulse() {
        setPulseHeight(getWakeUpHeight());
        setPulseHeight(getPulseHeight());
        // Let's place the hidden views at the end of the pulsing notification to make sure we have
        // a smooth animation
        boolean firstVisibleView = true;
+0 −2
Original line number Diff line number Diff line
@@ -2836,7 +2836,6 @@ public class NotificationPanelView extends PanelView implements

        final float darkAmount = dozing ? 1 : 0;
        mStatusBarStateController.setDozeAmount(darkAmount, animate);
        mWakeUpCoordinator.setDozing(mDozing, animate);
    }

    @Override
@@ -2847,7 +2846,6 @@ public class NotificationPanelView extends PanelView implements
        mKeyguardStatusView.setDarkAmount(mInterpolatedDarkAmount);
        mKeyguardBottomArea.setDarkAmount(mInterpolatedDarkAmount);
        positionClockAndNotifications();
        mWakeUpCoordinator.setDozeAmount(mLinearDarkAmount, mInterpolatedDarkAmount);
    }

    public void setPulsing(boolean pulsing) {
+3 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.AmbientPulseManager;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
@@ -141,7 +142,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
        // holds a copy of the CUT's instances of these classes, so they still refer to the CUT's
        // member variables, not the spy's member variables.
        mStackScrollerInternal = new NotificationStackScrollLayout(getContext(), null,
                true /* allowLongPress */, mNotificationRoundnessManager);
                true /* allowLongPress */, mNotificationRoundnessManager,
                new AmbientPulseManager(mContext));
        mStackScroller = spy(mStackScrollerInternal);
        mStackScroller.setShelf(notificationShelf);
        mStackScroller.setStatusBar(mBar);
Loading