summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author András Kurucz <kurucz@google.com> 2025-01-03 09:06:52 +0000
committer András Kurucz <kurucz@google.com> 2025-01-06 10:54:29 +0000
commitce71134b7cdcca52ed97a1d73f70ef319b5717da (patch)
tree44bb6a7f10c743c92a5d9c04e0e757d8faec7467
parenta5a6973f92e72bf1ccb5d0a13cd697dda8fb47df (diff)
[flexiglass] Move headsUpInset from the NSSL to the composables
NSSL used to determine the y position at which HUNs should be displayed. This is the status bar height, plus some padding. This is another example for determining the drawing bounds of the NSSL, which should come from the placeholders. Fixes: 387458294 Test: post HUNs over GONE -> check if HUNs are positioned correctly Flag: com.android.systemui.scene_container Change-Id: Icbe83d4cbfff7b92925a4045da3a999fb0993451
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt11
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/view/NotificationScrollView.kt3
4 files changed, 15 insertions, 11 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt
index 46e0efa79ef5..183929ca6c6a 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt
@@ -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(
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
index e4f4df386583..9ee25c3404ec 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt
@@ -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)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 9766f9e0ab1a..071d23283c43 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -2663,12 +2663,6 @@ public class NotificationStackScrollLayout
}
@Override
- public int getHeadsUpInset() {
- if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return 0;
- return mHeadsUpInset;
- }
-
- @Override
public int getStackBottomInset() {
return mPaddingBetweenElements + mShelf.getIntrinsicHeight();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/view/NotificationScrollView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/view/NotificationScrollView.kt
index 5249a6d304ec..d302fb67dddb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/view/NotificationScrollView.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/view/NotificationScrollView.kt
@@ -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.