Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5ce132a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Improve cutout related performance" into main

parents 8cc9e5fe 18b7e5cd
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.State
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.platform.LocalContext
@@ -52,7 +53,11 @@ fun ScreenDecorProvider(windowInsets: () -> WindowInsets?, content: @Composable
    val screenCornerRadiusPx =
        remember(context.display.uniqueId) { ScreenDecorationsUtils.getWindowCornerRadius(context) }
    val screenCornerRadiusDp = with(LocalDensity.current) { screenCornerRadiusPx.toDp() }
    val cutout = remember(windowInsets, context) { { windowInsets().toCutout(context) } }
    val cutout =
        remember(windowInsets, context) {
            val cutoutState = derivedStateOf { windowInsets().toCutout(context) }
            ({ cutoutState.value })
        }

    CompositionLocalProvider(
        LocalScreenCornerRadius provides screenCornerRadiusDp,
+6 −3
Original line number Diff line number Diff line
@@ -66,8 +66,7 @@ constructor(
    @Composable
    fun StatusBar(modifier: Modifier = Modifier) {
        val context = LocalContext.current
        val viewDisplayCutout =
            LocalDisplayCutout.current().viewDisplayCutoutKeyguardStatusBarView
        val displayCutout = LocalDisplayCutout.current

        @SuppressLint("InflateParams")
        val view =
@@ -114,7 +113,11 @@ constructor(
            },
            modifier =
                modifier.fillMaxWidth().height { Utils.getStatusBarHeaderHeightKeyguard(context) },
            update = { viewController.setDisplayCutout(viewDisplayCutout) },
            update = {
                viewController.setDisplayCutout(
                    displayCutout().viewDisplayCutoutKeyguardStatusBarView
                )
            },
        )
    }

+2 −1
Original line number Diff line number Diff line
@@ -598,7 +598,7 @@ private fun BatteryIconLegacy(
    val inverseColor =
        Utils.getColorAttrDefaultColor(themedContext, android.R.attr.textColorPrimaryInverse)

    val cutoutLocation = LocalDisplayCutout.current().location
    val cutout = LocalDisplayCutout.current

    AndroidView(
        factory = { context ->
@@ -618,6 +618,7 @@ private fun BatteryIconLegacy(
            batteryIcon
        },
        update = { batteryIcon ->
            val cutoutLocation = cutout().location
            batteryIcon.setPercentShowMode(
                if (useExpandedFormat || cutoutLocation != CutoutLocation.CENTER) {
                    BatteryMeterView.MODE_ESTIMATE
+3 −2
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ private fun ContentScope.SingleShade(
    shadeSession: SaveableSession,
    usingCollapsedLandscapeMedia: Boolean,
) {
    val cutoutLocation = LocalDisplayCutout.current().location
    val cutout = LocalDisplayCutout.current
    val cutoutInsets = WindowInsets.Companion.displayCutout
    // TODO(b/428779792): update color to match BC25 spec
    val shadePanelColor = Color.Gray.copy(alpha = 0.32f)
@@ -287,7 +287,8 @@ private fun ContentScope.SingleShade(
    val shadeHorizontalPadding =
        dimensionResource(id = R.dimen.notification_panel_margin_horizontal)
    val shadeMeasurePolicy =
        remember(mediaInRow) {
        remember(mediaInRow, cutout, cutoutInsets) {
            val cutoutLocation = cutout().location
            SingleShadeMeasurePolicy(
                isMediaInRow = mediaInRow,
                mediaOffset = { mediaOffset.roundToPx() },