Loading packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt +12 −9 Original line number Diff line number Diff line Loading @@ -23,11 +23,13 @@ import androidx.compose.foundation.layout.offset import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.unit.IntOffset import com.android.compose.nestedscroll.PriorityNestedScrollConnection import com.android.systemui.common.ui.compose.windowinsets.LocalRawScreenHeight import kotlin.math.max import kotlin.math.roundToInt import kotlin.math.tanh import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch Loading @@ -36,6 +38,7 @@ fun Modifier.stackVerticalOverscroll( coroutineScope: CoroutineScope, canScrollForward: () -> Boolean ): Modifier { val screenHeight = LocalRawScreenHeight.current val overscrollOffset = remember { Animatable(0f) } val stackNestedScrollConnection = remember { NotificationStackNestedScrollConnection( Loading @@ -43,7 +46,13 @@ fun Modifier.stackVerticalOverscroll( canScrollForward = canScrollForward, onScroll = { offsetAvailable -> coroutineScope.launch { overscrollOffset.snapTo(overscrollOffset.value + offsetAvailable * 0.3f) val maxProgress = screenHeight * 0.2f val tilt = 3f var offset = overscrollOffset.value + maxProgress * tanh(x = offsetAvailable / (maxProgress * tilt)) offset = max(offset, -1f * maxProgress) overscrollOffset.snapTo(offset) } }, onStop = { velocityAvailable -> Loading Loading @@ -79,13 +88,7 @@ fun NotificationStackNestedScrollConnection( offsetAvailable < 0f && offsetBeforeStart < 0f && !canScrollForward() }, canStartPostFling = { velocityAvailable -> velocityAvailable < 0f && !canScrollForward() }, canContinueScroll = { source -> if (source == NestedScrollSource.SideEffect) { stackOffset() > STACK_OVERSCROLL_FLING_MIN_OFFSET } else { true } }, canContinueScroll = { stackOffset() > 0f }, canScrollOnFling = true, onStart = { offsetAvailable -> onStart(offsetAvailable) }, onScroll = { offsetAvailable -> Loading packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt +0 −1 Original line number Diff line number Diff line Loading @@ -667,4 +667,3 @@ private val DEBUG_HUN_COLOR = Color(0f, 0f, 1f, 0.2f) private val DEBUG_BOX_COLOR = Color(0f, 1f, 0f, 0.2f) private const val HUN_SNOOZE_POSITIONAL_THRESHOLD_FRACTION = 0.25f private const val HUN_SNOOZE_VELOCITY_THRESHOLD = -70f internal const val STACK_OVERSCROLL_FLING_MIN_OFFSET = -100f packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +4 −0 Original line number Diff line number Diff line Loading @@ -3691,6 +3691,10 @@ public class NotificationStackScrollLayout if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { // If scene container is active, NSSL should not control its own scrolling. if (SceneContainerFlag.isEnabled()) { return false; } if (!mIsBeingDragged) { final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (vscroll != 0) { Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationStackNestedScrollConnection.kt +12 −9 Original line number Diff line number Diff line Loading @@ -23,11 +23,13 @@ import androidx.compose.foundation.layout.offset import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.unit.IntOffset import com.android.compose.nestedscroll.PriorityNestedScrollConnection import com.android.systemui.common.ui.compose.windowinsets.LocalRawScreenHeight import kotlin.math.max import kotlin.math.roundToInt import kotlin.math.tanh import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch Loading @@ -36,6 +38,7 @@ fun Modifier.stackVerticalOverscroll( coroutineScope: CoroutineScope, canScrollForward: () -> Boolean ): Modifier { val screenHeight = LocalRawScreenHeight.current val overscrollOffset = remember { Animatable(0f) } val stackNestedScrollConnection = remember { NotificationStackNestedScrollConnection( Loading @@ -43,7 +46,13 @@ fun Modifier.stackVerticalOverscroll( canScrollForward = canScrollForward, onScroll = { offsetAvailable -> coroutineScope.launch { overscrollOffset.snapTo(overscrollOffset.value + offsetAvailable * 0.3f) val maxProgress = screenHeight * 0.2f val tilt = 3f var offset = overscrollOffset.value + maxProgress * tanh(x = offsetAvailable / (maxProgress * tilt)) offset = max(offset, -1f * maxProgress) overscrollOffset.snapTo(offset) } }, onStop = { velocityAvailable -> Loading Loading @@ -79,13 +88,7 @@ fun NotificationStackNestedScrollConnection( offsetAvailable < 0f && offsetBeforeStart < 0f && !canScrollForward() }, canStartPostFling = { velocityAvailable -> velocityAvailable < 0f && !canScrollForward() }, canContinueScroll = { source -> if (source == NestedScrollSource.SideEffect) { stackOffset() > STACK_OVERSCROLL_FLING_MIN_OFFSET } else { true } }, canContinueScroll = { stackOffset() > 0f }, canScrollOnFling = true, onStart = { offsetAvailable -> onStart(offsetAvailable) }, onScroll = { offsetAvailable -> Loading
packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/Notifications.kt +0 −1 Original line number Diff line number Diff line Loading @@ -667,4 +667,3 @@ private val DEBUG_HUN_COLOR = Color(0f, 0f, 1f, 0.2f) private val DEBUG_BOX_COLOR = Color(0f, 1f, 0f, 0.2f) private const val HUN_SNOOZE_POSITIONAL_THRESHOLD_FRACTION = 0.25f private const val HUN_SNOOZE_VELOCITY_THRESHOLD = -70f internal const val STACK_OVERSCROLL_FLING_MIN_OFFSET = -100f
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +4 −0 Original line number Diff line number Diff line Loading @@ -3691,6 +3691,10 @@ public class NotificationStackScrollLayout if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { switch (event.getAction()) { case MotionEvent.ACTION_SCROLL: { // If scene container is active, NSSL should not control its own scrolling. if (SceneContainerFlag.isEnabled()) { return false; } if (!mIsBeingDragged) { final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL); if (vscroll != 0) { Loading