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

Commit 2cffcec9 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge "Fix notification and container view binding by Composable NotificationSection" into main

parents ee17dec5 f117427f
Loading
Loading
Loading
Loading
+32 −5
Original line number Diff line number Diff line
@@ -21,19 +21,27 @@ import android.view.ViewGroup
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.notifications.ui.composable.NotificationStack
import com.android.systemui.scene.shared.flag.SceneContainerFlags
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.notification.stack.NotificationStackSizeCalculator
import com.android.systemui.statusbar.notification.stack.shared.flexiNotifsEnabled
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import com.android.systemui.statusbar.notification.stack.ui.viewbinder.NotificationStackAppearanceViewBinder
import com.android.systemui.statusbar.notification.stack.ui.viewbinder.SharedNotificationContainerBinder
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationStackAppearanceViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.SharedNotificationContainerViewModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher

@SysUISingleton
class NotificationSection
@Inject
constructor(
@@ -42,15 +50,33 @@ constructor(
    controller: NotificationStackScrollLayoutController,
    sceneContainerFlags: SceneContainerFlags,
    sharedNotificationContainer: SharedNotificationContainer,
    sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    stackScrollLayout: NotificationStackScrollLayout,
    notificationStackAppearanceViewModel: NotificationStackAppearanceViewModel,
    ambientState: AmbientState,
    notificationStackSizeCalculator: NotificationStackSizeCalculator,
    @Main mainDispatcher: CoroutineDispatcher,
) {
    init {
        if (sceneContainerFlags.flexiNotifsEnabled()) {
        if (!KeyguardShadeMigrationNssl.isUnexpectedlyInLegacyMode()) {
            // This scene container section moves the NSSL to the SharedNotificationContainer. This
            //  also requires that SharedNotificationContainer gets moved to the SceneWindowRootView
            //  by the SceneWindowRootViewBinder.
            // Prior to Scene Container, but when the KeyguardShadeMigrationNssl flag is enabled,
            //  NSSL is moved into this container by the NotificationStackScrollLayoutSection.
            (stackScrollLayout.parent as? ViewGroup)?.removeView(stackScrollLayout)
            sharedNotificationContainer.addNotificationStackScrollLayout(stackScrollLayout)

            SharedNotificationContainerBinder.bind(
                sharedNotificationContainer,
                sharedNotificationContainerViewModel,
                sceneContainerFlags,
                controller,
                notificationStackSizeCalculator,
                mainDispatcher,
            )

            if (sceneContainerFlags.flexiNotifsEnabled()) {
                NotificationStackAppearanceViewBinder.bind(
                    context,
                    sharedNotificationContainer,
@@ -60,6 +86,7 @@ constructor(
                )
            }
        }
    }

    @Composable
    fun SceneScope.Notifications(modifier: Modifier = Modifier) {
+2 −1
Original line number Diff line number Diff line
@@ -87,7 +87,8 @@ constructor(
            return
        }
        // This moves the existing NSSL view to a different parent, as the controller is a
        // singleton and recreating it has other bad side effects
        // singleton and recreating it has other bad side effects.
        // In the SceneContainer, this is done by the NotificationSection composable.
        notificationPanelView.findViewById<View?>(R.id.notification_stack_scroller)?.let {
            (it.parent as ViewGroup).removeView(it)
            sharedNotificationContainer.addNotificationStackScrollLayout(it)
+4 −0
Original line number Diff line number Diff line
@@ -97,6 +97,10 @@ object SceneWindowRootViewBinder {
                    val legacyView = view.requireViewById<View>(R.id.legacy_window_root)
                    view.addView(createVisibilityToggleView(legacyView))

                    // This moves the SharedNotificationContainer to the WindowRootView just after
                    //  the SceneContainerView. This SharedNotificationContainer should contain NSSL
                    //  due to the NotificationStackScrollLayoutSection (legacy) or
                    //  NotificationSection (scene container) moving it there.
                    if (flags.flexiNotifsEnabled()) {
                        (sharedNotificationContainer.parent as? ViewGroup)?.removeView(
                            sharedNotificationContainer