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

Commit 32b19f8d authored by Steve Elliott's avatar Steve Elliott Committed by Automerger Merge Worker
Browse files

Merge changes I5887c0b0,Iae05381b into udc-dev am: 7ee8af55

parents 3d1cc7b2 7ee8af55
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -3333,7 +3333,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump

        mGestureRecorder = recorder;
        mHideExpandedRunnable = hideExpandedRunnable;
        mNotificationStackScrollLayoutController.setShelfController(notificationShelfController);
        if (!mFeatureFlags.isEnabled(Flags.NOTIFICATION_SHELF_REFACTOR)) {
            mNotificationStackScrollLayoutController.setShelfController(
                    notificationShelfController);
        }
        mNotificationShelfController = notificationShelfController;
        mLockscreenShadeTransitionController.bindController(notificationShelfController);
        updateMaxDisplayedNotifications(true);
+102 −13
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ 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.NotificationRoundnessManager;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm;
import com.android.systemui.statusbar.notification.stack.ViewState;
@@ -99,6 +101,9 @@ public class NotificationShelf extends ActivatableNotificationView implements St
    private boolean mSensitiveRevealAnimEndabled;
    private boolean mShelfRefactorFlagEnabled;
    private boolean mCanModifyColorOfNotifications;
    private boolean mCanInteract;
    private NotificationStackScrollLayout mHostLayout;
    private NotificationRoundnessManager mRoundnessManager;

    public NotificationShelf(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -135,6 +140,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St

    public void bind(AmbientState ambientState,
                     NotificationStackScrollLayoutController hostLayoutController) {
        assertRefactorFlagDisabled();
        mAmbientState = ambientState;
        mHostLayoutController = hostLayoutController;
        hostLayoutController.setOnNotificationRemovedListener((child, isTransferInProgress) -> {
@@ -142,6 +148,14 @@ public class NotificationShelf extends ActivatableNotificationView implements St
        });
    }

    public void bind(AmbientState ambientState, NotificationStackScrollLayout hostLayout,
            NotificationRoundnessManager roundnessManager) {
        if (!checkRefactorFlagEnabled()) return;
        mAmbientState = ambientState;
        mHostLayout = hostLayout;
        mRoundnessManager = roundnessManager;
    }

    private void updateResources() {
        Resources res = getResources();
        mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
@@ -233,7 +247,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St
            } else {
                viewState.setAlpha(1f - ambientState.getHideAmount());
            }
            viewState.belowSpeedBump = mHostLayoutController.getSpeedBumpIndex() == 0;
            viewState.belowSpeedBump = getSpeedBumpIndex() == 0;
            viewState.hideSensitive = false;
            viewState.setXTranslation(getTranslationX());
            viewState.hasItemsInStableShelf = lastViewState.inShelf;
@@ -276,6 +290,14 @@ public class NotificationShelf extends ActivatableNotificationView implements St
        }
    }

    private int getSpeedBumpIndex() {
        if (mShelfRefactorFlagEnabled) {
            return mHostLayout.getSpeedBumpIndex();
        } else {
            return mHostLayoutController.getSpeedBumpIndex();
        }
    }

    /**
     * @param fractionToShade Fraction of lockscreen to shade transition
     * @param shortestWidth   Shortest width to use for lockscreen shelf
@@ -388,8 +410,8 @@ public class NotificationShelf extends ActivatableNotificationView implements St
        int baseZHeight = mAmbientState.getBaseZHeight();
        int clipTopAmount = 0;

        for (int i = 0; i < mHostLayoutController.getChildCount(); i++) {
            ExpandableView child = mHostLayoutController.getChildAt(i);
        for (int i = 0; i < getHostLayoutChildCount(); i++) {
            ExpandableView child = getHostLayoutChildAt(i);
            if (!child.needsClippingToShelf() || child.getVisibility() == GONE) {
                continue;
            }
@@ -474,11 +496,11 @@ public class NotificationShelf extends ActivatableNotificationView implements St

        // TODO(b/172289889) transition last icon in shelf to notification icon and vice versa.
        setVisibility(isHidden ? View.INVISIBLE : View.VISIBLE);
        mShelfIcons.setSpeedBumpIndex(mHostLayoutController.getSpeedBumpIndex());
        mShelfIcons.setSpeedBumpIndex(getSpeedBumpIndex());
        mShelfIcons.calculateIconXTranslations();
        mShelfIcons.applyIconStates();
        for (int i = 0; i < mHostLayoutController.getChildCount(); i++) {
            View child = mHostLayoutController.getChildAt(i);
        for (int i = 0; i < getHostLayoutChildCount(); i++) {
            View child = getHostLayoutChildAt(i);
            if (!(child instanceof ExpandableNotificationRow)
                    || child.getVisibility() == GONE) {
                continue;
@@ -493,6 +515,22 @@ public class NotificationShelf extends ActivatableNotificationView implements St
        }
    }

    private ExpandableView getHostLayoutChildAt(int index) {
        if (mShelfRefactorFlagEnabled) {
            return (ExpandableView) mHostLayout.getChildAt(index);
        } else {
            return mHostLayoutController.getChildAt(index);
        }
    }

    private int getHostLayoutChildCount() {
        if (mShelfRefactorFlagEnabled) {
            return mHostLayout.getChildCount();
        } else {
            return mHostLayoutController.getChildCount();
        }
    }

    private boolean canModifyColorOfNotifications() {
        if (mShelfRefactorFlagEnabled) {
            return mCanModifyColorOfNotifications && mAmbientState.isShadeExpanded();
@@ -515,7 +553,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St
                && anv == mAmbientState.getTrackedHeadsUpRow();

        final boolean shouldUpdateCornerRoundness = viewStart < shelfStart
                && !mHostLayoutController.isViewAffectedBySwipe(anv)
                && !isViewAffectedBySwipe(anv)
                && !isUnlockedHeadsUp
                && !isHunGoingToShade
                && !anv.isAboveShelf()
@@ -567,6 +605,14 @@ public class NotificationShelf extends ActivatableNotificationView implements St
        anv.requestBottomRoundness(bottomValue, sourceType, /* animate = */ false);
    }

    private boolean isViewAffectedBySwipe(ExpandableView expandableView) {
        if (!mShelfRefactorFlagEnabled) {
            return mHostLayoutController.isViewAffectedBySwipe(expandableView);
        } else {
            return mRoundnessManager.isViewAffectedBySwipe(expandableView);
        }
    }

    /**
     * Clips transient views to the top of the shelf - Transient views are only used for
     * disappearing views/animations and need to be clipped correctly by the shelf to ensure they
@@ -574,8 +620,8 @@ public class NotificationShelf extends ActivatableNotificationView implements St
     * swipes quickly.
     */
    private void clipTransientViews() {
        for (int i = 0; i < mHostLayoutController.getTransientViewCount(); i++) {
            View transientView = mHostLayoutController.getTransientView(i);
        for (int i = 0; i < getHostLayoutTransientViewCount(); i++) {
            View transientView = getHostLayoutTransientView(i);
            if (transientView instanceof ExpandableView) {
                ExpandableView transientExpandableView = (ExpandableView) transientView;
                updateNotificationClipHeight(transientExpandableView, getTranslationY(), -1);
@@ -583,6 +629,22 @@ public class NotificationShelf extends ActivatableNotificationView implements St
        }
    }

    private View getHostLayoutTransientView(int index) {
        if (mShelfRefactorFlagEnabled) {
            return mHostLayout.getTransientView(index);
        } else {
            return mHostLayoutController.getTransientView(index);
        }
    }

    private int getHostLayoutTransientViewCount() {
        if (mShelfRefactorFlagEnabled) {
            return mHostLayout.getTransientViewCount();
        } else {
            return mHostLayoutController.getTransientViewCount();
        }
    }

    private void updateIconClipAmount(ExpandableNotificationRow row) {
        float maxTop = row.getTranslationY();
        if (getClipTopAmount() != 0) {
@@ -922,18 +984,27 @@ public class NotificationShelf extends ActivatableNotificationView implements St

    @Override
    public void onStateChanged(int newState) {
        assertRefactorFlagDisabled();
        mStatusBarState = newState;
        updateInteractiveness();
    }

    private void updateInteractiveness() {
        mInteractive = mStatusBarState == StatusBarState.KEYGUARD && mHasItemsInStableShelf;
        mInteractive = canInteract() && mHasItemsInStableShelf;
        setClickable(mInteractive);
        setFocusable(mInteractive);
        setImportantForAccessibility(mInteractive ? View.IMPORTANT_FOR_ACCESSIBILITY_YES
                : View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
    }

    private boolean canInteract() {
        if (mShelfRefactorFlagEnabled) {
            return mCanInteract;
        } else {
            return mStatusBarState == StatusBarState.KEYGUARD;
        }
    }

    @Override
    protected boolean isInteractive() {
        return mInteractive;
@@ -972,8 +1043,7 @@ public class NotificationShelf extends ActivatableNotificationView implements St

    private void assertRefactorFlagDisabled() {
        if (mShelfRefactorFlagEnabled) {
            throw new IllegalStateException(
                    "Code path not supported when Flags.NOTIFICATION_SHELF_REFACTOR is enabled.");
            NotificationShelfController.throwIllegalFlagStateError(false);
        }
    }

@@ -995,8 +1065,22 @@ public class NotificationShelf extends ActivatableNotificationView implements St
        mCanModifyColorOfNotifications = canModifyColorOfNotifications;
    }

    public void setCanInteract(boolean canInteract) {
        if (!checkRefactorFlagEnabled()) return;
        mCanInteract = canInteract;
        updateInteractiveness();
    }

    public void setIndexOfFirstViewInShelf(ExpandableView firstViewInShelf) {
        mIndexOfFirstViewInShelf = mHostLayoutController.indexOfChild(firstViewInShelf);
        mIndexOfFirstViewInShelf = getIndexOfViewInHostLayout(firstViewInShelf);
    }

    private int getIndexOfViewInHostLayout(ExpandableView child) {
        if (mShelfRefactorFlagEnabled) {
            return mHostLayout.indexOfChild(child);
        } else {
            return mHostLayoutController.indexOfChild(child);
        }
    }

    /**
@@ -1011,6 +1095,11 @@ public class NotificationShelf extends ActivatableNotificationView implements St
        mShelfRefactorFlagEnabled = enabled;
    }

    public void requestRoundnessResetFor(ExpandableView child) {
        if (!checkRefactorFlagEnabled()) return;
        child.requestRoundnessReset(SHELF_SCROLL);
    }

    /**
     * This method resets the OnScroll roundness of a view to 0f
     * <p>
+28 −0
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package com.android.systemui.statusbar

import android.util.Log
import android.view.View
import android.view.View.OnClickListener
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView.OnActivatedListener
import com.android.systemui.statusbar.notification.row.ExpandableView
@@ -51,4 +54,29 @@ interface NotificationShelfController {

    /** @see View.setOnClickListener */
    fun setOnClickListener(listener: OnClickListener)

    companion object {
        @JvmStatic
        fun assertRefactorFlagDisabled(featureFlags: FeatureFlags) {
            if (featureFlags.isEnabled(Flags.NOTIFICATION_SHELF_REFACTOR)) {
                throwIllegalFlagStateError(expected = false)
            }
        }

        @JvmStatic
        fun checkRefactorFlagEnabled(featureFlags: FeatureFlags): Boolean =
            featureFlags.isEnabled(Flags.NOTIFICATION_SHELF_REFACTOR).also { enabled ->
                if (!enabled) {
                    Log.wtf("NotifShelf", getErrorMessage(expected = true))
                }
            }

        @JvmStatic
        fun throwIllegalFlagStateError(expected: Boolean): Nothing =
            error(getErrorMessage(expected))

        private fun getErrorMessage(expected: Boolean): String =
            "Code path not supported when Flags.NOTIFICATION_SHELF_REFACTOR is " +
                if (expected) "disabled" else "enabled"
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ constructor(
    private val keyguardRepository: KeyguardRepository,
    private val deviceEntryFaceAuthRepository: DeviceEntryFaceAuthRepository,
) {
    /** Is the shelf showing on the keyguard? */
    val isShowingOnKeyguard: Flow<Boolean>
        get() = keyguardRepository.isKeyguardShowing

    /** Is the system in a state where the shelf is just a static display of notification icons? */
    val isShelfStatic: Flow<Boolean>
        get() =
+13 −25
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.notification.shelf.ui.viewbinder

import android.view.View
import android.view.View.OnAttachStateChangeListener
import android.view.accessibility.AccessibilityManager
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
@@ -29,7 +28,6 @@ import com.android.systemui.plugins.FalsingManager
import com.android.systemui.statusbar.LegacyNotificationShelfControllerImpl
import com.android.systemui.statusbar.NotificationShelf
import com.android.systemui.statusbar.NotificationShelfController
import com.android.systemui.statusbar.SysuiStatusBarStateController
import com.android.systemui.statusbar.notification.row.ActivatableNotificationView
import com.android.systemui.statusbar.notification.row.ActivatableNotificationViewController
import com.android.systemui.statusbar.notification.row.ExpandableOutlineViewController
@@ -40,9 +38,11 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackScroll
import com.android.systemui.statusbar.phone.NotificationIconContainer
import com.android.systemui.statusbar.phone.NotificationTapHelper
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope
import com.android.systemui.util.kotlin.getValue
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import javax.inject.Inject

/**
 * Controller class for [NotificationShelf]. This implementation serves as a temporary wrapper
@@ -61,11 +61,13 @@ constructor(
    private val a11yManager: AccessibilityManager,
    private val falsingManager: FalsingManager,
    private val falsingCollector: FalsingCollector,
    private val statusBarStateController: SysuiStatusBarStateController,
    hostControllerLazy: Lazy<NotificationStackScrollLayoutController>,
) : NotificationShelfController {

    private val hostController: NotificationStackScrollLayoutController by hostControllerLazy

    override val view: NotificationShelf
        get() = shelf
        get() = unsupported

    init {
        shelf.apply {
@@ -87,22 +89,9 @@ constructor(
                falsingCollector,
            )
            .init()
        val onAttachStateListener =
            object : OnAttachStateChangeListener {
                override fun onViewAttachedToWindow(v: View) {
                    statusBarStateController.addCallback(
                        shelf,
                        SysuiStatusBarStateController.RANK_SHELF,
                    )
                }

                override fun onViewDetachedFromWindow(v: View) {
                    statusBarStateController.removeCallback(shelf)
                }
            }
        shelf.addOnAttachStateChangeListener(onAttachStateListener)
        if (shelf.isAttachedToWindow) {
            onAttachStateListener.onViewAttachedToWindow(shelf)
        hostController.setShelf(shelf)
        hostController.setOnNotificationRemovedListener { child, _ ->
            view.requestRoundnessResetFor(child)
        }
    }

@@ -121,16 +110,14 @@ constructor(
    override fun bind(
        ambientState: AmbientState,
        notificationStackScrollLayoutController: NotificationStackScrollLayoutController,
    ) {
        shelf.bind(ambientState, notificationStackScrollLayoutController)
    }
    ) = unsupported

    override fun setOnClickListener(listener: View.OnClickListener) {
        shelf.setOnClickListener(listener)
    }

    private val unsupported: Nothing
        get() = error("Code path not supported when Flags.NOTIFICATION_SHELF_REFACTOR is enabled")
        get() = NotificationShelfController.throwIllegalFlagStateError(expected = true)
}

/** Binds a [NotificationShelf] to its backend. */
@@ -141,6 +128,7 @@ object NotificationShelfViewBinder {
                viewModel.canModifyColorOfNotifications
                    .onEach(shelf::setCanModifyColorOfNotifications)
                    .launchIn(this)
                viewModel.isClickable.onEach(shelf::setCanInteract).launchIn(this)
            }
        }
    }
Loading