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

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

Merge "Replace use of NotificationContainerBounds with a Float." into main

parents ee0ab372 38374f32
Loading
Loading
Loading
Loading
+0 −5
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.combineTransform
import kotlinx.coroutines.flow.distinctUntilChanged
@@ -183,10 +182,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.
+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)
                    }