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

Commit 44df1fda authored by Dave Mankoff's avatar Dave Mankoff Committed by Steve Elliott
Browse files

Create a controller for NSSL

This is the first step towards removing view injection from
NotificationStackScrollLayout.

For right now, this doesn't seem to do too much. This CL passes the
controller into most places the view used to go, and that in turn
simply proxies requests through to the view.

A follow up CL will work to actually remove injection from
NotificationStackScrollLayout.

Bug: 149989572
Test: atest SytemUITests && manual
Change-Id: Ic161c36f090479fb1ccbfdd735a2a9ab5616f290
parent f152f9d2
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableView;
import com.android.systemui.statusbar.notification.stack.AmbientState;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.notification.stack.ViewState;
import com.android.systemui.statusbar.phone.NotificationIconContainer;

@@ -69,7 +69,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
    private float mHiddenShelfIconSize;
    private int mStatusBarHeight;
    private AmbientState mAmbientState;
    private NotificationStackScrollLayout mHostLayout;
    private NotificationStackScrollLayoutController mHostLayoutController;
    private int mMaxLayoutHeight;
    private int mPaddingBetweenElements;
    private int mNotGoneIndex;
@@ -114,9 +114,10 @@ public class NotificationShelf extends ActivatableNotificationView implements
        initDimens();
    }

    public void bind(AmbientState ambientState, NotificationStackScrollLayout hostLayout) {
    public void bind(AmbientState ambientState,
            NotificationStackScrollLayoutController hostLayoutController) {
        mAmbientState = ambientState;
        mHostLayout = hostLayout;
        mHostLayoutController = hostLayoutController;
    }

    private void initDimens() {
@@ -248,8 +249,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
        float firstElementRoundness = 0.0f;
        ActivatableNotificationView previousAnv = null;

        for (int i = 0; i < mHostLayout.getChildCount(); i++) {
            ExpandableView child = (ExpandableView) mHostLayout.getChildAt(i);
        for (int i = 0; i < mHostLayoutController.getChildCount(); i++) {
            ExpandableView child = (ExpandableView) mHostLayoutController.getChildAt(i);

            if (!child.needsClippingToShelf() || child.getVisibility() == GONE) {
                continue;
@@ -354,8 +355,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
        mShelfIcons.setSpeedBumpIndex(mAmbientState.getSpeedBumpIndex());
        mShelfIcons.calculateIconTranslations();
        mShelfIcons.applyIconStates();
        for (int i = 0; i < mHostLayout.getChildCount(); i++) {
            View child = mHostLayout.getChildAt(i);
        for (int i = 0; i < mHostLayoutController.getChildCount(); i++) {
            View child = mHostLayoutController.getChildAt(i);
            if (!(child instanceof ExpandableNotificationRow)
                    || child.getVisibility() == GONE) {
                continue;
@@ -378,8 +379,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
     * swipes quickly.
     */
    private void clipTransientViews() {
        for (int i = 0; i < mHostLayout.getTransientViewCount(); i++) {
            View transientView = mHostLayout.getTransientView(i);
        for (int i = 0; i < mHostLayoutController.getTransientViewCount(); i++) {
            View transientView = mHostLayoutController.getTransientView(i);
            if (transientView instanceof ExpandableView) {
                ExpandableView transientExpandableView = (ExpandableView) transientView;
                updateNotificationClipHeight(transientExpandableView, getTranslationY(), -1);
@@ -618,7 +619,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
            // We need to persist this, since after the expansion, the behavior should still be the
            // same.
            float position = mAmbientState.getIntrinsicPadding()
                    + mHostLayout.getPositionInLinearLayout(view);
                    + mHostLayoutController.getPositionInLinearLayout(view);
            int maxShelfStart = mMaxLayoutHeight - getIntrinsicHeight();
            if (position < maxShelfStart && position + view.getIntrinsicHeight() >= maxShelfStart
                    && view.getTranslationY() < position) {
+3 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import android.view.View;
import com.android.systemui.statusbar.notification.row.ActivatableNotificationViewController;
import com.android.systemui.statusbar.notification.row.dagger.NotificationRowScope;
import com.android.systemui.statusbar.notification.stack.AmbientState;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.statusbar.phone.StatusBarNotificationPresenter;
@@ -90,8 +90,8 @@ public class NotificationShelfController {
    }

    public void bind(AmbientState ambientState,
            NotificationStackScrollLayout notificationStackScrollLayout) {
        mView.bind(ambientState, notificationStackScrollLayout);
            NotificationStackScrollLayoutController notificationStackScrollLayoutController) {
        mView.bind(ambientState, notificationStackScrollLayoutController);
        mAmbientState = ambientState;
    }

+6 −6
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.phone.HeadsUpManagerPhone
import com.android.systemui.statusbar.phone.KeyguardBypassController
import com.android.systemui.statusbar.phone.ShadeController
@@ -93,7 +93,7 @@ constructor(
        private set
    private val mTouchSlop: Float
    private lateinit var expansionCallback: ExpansionCallback
    private lateinit var stackScroller: NotificationStackScrollLayout
    private lateinit var stackScrollerController: NotificationStackScrollLayoutController
    private val mTemp2 = IntArray(2)
    private var mDraggedFarEnough: Boolean = false
    private var mStartingChild: ExpandableView? = null
@@ -315,23 +315,23 @@ constructor(
    private fun findView(x: Float, y: Float): ExpandableView? {
        var totalX = x
        var totalY = y
        stackScroller.getLocationOnScreen(mTemp2)
        stackScrollerController.getLocationOnScreen(mTemp2)
        totalX += mTemp2[0].toFloat()
        totalY += mTemp2[1].toFloat()
        val childAtRawPosition = stackScroller.getChildAtRawPosition(totalX, totalY)
        val childAtRawPosition = stackScrollerController.getChildAtRawPosition(totalX, totalY)
        return if (childAtRawPosition != null && childAtRawPosition.isContentExpandable) {
            childAtRawPosition
        } else null
    }

    fun setUp(
        stackScroller: NotificationStackScrollLayout,
        stackScrollerController: NotificationStackScrollLayoutController,
        expansionCallback: ExpansionCallback,
        shadeController: ShadeController
    ) {
        this.expansionCallback = expansionCallback
        this.shadeController = shadeController
        this.stackScroller = stackScroller
        this.stackScrollerController = stackScrollerController
    }

    fun setPulsing(pulsing: Boolean) {
+16 −15
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import com.android.systemui.Interpolators
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.KeyguardBypassController
@@ -33,6 +33,7 @@ import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener

import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.min

@Singleton
class NotificationWakeUpCoordinator @Inject constructor(
@@ -53,7 +54,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
            return coordinator.mLinearVisibilityAmount
        }
    }
    private lateinit var mStackScroller: NotificationStackScrollLayout
    private lateinit var mStackScrollerController: NotificationStackScrollLayoutController
    private var mVisibilityInterpolator = Interpolators.FAST_OUT_SLOW_IN_REVERSE

    private var mLinearDozeAmount: Float = 0.0f
@@ -79,7 +80,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
                if (mNotificationsVisible && !mNotificationsVisibleForExpansion &&
                    !bypassController.bypassEnabled) {
                    // We're waking up while pulsing, let's make sure the animation looks nice
                    mStackScroller.wakeUpFromPulse()
                    mStackScrollerController.wakeUpFromPulse()
                }
                if (bypassController.bypassEnabled && !mNotificationsVisible) {
                    // Let's make sure our huns become visible once we are waking up in case
@@ -156,10 +157,10 @@ class NotificationWakeUpCoordinator @Inject constructor(
        })
    }

    fun setStackScroller(stackScroller: NotificationStackScrollLayout) {
        mStackScroller = stackScroller
        pulseExpanding = stackScroller.isPulseExpanding
        stackScroller.setOnPulseHeightChangedListener {
    fun setStackScroller(stackScrollerController: NotificationStackScrollLayoutController) {
        mStackScrollerController = stackScrollerController
        pulseExpanding = stackScrollerController.isPulseExpanding
        stackScrollerController.setOnPulseHeightChangedListener {
            val nowExpanding = isPulseExpanding()
            val changed = nowExpanding != pulseExpanding
            pulseExpanding = nowExpanding
@@ -169,7 +170,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
        }
    }

    fun isPulseExpanding(): Boolean = mStackScroller.isPulseExpanding
    fun isPulseExpanding(): Boolean = mStackScrollerController.isPulseExpanding

    /**
     * @param visible should notifications be visible
@@ -249,7 +250,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
        val changed = linear != mLinearDozeAmount
        mLinearDozeAmount = linear
        mDozeAmount = eased
        mStackScroller.setDozeAmount(mDozeAmount)
        mStackScrollerController.setDozeAmount(mDozeAmount)
        updateHideAmount()
        if (changed && linear == 0.0f) {
            setNotificationsVisible(visible = false, animate = false, increaseSpeed = false)
@@ -330,18 +331,18 @@ class NotificationWakeUpCoordinator @Inject constructor(
    }

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

    private fun updateHideAmount() {
        val linearAmount = Math.min(1.0f - mLinearVisibilityAmount, mLinearDozeAmount)
        val amount = Math.min(1.0f - mVisibilityAmount, mDozeAmount)
        mStackScroller.setHideAmount(linearAmount, amount)
        val linearAmount = min(1.0f - mLinearVisibilityAmount, mLinearDozeAmount)
        val amount = min(1.0f - mVisibilityAmount, mDozeAmount)
        mStackScrollerController.setHideAmount(linearAmount, amount)
        notificationsFullyHidden = linearAmount == 1.0f
    }

    private fun notifyAnimationStart(awake: Boolean) {
        mStackScroller.notifyHideAnimationStart(!awake)
        mStackScrollerController.notifyHideAnimationStart(!awake)
    }

    override fun onDozingChanged(isDozing: Boolean) {
@@ -355,7 +356,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
     * from a pulse and determines how much the notifications are expanded.
     */
    fun setPulseHeight(height: Float): Float {
        val overflow = mStackScroller.setPulseHeight(height)
        val overflow = mStackScrollerController.setPulseHeight(height)
        //  no overflow for the bypass experience
        return if (bypassController.bypassEnabled) 0.0f else overflow
    }
+11 −1
Original line number Diff line number Diff line
@@ -539,6 +539,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
    private int mGapHeight;

    private int mWaterfallTopInset;
    private NotificationStackScrollLayoutController mController;

    private SysuiColorExtractor.OnColorsChangedListener mOnColorsChangedListener =
            (colorExtractor, which) -> {
@@ -5430,7 +5431,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        addView(mShelf, index);
        mAmbientState.setShelf(mShelf);
        mStateAnimator.setShelf(mShelf);
        notificationShelfController.bind(mAmbientState, this);
        notificationShelfController.bind(mAmbientState, mController);
        if (ANCHOR_SCROLLING) {
            mScrollAnchorView = mShelf;
        }
@@ -5904,6 +5905,15 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
        return MathUtils.smoothStep(0, totalDistance, dragDownAmount);
    }

    public void setController(
            NotificationStackScrollLayoutController notificationStackScrollLayoutController) {
        mController = notificationStackScrollLayoutController;
    }

    public NotificationStackScrollLayoutController getController() {
        return mController;
    }

    /**
     * A listener that is notified when the empty space below the notifications is clicked on
     */
Loading