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

Commit 4dbe8762 authored by András Kurucz's avatar András Kurucz Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Move headsUpInset from the NSSL to the composables" into main

parents aaa37958 ce71134b
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imeAnimationTarget
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.overscroll
@@ -180,10 +181,12 @@ fun ContentScope.SnoozeableHeadsUpNotificationSpace(
    stackScrollView: NotificationScrollView,
    viewModel: NotificationsPlaceholderViewModel,
) {

    val isHeadsUp by viewModel.isHeadsUpOrAnimatingAway.collectAsStateWithLifecycle(false)

    var scrollOffset by remember { mutableFloatStateOf(0f) }
    val minScrollOffset = -(stackScrollView.getHeadsUpInset().toFloat())
    val headsUpInset = with(LocalDensity.current) { headsUpTopInset().toPx() }
    val minScrollOffset = -headsUpInset
    val maxScrollOffset = 0f

    val scrollableState = rememberScrollableState { delta ->
@@ -241,6 +244,12 @@ fun ContentScope.SnoozeableHeadsUpNotificationSpace(
    )
}

/** Y position of the HUNs at rest, when the shade is closed. */
@Composable
fun headsUpTopInset(): Dp =
    WindowInsets.safeDrawing.asPaddingValues().calculateTopPadding() +
        dimensionResource(R.dimen.heads_up_status_bar_padding)

/** Adds the space where notification stack should appear in the scene. */
@Composable
fun ContentScope.ConstrainedNotificationStack(
+5 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalDensity
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
@@ -34,6 +35,7 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.rememberViewModel
import com.android.systemui.notifications.ui.composable.SnoozeableHeadsUpNotificationSpace
import com.android.systemui.notifications.ui.composable.headsUpTopInset
import com.android.systemui.qs.ui.composable.QuickSettings
import com.android.systemui.qs.ui.composable.QuickSettings.SharedValues.MediaLandscapeTopOffset
import com.android.systemui.qs.ui.composable.QuickSettings.SharedValues.MediaOffset.Default
@@ -78,6 +80,8 @@ constructor(
            }
        }

        val headsUpInset = with(LocalDensity.current) { headsUpTopInset().toPx() }

        LaunchedEffect(isIdleAndNotOccluded) {
            // Wait for being Idle on this Scene, otherwise LaunchedEffect would fire too soon,
            // and another transition could override the NSSL stack bounds.
@@ -86,7 +90,7 @@ constructor(
                // and not to confuse the StackScrollAlgorithm when it displays a HUN over GONE.
                notificationStackScrolLView.get().apply {
                    // use -headsUpInset to allow HUN translation outside bounds for snoozing
                    setStackTop(-getHeadsUpInset().toFloat())
                    setStackTop(-headsUpInset)
                    setStackCutoff(0f)
                }
            }
+0 −6
Original line number Diff line number Diff line
@@ -2662,12 +2662,6 @@ public class NotificationStackScrollLayout
        return getTopHeadsUpIntrinsicHeight();
    }

    @Override
    public int getHeadsUpInset() {
        if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0;
        return mHeadsUpInset;
    }

    @Override
    public int getStackBottomInset() {
        return mPaddingBetweenElements + mShelf.getIntrinsicHeight();
+0 −3
Original line number Diff line number Diff line
@@ -106,9 +106,6 @@ interface NotificationScrollView {
    /** Sets whether the view is displayed in pulsing mode. */
    fun setPulsing(pulsing: Boolean, animated: Boolean)

    /** Gets the inset for HUNs when they are not visible */
    fun getHeadsUpInset(): Int

    /**
     * Signals that any open Notification guts should be closed, as scene container is handling
     * touch events.