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

Commit 38374f32 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Replace use of NotificationContainerBounds with a Float.

The way notification code handles bounds is currently hacky and unclear.  This is a tiny refactor to start reducing use of this type. It also reduces potential unnecessary recomputation of max notifications.

Bug: 296118689
Test: atest SystemUITests
Flag: ACONFIG com.android.systemui.migrate_clocks_to_blueprint TEAMFOOD
Change-Id: I4374b51eda1ce86bd57d0dcdc82f77b630230521
parent 5cd5846e
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
@@ -159,10 +158,6 @@ constructor(
    /** Last point that the root view was tapped */
    val lastRootViewTapPosition: Flow<Point?> = keyguardInteractor.lastRootViewTapPosition

    /** the shared notification container bounds *on the lockscreen* */
    val notificationBounds: StateFlow<NotificationContainerBounds> =
        keyguardInteractor.notificationContainerBounds

    /**
     * The keyguard root view can be clipped as the shade is pulled down, typically only for
     * non-split shade cases.
@@ -235,11 +230,7 @@ constructor(
        burnInJob?.cancel()

        burnInJob =
            scope.launch {
                aodBurnInViewModel.movement(params).collect {
                    burnInModel.value = it
                }
            }
            scope.launch { aodBurnInViewModel.movement(params).collect { burnInModel.value = it } }
    }

    val scale: Flow<BurnInScaleViewModel> =
+9 −3
Original line number Diff line number Diff line
@@ -506,6 +506,12 @@ constructor(
            )
            .dumpWhileCollecting("translationX")

    private val availableHeight: Flow<Float> =
        bounds
            .map { it.bottom - it.top }
            .distinctUntilChanged()
            .dumpWhileCollecting("availableHeight")

    /**
     * When on keyguard, there is limited space to display notifications so calculate how many could
     * be shown. Otherwise, there is no limit since the vertical space will be scrollable.
@@ -527,19 +533,19 @@ constructor(
                showLimitedNotifications,
                showUnlimitedNotifications,
                shadeInteractor.isUserInteracting,
                bounds,
                availableHeight,
                interactor.notificationStackChanged.onStart { emit(Unit) },
                interactor.useExtraShelfSpace,
            ) { flows ->
                val showLimitedNotifications = flows[0] as Boolean
                val showUnlimitedNotifications = flows[1] as Boolean
                val isUserInteracting = flows[2] as Boolean
                val bounds = flows[3] as NotificationContainerBounds
                val availableHeight = flows[3] as Float
                val useExtraShelfSpace = flows[5] as Boolean

                if (!isUserInteracting) {
                    if (showLimitedNotifications) {
                        emit(calculateSpace(bounds.bottom - bounds.top, useExtraShelfSpace))
                        emit(calculateSpace(availableHeight, useExtraShelfSpace))
                    } else if (showUnlimitedNotifications) {
                        emit(-1)
                    }