From c270be975cf1a2d5bfd34db1c279715533330ab4 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Mon, 27 Mar 2023 16:48:03 -0700 Subject: [PATCH] [multi-shade] Remove shade content padding when the shade is collapsed. Having non-zero padding around the shade content when the shade is collapsed actually protrudes into the display and swallows clicks on the user switcher chip in the status bar near the top of the display. This CL fixes that by calculating the padding dynamically such that it's never bigger than 12dp or the height of shade, whichever is smaller. Bug: 274159734 Test: manually verified that I can click on the user switcher chip in the status bar when the shade is collapsed. I even used a stylus for increased accuracy. I also verified that the shade can be expanded and collapsed normally both from outside of it and inside of it. Change-Id: I5fab6d9ab6f0e1d771866fcb0330a6c44846d89b --- .../multishade/ui/composable/Shade.kt | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/multishade/ui/composable/Shade.kt b/packages/SystemUI/compose/features/src/com/android/systemui/multishade/ui/composable/Shade.kt index 98ef57f947833..cfcc2fb251fdb 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/multishade/ui/composable/Shade.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/multishade/ui/composable/Shade.kt @@ -22,7 +22,6 @@ import androidx.compose.foundation.interaction.DragInteraction import androidx.compose.foundation.interaction.InteractionSource import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Surface @@ -41,6 +40,7 @@ import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.android.compose.modifiers.height +import com.android.compose.modifiers.padding import com.android.compose.swipeable.FixedThreshold import com.android.compose.swipeable.SwipeableState import com.android.compose.swipeable.ThresholdConfig @@ -48,6 +48,7 @@ import com.android.compose.swipeable.rememberSwipeableState import com.android.compose.swipeable.swipeable import com.android.systemui.multishade.shared.model.ProxiedInputModel import com.android.systemui.multishade.ui.viewmodel.ShadeViewModel +import kotlin.math.min import kotlin.math.roundToInt import kotlinx.coroutines.launch @@ -145,13 +146,31 @@ private fun ShadeContent( modifier: Modifier = Modifier, content: @Composable () -> Unit = {}, ) { + /** + * Returns a function that takes in [Density] and returns the current padding around the shade + * content. + */ + fun padding( + shadeHeightPx: () -> Float, + ): Density.() -> Int { + return { + min( + 12.dp.toPx().roundToInt(), + shadeHeightPx().roundToInt(), + ) + } + } + Surface( shape = RoundedCornerShape(32.dp), modifier = modifier - .padding(12.dp) .fillMaxWidth() .height { shadeHeightPx().roundToInt() } + .padding( + horizontal = padding(shadeHeightPx), + vertical = padding(shadeHeightPx), + ) .graphicsLayer { // Applies the vertical over-stretching of the shade content that may happen if // the user keep dragging down when the shade is already fully-expanded.