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

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

Init and show bundle header and set ENR on entry

When ENR is not set on entry it causes NPEs downstream. Setting it here
right after the row is created and known seems appropriate.

We want to create the ViewModel from dagger such that we can easily
inject other objects.

Test: manual test bundle (not bugfree yet)
Flag: com.android.systemui.notification_bundle_ui
Bug: b/389839492
Change-Id: I4503d00f49b5a422d50edf5398f8aaede2b2d14a
parent 89f6d9c0
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -33,8 +33,7 @@ class BundleEntry(spec: BundleSpec) : PipelineEntry(spec.key) {
    // TODO(b/394483200): move NotificationEntry's implementation to PipelineEntry?
    // TODO(b/394483200): move NotificationEntry's implementation to PipelineEntry?
    val isSensitive: MutableStateFlow<Boolean> = MutableStateFlow(false)
    val isSensitive: MutableStateFlow<Boolean> = MutableStateFlow(false)


    // TODO (b/389839319): implement the row
    var row: ExpandableNotificationRow? = null
    val row: ExpandableNotificationRow? = null


    private val _children: MutableList<ListEntry> = ArrayList()
    private val _children: MutableList<ListEntry> = ArrayList()
    val children: List<ListEntry> = Collections.unmodifiableList(_children)
    val children: List<ListEntry> = Collections.unmodifiableList(_children)
+30 −25
Original line number Original line Diff line number Diff line
@@ -27,6 +27,8 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.RowInflaterTask
import com.android.systemui.statusbar.notification.row.RowInflaterTask
import com.android.systemui.statusbar.notification.row.RowInflaterTaskLogger
import com.android.systemui.statusbar.notification.row.RowInflaterTaskLogger
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent
import com.android.systemui.statusbar.notification.row.domain.interactor.BundleInteractor
import com.android.systemui.statusbar.notification.row.ui.viewmodel.BundleHeaderViewModel
import com.android.systemui.statusbar.notification.stack.NotificationListContainer
import com.android.systemui.statusbar.notification.stack.NotificationListContainer
import com.android.systemui.util.time.SystemClock
import com.android.systemui.util.time.SystemClock
import dagger.Lazy
import dagger.Lazy
@@ -35,11 +37,14 @@ import javax.inject.Provider


/**
/**
 * Class that handles inflating BundleEntry view and controller, for use by NodeSpecBuilder.
 * Class that handles inflating BundleEntry view and controller, for use by NodeSpecBuilder.
 * TODO(b/402628023) Make this class dumpable and dump its map so that we can see the
 *
 * "inflation pending" state per bundle
 * TODO(b/402628023) Make this class dumpable and dump its map so that we can see the "inflation
 *   pending" state per bundle
 */
 */
@SysUISingleton
@SysUISingleton
class BundleBarn @Inject constructor(
class BundleBarn
@Inject
constructor(
    private val rowComponent: ExpandableNotificationRowComponent.Builder,
    private val rowComponent: ExpandableNotificationRowComponent.Builder,
    private val rowInflaterTaskProvider: Provider<RowInflaterTask>,
    private val rowInflaterTaskProvider: Provider<RowInflaterTask>,
    private val listContainer: NotificationListContainer,
    private val listContainer: NotificationListContainer,
@@ -47,13 +52,11 @@ class BundleBarn @Inject constructor(
    val systemClock: SystemClock,
    val systemClock: SystemClock,
    val logger: RowInflaterTaskLogger,
    val logger: RowInflaterTaskLogger,
    val userTracker: UserTracker,
    val userTracker: UserTracker,
    private val presenterLazy: Lazy<NotificationPresenter?>? = null
    private val presenterLazy: Lazy<NotificationPresenter?>? = null,
) {
) {
    /**
    /**
     * Map of [BundleEntry] key to [NodeController]:
     * Map of [BundleEntry] key to [NodeController]: no key -> not started key maps to null ->
     * no key -> not started
     * inflating key maps to controller -> inflated
     * key maps to null -> inflating
     * key maps to controller -> inflated
     */
     */
    private val keyToControllerMap = mutableMapOf<String, NotifViewController?>()
    private val keyToControllerMap = mutableMapOf<String, NotifViewController?>()


@@ -61,9 +64,7 @@ class BundleBarn @Inject constructor(
        debugBundleLog(TAG, { s })
        debugBundleLog(TAG, { s })
    }
    }


    /**
    /** Build view and controller for BundleEntry. */
     * Build view and controller for BundleEntry.
     */
    fun inflateBundleEntry(bundleEntry: BundleEntry) {
    fun inflateBundleEntry(bundleEntry: BundleEntry) {
        debugLog("inflateBundleEntry: ${bundleEntry.key}")
        debugLog("inflateBundleEntry: ${bundleEntry.key}")
        if (keyToControllerMap.containsKey(bundleEntry.key)) {
        if (keyToControllerMap.containsKey(bundleEntry.key)) {
@@ -75,36 +76,40 @@ class BundleBarn @Inject constructor(
        val inflationFinishedListener: (ExpandableNotificationRow) -> Unit = { row ->
        val inflationFinishedListener: (ExpandableNotificationRow) -> Unit = { row ->
            // A subset of NotificationRowBinderImpl.inflateViews
            // A subset of NotificationRowBinderImpl.inflateViews
            debugLog("finished inflating: ${bundleEntry.key}")
            debugLog("finished inflating: ${bundleEntry.key}")
            val component = rowComponent
            bundleEntry.row = row
            val component =
                rowComponent
                    .expandableNotificationRow(row)
                    .expandableNotificationRow(row)
                    .pipelineEntry(bundleEntry)
                    .pipelineEntry(bundleEntry)
                    .onExpandClickListener(presenterLazy?.get())
                    .onExpandClickListener(presenterLazy?.get())
                    .build()
                    .build()
            val controller =
            val controller = component.expandableNotificationRowController
                component.expandableNotificationRowController
            controller.init(bundleEntry)
            controller.init(bundleEntry)
            keyToControllerMap[bundleEntry.key] = controller
            keyToControllerMap[bundleEntry.key] = controller

            // TODO(389839492): Construct BundleHeaderViewModel (or even ENRViewModel) by dagger
            row.initBundleHeader(
                BundleHeaderViewModel(BundleInteractor(bundleEntry.bundleRepository))
            )
        }
        }
        debugLog("calling inflate: ${bundleEntry.key}")
        debugLog("calling inflate: ${bundleEntry.key}")
        keyToControllerMap[bundleEntry.key] = null
        keyToControllerMap[bundleEntry.key] = null
        rowInflaterTaskProvider.get().inflate(
        rowInflaterTaskProvider
            context, parent, bundleEntry, inflationFinishedListener
            .get()
        )
            .inflate(context, parent, bundleEntry, inflationFinishedListener)
    }
    }


    /**
    /** Return true if finished inflating. */
     * Return true if finished inflating.
     */
    fun isInflated(bundleEntry: BundleEntry): Boolean {
    fun isInflated(bundleEntry: BundleEntry): Boolean {
        return keyToControllerMap[bundleEntry.key] != null
        return keyToControllerMap[bundleEntry.key] != null
    }
    }


    /**
    /** Return ExpandableNotificationRowController for BundleEntry. */
     * Return ExpandableNotificationRowController for BundleEntry.
     */
    fun requireNodeController(bundleEntry: BundleEntry): NodeController {
    fun requireNodeController(bundleEntry: BundleEntry): NodeController {
        debugLog("requireNodeController: ${bundleEntry.key}" +
        debugLog(
                "controller: ${keyToControllerMap[bundleEntry.key]}")
            "requireNodeController: ${bundleEntry.key}" +
                "controller: ${keyToControllerMap[bundleEntry.key]}"
        )
        return keyToControllerMap[bundleEntry.key]
        return keyToControllerMap[bundleEntry.key]
            ?: error("No view has been registered for bundle: ${bundleEntry.key}")
            ?: error("No view has been registered for bundle: ${bundleEntry.key}")
    }
    }
+9 −3
Original line number Original line Diff line number Diff line
@@ -285,6 +285,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    private NotificationGuts mGuts;
    private NotificationGuts mGuts;
    private NotificationEntry mEntry;
    private NotificationEntry mEntry;
    private EntryAdapter mEntryAdapter;
    private EntryAdapter mEntryAdapter;
    private boolean mIsBundle;
    private String mAppName;
    private String mAppName;
    private NotificationRebindingTracker mRebindingTracker;
    private NotificationRebindingTracker mRebindingTracker;
    private FalsingManager mFalsingManager;
    private FalsingManager mFalsingManager;
@@ -2255,6 +2256,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView


        if (NotificationBundleUi.isEnabled()) {
        if (NotificationBundleUi.isEnabled()) {
            mEntryAdapter = entryAdapter;
            mEntryAdapter = entryAdapter;
            mIsBundle = entryAdapter instanceof BundleEntryAdapter;
        } else {
        } else {
            mEntry = (NotificationEntry) entry;
            mEntry = (NotificationEntry) entry;
        }
        }
@@ -2879,10 +2881,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren
        mPrivateLayout.setVisibility(!mShowingPublic && !mIsSummaryWithChildren
                && !hideContentWhileLaunching ? VISIBLE : INVISIBLE);
                && !hideContentWhileLaunching ? VISIBLE : INVISIBLE);
        if (mChildrenContainer != null) {
        if (mChildrenContainer != null) {
            if (mIsBundle) {
                mChildrenContainer.setVisibility(!hideContentWhileLaunching ? VISIBLE : INVISIBLE);
            } else {
                mChildrenContainer.setVisibility(!mShowingPublic && mIsSummaryWithChildren
                mChildrenContainer.setVisibility(!mShowingPublic && mIsSummaryWithChildren
                        && !hideContentWhileLaunching ? VISIBLE
                        && !hideContentWhileLaunching ? VISIBLE
                        : INVISIBLE);
                        : INVISIBLE);
            }
            }
        }
        // The limits might have changed if the view suddenly became a group or vice versa
        // The limits might have changed if the view suddenly became a group or vice versa
        updateLimits();
        updateLimits();
    }
    }