Loading packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/windowinsets/DisplayCutout.kt +15 −8 Original line number Diff line number Diff line Loading @@ -17,16 +17,22 @@ package com.android.systemui.common.ui.compose.windowinsets import android.view.DisplayCutout as ViewDisplayCutout import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import kotlin.math.abs /** Represents the global position of the bounds for the display cutout for this display */ /** * Represents the global position of the bounds for the display cutout for this display. * * Important: The bounds are expressed in raw pixels (and not dips) because these bounds should be * used either during layout or drawing but *not* during composition. This is because insets are * computed after composition but before layout. Moreover, these insets can be animated and we don't * want to recompose every frame. */ data class DisplayCutout( val left: Dp = 0.dp, val top: Dp = 0.dp, val right: Dp = 0.dp, val bottom: Dp = 0.dp, val left: Int = 0, val top: Int = 0, val right: Int = 0, val bottom: Int = 0, val location: CutoutLocation = CutoutLocation.NONE, /** * The original `DisplayCutout` for the `View` world; only use this when feeding it back to a Loading @@ -34,8 +40,9 @@ data class DisplayCutout( */ val viewDisplayCutoutKeyguardStatusBarView: ViewDisplayCutout? = null, ) { fun width() = abs(right.value - left.value).dp fun height() = abs(bottom.value - top.value).dp fun width() = abs(right - left).dp fun height() = abs(bottom - top).dp } enum class CutoutLocation { Loading packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/windowinsets/ScreenDecorProvider.kt +8 −14 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.android.internal.policy.ScreenDecorationsUtils Loading Loading @@ -70,14 +69,14 @@ fun ScreenDecorProvider(windowInsets: () -> WindowInsets?, content: @Composable private fun WindowInsets?.toCutout(context: Context): DisplayCutout { val boundingRect = this?.displayCutout?.boundingRectTop val width = boundingRect?.let { boundingRect.right - boundingRect.left } ?: 0 val left = boundingRect?.left?.toDp(context) ?: 0.dp val top = boundingRect?.top?.toDp(context) ?: 0.dp val right = boundingRect?.right?.toDp(context) ?: 0.dp val bottom = boundingRect?.bottom?.toDp(context) ?: 0.dp val left = boundingRect?.left ?: 0 val top = boundingRect?.top ?: 0 val right = boundingRect?.right ?: 0 val bottom = boundingRect?.bottom ?: 0 val location = when { width <= 0f -> CutoutLocation.NONE left <= 0.dp -> CutoutLocation.LEFT width <= 0 -> CutoutLocation.NONE left <= 0 -> CutoutLocation.LEFT right >= getDisplayWidth(context) -> CutoutLocation.RIGHT else -> CutoutLocation.CENTER } Loading @@ -86,13 +85,8 @@ private fun WindowInsets?.toCutout(context: Context): DisplayCutout { } // TODO(b/298525212): remove once Compose exposes window inset bounds. private fun Int.toDp(context: Context): Dp { return (this.toFloat() / context.resources.displayMetrics.density).dp } // TODO(b/298525212): remove once Compose exposes window inset bounds. private fun getDisplayWidth(context: Context): Dp { private fun getDisplayWidth(context: Context): Int { val point = Point() checkNotNull(context.display).getRealSize(point) return point.x.toDp(context) return point.x } packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeHeader.kt +2 −1 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.ShadeCarrierG import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.composeWrapper import com.android.systemui.statusbar.policy.Clock import com.android.systemui.util.composable.kairos.ActivatedKairosSpec import kotlin.math.max import kotlin.math.roundToInt import kotlinx.coroutines.delay Loading Loading @@ -474,7 +475,7 @@ private fun CutoutAwareShadeHeader( val screenWidth = constraints.maxWidth val cutoutWidthPx = cutoutWidth.roundToPx() val height = max(cutoutHeight + (cutoutTop * 2), statusBarHeight).roundToPx() val height = max(cutoutHeight.roundToPx() + (cutoutTop * 2), statusBarHeight.roundToPx()) val childConstraints = Constraints.fixed((screenWidth - cutoutWidthPx) / 2, height) val startMeasurable = measurables[0][0] Loading packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt +1 −9 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.Layout import androidx.compose.ui.layout.layoutId Loading Loading @@ -259,13 +258,6 @@ private fun ContentScope.SingleShade( mediaHost.expansion = if (usingCollapsedLandscapeMedia && isLandscape()) COLLAPSED else EXPANDED var maxNotifScrimTop by remember { mutableIntStateOf(0) } val tileSquishiness by animateContentFloatAsState( value = 1f, key = QuickSettings.SharedValues.TilesSquishiness, canOverflow = false, ) val shouldPunchHoleBehindScrim = layoutState.isTransitioningBetween(Scenes.Gone, Scenes.Shade) || layoutState.isTransitioning(from = Scenes.Lockscreen, to = Scenes.Shade) Loading Loading @@ -308,7 +300,7 @@ private fun ContentScope.SingleShade( ) } Box() { Box(modifier) { Box( modifier = Modifier.fillMaxSize() Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/windowinsets/DisplayCutout.kt +15 −8 Original line number Diff line number Diff line Loading @@ -17,16 +17,22 @@ package com.android.systemui.common.ui.compose.windowinsets import android.view.DisplayCutout as ViewDisplayCutout import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import kotlin.math.abs /** Represents the global position of the bounds for the display cutout for this display */ /** * Represents the global position of the bounds for the display cutout for this display. * * Important: The bounds are expressed in raw pixels (and not dips) because these bounds should be * used either during layout or drawing but *not* during composition. This is because insets are * computed after composition but before layout. Moreover, these insets can be animated and we don't * want to recompose every frame. */ data class DisplayCutout( val left: Dp = 0.dp, val top: Dp = 0.dp, val right: Dp = 0.dp, val bottom: Dp = 0.dp, val left: Int = 0, val top: Int = 0, val right: Int = 0, val bottom: Int = 0, val location: CutoutLocation = CutoutLocation.NONE, /** * The original `DisplayCutout` for the `View` world; only use this when feeding it back to a Loading @@ -34,8 +40,9 @@ data class DisplayCutout( */ val viewDisplayCutoutKeyguardStatusBarView: ViewDisplayCutout? = null, ) { fun width() = abs(right.value - left.value).dp fun height() = abs(bottom.value - top.value).dp fun width() = abs(right - left).dp fun height() = abs(bottom - top).dp } enum class CutoutLocation { Loading
packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/windowinsets/ScreenDecorProvider.kt +8 −14 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.android.internal.policy.ScreenDecorationsUtils Loading Loading @@ -70,14 +69,14 @@ fun ScreenDecorProvider(windowInsets: () -> WindowInsets?, content: @Composable private fun WindowInsets?.toCutout(context: Context): DisplayCutout { val boundingRect = this?.displayCutout?.boundingRectTop val width = boundingRect?.let { boundingRect.right - boundingRect.left } ?: 0 val left = boundingRect?.left?.toDp(context) ?: 0.dp val top = boundingRect?.top?.toDp(context) ?: 0.dp val right = boundingRect?.right?.toDp(context) ?: 0.dp val bottom = boundingRect?.bottom?.toDp(context) ?: 0.dp val left = boundingRect?.left ?: 0 val top = boundingRect?.top ?: 0 val right = boundingRect?.right ?: 0 val bottom = boundingRect?.bottom ?: 0 val location = when { width <= 0f -> CutoutLocation.NONE left <= 0.dp -> CutoutLocation.LEFT width <= 0 -> CutoutLocation.NONE left <= 0 -> CutoutLocation.LEFT right >= getDisplayWidth(context) -> CutoutLocation.RIGHT else -> CutoutLocation.CENTER } Loading @@ -86,13 +85,8 @@ private fun WindowInsets?.toCutout(context: Context): DisplayCutout { } // TODO(b/298525212): remove once Compose exposes window inset bounds. private fun Int.toDp(context: Context): Dp { return (this.toFloat() / context.resources.displayMetrics.density).dp } // TODO(b/298525212): remove once Compose exposes window inset bounds. private fun getDisplayWidth(context: Context): Dp { private fun getDisplayWidth(context: Context): Int { val point = Point() checkNotNull(context.display).getRealSize(point) return point.x.toDp(context) return point.x }
packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeHeader.kt +2 −1 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.ShadeCarrierG import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.composeWrapper import com.android.systemui.statusbar.policy.Clock import com.android.systemui.util.composable.kairos.ActivatedKairosSpec import kotlin.math.max import kotlin.math.roundToInt import kotlinx.coroutines.delay Loading Loading @@ -474,7 +475,7 @@ private fun CutoutAwareShadeHeader( val screenWidth = constraints.maxWidth val cutoutWidthPx = cutoutWidth.roundToPx() val height = max(cutoutHeight + (cutoutTop * 2), statusBarHeight).roundToPx() val height = max(cutoutHeight.roundToPx() + (cutoutTop * 2), statusBarHeight.roundToPx()) val childConstraints = Constraints.fixed((screenWidth - cutoutWidthPx) / 2, height) val startMeasurable = measurables[0][0] Loading
packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt +1 −9 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.Layout import androidx.compose.ui.layout.layoutId Loading Loading @@ -259,13 +258,6 @@ private fun ContentScope.SingleShade( mediaHost.expansion = if (usingCollapsedLandscapeMedia && isLandscape()) COLLAPSED else EXPANDED var maxNotifScrimTop by remember { mutableIntStateOf(0) } val tileSquishiness by animateContentFloatAsState( value = 1f, key = QuickSettings.SharedValues.TilesSquishiness, canOverflow = false, ) val shouldPunchHoleBehindScrim = layoutState.isTransitioningBetween(Scenes.Gone, Scenes.Shade) || layoutState.isTransitioning(from = Scenes.Lockscreen, to = Scenes.Shade) Loading Loading @@ -308,7 +300,7 @@ private fun ContentScope.SingleShade( ) } Box() { Box(modifier) { Box( modifier = Modifier.fillMaxSize() Loading