Loading packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/SingleShadeMeasurePolicy.kt +27 −20 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import androidx.compose.ui.layout.Placeable import androidx.compose.ui.layout.layoutId import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.offset import androidx.compose.ui.util.fastFirst import androidx.compose.ui.util.fastFirstOrNull import com.android.systemui.shade.ui.composable.SingleShadeMeasurePolicy.LayoutId import kotlin.math.max Loading Loading @@ -60,18 +59,20 @@ class SingleShadeMeasurePolicy( val shadeHeaderPlaceable = measurables .fastFirst { it.layoutId == LayoutId.ShadeHeader } .measure(constraintsWithCutout) .fastFirstOrNull { it.layoutId == LayoutId.ShadeHeader } ?.measure(constraintsWithCutout) val mediaPlaceable = measurables .fastFirstOrNull { it.layoutId == LayoutId.Media } ?.measure(applyMediaConstraints(constraintsWithCutout, isMediaInRow)) val quickSettingsPlaceable = measurables .fastFirst { it.layoutId == LayoutId.QuickSettings } .measure(constraintsWithCutout) .fastFirstOrNull { it.layoutId == LayoutId.QuickSettings } ?.measure(constraintsWithCutout) val notificationsPlaceable = measurables.fastFirst { it.layoutId == LayoutId.Notifications }.measure(constraints) measurables .fastFirstOrNull { it.layoutId == LayoutId.Notifications } ?.measure(constraints) val notificationsTop = calculateNotificationsTop( Loading @@ -84,23 +85,25 @@ class SingleShadeMeasurePolicy( onNotificationsTopChanged(notificationsTop) return layout(constraints.maxWidth, constraints.maxHeight) { shadeHeaderPlaceable.placeRelative(x = insetsLeft, y = insetsTop) quickSettingsPlaceable.placeRelative( shadeHeaderPlaceable?.placeRelative(x = insetsLeft, y = insetsTop) val statusBarHeaderHeight = shadeHeaderPlaceable?.height ?: 0 quickSettingsPlaceable?.placeRelative( x = insetsLeft, y = insetsTop + shadeHeaderPlaceable.height, y = insetsTop + statusBarHeaderHeight, ) if (mediaPlaceable != null) if (mediaPlaceable != null) { val quickSettingsHeight = quickSettingsPlaceable?.height ?: 0 if (isMediaInRow) { // mediaPlaceable height ranges from 0 to qsHeight. We want it to be centered // vertically when it's smaller than the QS val mediaCenteringOffset = (quickSettingsPlaceable.height - mediaPlaceable.height) / 2 val mediaCenteringOffset = (quickSettingsHeight - mediaPlaceable.height) / 2 mediaPlaceable.placeRelative( x = insetsLeft + constraintsWithCutout.maxWidth / 2, y = insetsTop + shadeHeaderPlaceable.height + statusBarHeaderHeight + mediaCenteringOffset + mediaOffset(), zIndex = mediaZIndex(), Loading @@ -108,30 +111,34 @@ class SingleShadeMeasurePolicy( } else { mediaPlaceable.placeRelative( x = insetsLeft, y = insetsTop + shadeHeaderPlaceable.height + quickSettingsPlaceable.height, y = insetsTop + statusBarHeaderHeight + quickSettingsHeight, zIndex = mediaZIndex(), ) } } // Notifications don't need to accommodate for horizontal insets notificationsPlaceable.placeRelative(x = 0, y = notificationsTop) notificationsPlaceable?.placeRelative(x = 0, y = notificationsTop) } } private fun calculateNotificationsTop( statusBarHeaderPlaceable: Placeable, quickSettingsPlaceable: Placeable, statusBarHeaderPlaceable: Placeable?, quickSettingsPlaceable: Placeable?, mediaPlaceable: Placeable?, insetsTop: Int, isMediaInRow: Boolean, ): Int { val mediaHeight = mediaPlaceable?.height ?: 0 val statusBarHeaderHeight = statusBarHeaderPlaceable?.height ?: 0 val quickSettingsHeight = quickSettingsPlaceable?.height ?: 0 return insetsTop + statusBarHeaderPlaceable.height + statusBarHeaderHeight + if (isMediaInRow) { max(quickSettingsPlaceable.height, mediaHeight) max(quickSettingsHeight, mediaHeight) } else { quickSettingsPlaceable.height + mediaHeight quickSettingsHeight + mediaHeight } } Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/SingleShadeMeasurePolicy.kt +27 −20 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import androidx.compose.ui.layout.Placeable import androidx.compose.ui.layout.layoutId import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.offset import androidx.compose.ui.util.fastFirst import androidx.compose.ui.util.fastFirstOrNull import com.android.systemui.shade.ui.composable.SingleShadeMeasurePolicy.LayoutId import kotlin.math.max Loading Loading @@ -60,18 +59,20 @@ class SingleShadeMeasurePolicy( val shadeHeaderPlaceable = measurables .fastFirst { it.layoutId == LayoutId.ShadeHeader } .measure(constraintsWithCutout) .fastFirstOrNull { it.layoutId == LayoutId.ShadeHeader } ?.measure(constraintsWithCutout) val mediaPlaceable = measurables .fastFirstOrNull { it.layoutId == LayoutId.Media } ?.measure(applyMediaConstraints(constraintsWithCutout, isMediaInRow)) val quickSettingsPlaceable = measurables .fastFirst { it.layoutId == LayoutId.QuickSettings } .measure(constraintsWithCutout) .fastFirstOrNull { it.layoutId == LayoutId.QuickSettings } ?.measure(constraintsWithCutout) val notificationsPlaceable = measurables.fastFirst { it.layoutId == LayoutId.Notifications }.measure(constraints) measurables .fastFirstOrNull { it.layoutId == LayoutId.Notifications } ?.measure(constraints) val notificationsTop = calculateNotificationsTop( Loading @@ -84,23 +85,25 @@ class SingleShadeMeasurePolicy( onNotificationsTopChanged(notificationsTop) return layout(constraints.maxWidth, constraints.maxHeight) { shadeHeaderPlaceable.placeRelative(x = insetsLeft, y = insetsTop) quickSettingsPlaceable.placeRelative( shadeHeaderPlaceable?.placeRelative(x = insetsLeft, y = insetsTop) val statusBarHeaderHeight = shadeHeaderPlaceable?.height ?: 0 quickSettingsPlaceable?.placeRelative( x = insetsLeft, y = insetsTop + shadeHeaderPlaceable.height, y = insetsTop + statusBarHeaderHeight, ) if (mediaPlaceable != null) if (mediaPlaceable != null) { val quickSettingsHeight = quickSettingsPlaceable?.height ?: 0 if (isMediaInRow) { // mediaPlaceable height ranges from 0 to qsHeight. We want it to be centered // vertically when it's smaller than the QS val mediaCenteringOffset = (quickSettingsPlaceable.height - mediaPlaceable.height) / 2 val mediaCenteringOffset = (quickSettingsHeight - mediaPlaceable.height) / 2 mediaPlaceable.placeRelative( x = insetsLeft + constraintsWithCutout.maxWidth / 2, y = insetsTop + shadeHeaderPlaceable.height + statusBarHeaderHeight + mediaCenteringOffset + mediaOffset(), zIndex = mediaZIndex(), Loading @@ -108,30 +111,34 @@ class SingleShadeMeasurePolicy( } else { mediaPlaceable.placeRelative( x = insetsLeft, y = insetsTop + shadeHeaderPlaceable.height + quickSettingsPlaceable.height, y = insetsTop + statusBarHeaderHeight + quickSettingsHeight, zIndex = mediaZIndex(), ) } } // Notifications don't need to accommodate for horizontal insets notificationsPlaceable.placeRelative(x = 0, y = notificationsTop) notificationsPlaceable?.placeRelative(x = 0, y = notificationsTop) } } private fun calculateNotificationsTop( statusBarHeaderPlaceable: Placeable, quickSettingsPlaceable: Placeable, statusBarHeaderPlaceable: Placeable?, quickSettingsPlaceable: Placeable?, mediaPlaceable: Placeable?, insetsTop: Int, isMediaInRow: Boolean, ): Int { val mediaHeight = mediaPlaceable?.height ?: 0 val statusBarHeaderHeight = statusBarHeaderPlaceable?.height ?: 0 val quickSettingsHeight = quickSettingsPlaceable?.height ?: 0 return insetsTop + statusBarHeaderPlaceable.height + statusBarHeaderHeight + if (isMediaInRow) { max(quickSettingsPlaceable.height, mediaHeight) max(quickSettingsHeight, mediaHeight) } else { quickSettingsPlaceable.height + mediaHeight quickSettingsHeight + mediaHeight } } Loading