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

Commit c99ead25 authored by Andreas Miko's avatar Andreas Miko
Browse files

Attach children to NodeSpec of BundleEntry

Test: manual test bundle (not bugfree yet)
Flag: com.android.systemui.notification_bundle_ui
Bug: b/389839492
Change-Id: I9c49c437fab39642b80f088c7045f5b69b042d43
parent 01166308
Loading
Loading
Loading
Loading
+63 −59
Original line number Diff line number Diff line
@@ -16,24 +16,24 @@

package com.android.systemui.statusbar.notification.collection.render

import com.android.app.tracing.traceSection
import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager
import com.android.systemui.statusbar.notification.collection.BundleEntry
import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry
import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection
import com.android.systemui.statusbar.notification.collection.provider.SectionHeaderVisibilityProvider
import com.android.systemui.util.Compile
import com.android.app.tracing.traceSection
import com.android.systemui.statusbar.notification.collection.BundleEntry
import com.android.systemui.statusbar.notification.collection.PipelineEntry

/**
 * Converts a notif list (the output of the ShadeListBuilder) into a NodeSpec, an abstract
 * representation of which views should be present in the shade. This spec will later be consumed
 * by the ViewDiffer, which will add and remove views until the shade matches the spec. Up until
 * this point, the pipeline has dealt with pure data representations of notifications (in the
 * form of NotificationEntries). In this step, NotificationEntries finally become associated with
 * the views that will represent them. In addition, we add in any non-notification views that also
 * need to present in the shade, notably the section headers.
 * representation of which views should be present in the shade. This spec will later be consumed by
 * the ViewDiffer, which will add and remove views until the shade matches the spec. Up until this
 * point, the pipeline has dealt with pure data representations of notifications (in the form of
 * NotificationEntries). In this step, NotificationEntries finally become associated with the views
 * that will represent them. In addition, we add in any non-notification views that also need to
 * present in the shade, notably the section headers.
 */
class NodeSpecBuilder(
    private val mediaContainerController: MediaContainerController,
@@ -41,14 +41,12 @@ class NodeSpecBuilder(
    private val sectionHeaderVisibilityProvider: SectionHeaderVisibilityProvider,
    private val viewBarn: NotifViewBarn,
    private val bundleBarn: BundleBarn,
    private val logger: NodeSpecBuilderLogger
    private val logger: NodeSpecBuilderLogger,
) {
    private var lastSections = setOf<NotifSection?>()

    fun buildNodeSpec(
        rootController: NodeController,
        notifList: List<PipelineEntry>
    ): NodeSpec = traceSection("NodeSpecBuilder.buildNodeSpec") {
    fun buildNodeSpec(rootController: NodeController, notifList: List<PipelineEntry>): NodeSpec =
        traceSection("NodeSpecBuilder.buildNodeSpec") {
            val root = NodeSpecImpl(null, rootController)

            // The media container should be added as the first child of the root node
@@ -72,7 +70,9 @@ class NodeSpecBuilder(

                // If this notif begins a new section, first add the section's header view
                if (section != currentSection) {
                if (section.headerController != currentSection?.headerController && showHeaders) {
                    if (
                        section.headerController != currentSection?.headerController && showHeaders
                    ) {
                        section.headerController?.let { headerController ->
                            root.children.add(NodeSpecImpl(root, headerController))
                            if (Compile.IS_DEBUG) {
@@ -102,12 +102,16 @@ class NodeSpecBuilder(
            return@traceSection root
        }

    private fun buildNotifNode(parent: NodeSpec, entry: PipelineEntry): NodeSpec = when (entry) {
    private fun buildNotifNode(parent: NodeSpec, entry: PipelineEntry): NodeSpec =
        when (entry) {
            is NotificationEntry -> NodeSpecImpl(parent, viewBarn.requireNodeController(entry))
            is GroupEntry ->
                NodeSpecImpl(parent, viewBarn.requireNodeController(checkNotNull(entry.summary)))
                    .apply { entry.children.forEach { children.add(buildNotifNode(this, it)) } }
        is BundleEntry -> NodeSpecImpl(parent, bundleBarn.requireNodeController(entry))
            is BundleEntry ->
                NodeSpecImpl(parent, bundleBarn.requireNodeController(entry)).apply {
                    entry.children.forEach { children.add(buildNotifNode(this, it)) }
                }
            else -> throw RuntimeException("Unexpected entry: $entry")
        }
}