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

Commit 2f648a6f authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Rename Modifier.background(Color, () -> Float) to fadingBackground (1/2)

This CL renames the overload Modifier.background() meant to be used when
the background fades away to Modifier.fadingBackground(). This avoids
people using this when they can simply use Modifier.background.

Bug: 375119446
Test: N/A simple renaming
Flag: EXEMPT simple renaming
Change-Id: Idd18c646ae0397be5c1e8e4047d7cd96c6438b17
parent a994119a
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -39,11 +39,7 @@ import androidx.compose.ui.unit.LayoutDirection
 * @param alpha alpha of the background
 * @param shape desired shape of the background
 */
fun Modifier.background(
    color: Color,
    alpha: () -> Float,
    shape: Shape = RectangleShape,
) =
fun Modifier.fadingBackground(color: Color, alpha: () -> Float, shape: Shape = RectangleShape) =
    this.then(
        FadingBackground(
            brush = SolidColor(color),
@@ -56,7 +52,7 @@ fun Modifier.background(
                    properties["color"] = color
                    properties["alpha"] = alpha
                    properties["shape"] = shape
                }
                },
        )
    )

@@ -65,7 +61,7 @@ constructor(
    private val brush: Brush,
    private val shape: Shape,
    private val alpha: () -> Float,
    inspectorInfo: InspectorInfo.() -> Unit
    inspectorInfo: InspectorInfo.() -> Unit,
) : DrawModifier, InspectorValueInfo(inspectorInfo) {
    // naive cache outline calculation if size is the same
    private var lastSize: Size? = null
+8 −16
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
@@ -40,7 +41,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.modifiers.background
import com.android.compose.modifiers.height
import com.android.compose.modifiers.width
import com.android.systemui.deviceentry.shared.model.BiometricMessage
@@ -82,16 +82,13 @@ fun AlternateBouncer(
        Box(
            contentAlignment = Alignment.TopCenter,
            modifier =
                Modifier.background(color = Colors.AlternateBouncerBackgroundColor, alpha = { 1f })
                    .pointerInput(Unit) {
                        detectTapGestures(
                            onTap = { alternateBouncerDependencies.viewModel.onTapped() }
                        )
                Modifier.background(color = Colors.AlternateBouncerBackgroundColor).pointerInput(
                    Unit
                ) {
                    detectTapGestures(onTap = { alternateBouncerDependencies.viewModel.onTapped() })
                },
        ) {
            StatusMessage(
                viewModel = alternateBouncerDependencies.messageAreaViewModel,
            )
            StatusMessage(viewModel = alternateBouncerDependencies.messageAreaViewModel)
        }

        udfpsIconLocation?.let { udfpsLocation ->
@@ -103,12 +100,7 @@ fun AlternateBouncer(
                        Modifier.width { udfpsLocation.width }
                            .height { udfpsLocation.height }
                            .fillMaxHeight()
                            .offset {
                                IntOffset(
                                    x = udfpsLocation.left,
                                    y = udfpsLocation.top,
                                )
                            },
                            .offset { IntOffset(x = udfpsLocation.left, y = udfpsLocation.top) },
                )
            }

+10 −32
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.compose.animation.Expandable
import com.android.compose.animation.scene.SceneScope
import com.android.compose.modifiers.background
import com.android.compose.modifiers.fadingBackground
import com.android.compose.theme.colorAttr
import com.android.systemui.animation.Expandable
import com.android.systemui.common.shared.model.Icon
@@ -107,7 +107,7 @@ fun SceneScope.FooterActionsWithAnimatedVisibility(
                animationSpec = tween(customizingAnimationDuration),
                targetHeight = { 0 },
            ) + fadeOut(tween(customizingAnimationDuration)),
        modifier = modifier.fillMaxWidth()
        modifier = modifier.fillMaxWidth(),
    ) {
        QuickSettingsTheme {
            // This view has its own horizontal padding
@@ -165,12 +165,8 @@ fun FooterActions(
    val contentColor = MaterialTheme.colorScheme.onSurface
    val backgroundTopRadius = dimensionResource(R.dimen.qs_corner_radius)
    val backgroundModifier =
        remember(
            backgroundColor,
            backgroundAlpha,
            backgroundTopRadius,
        ) {
            Modifier.background(
        remember(backgroundColor, backgroundAlpha, backgroundTopRadius) {
            Modifier.fadingBackground(
                backgroundColor,
                backgroundAlpha::value,
                RoundedCornerShape(topStart = backgroundTopRadius, topEnd = backgroundTopRadius),
@@ -210,9 +206,7 @@ fun FooterActions(
            },
        verticalAlignment = Alignment.CenterVertically,
    ) {
        CompositionLocalProvider(
            LocalContentColor provides contentColor,
        ) {
        CompositionLocalProvider(LocalContentColor provides contentColor) {
            if (security == null && foregroundServices == null) {
                Spacer(Modifier.weight(1f))
            }
@@ -238,19 +232,13 @@ private fun SecurityButton(
            { expandable -> onClick(context, expandable) }
        }

    TextButton(
        model.icon,
        model.text,
        showNewDot = false,
        onClick = onClick,
        modifier,
    )
    TextButton(model.icon, model.text, showNewDot = false, onClick = onClick, modifier)
}

/** The foreground services button. */
@Composable
private fun RowScope.ForegroundServicesButton(
    model: FooterActionsForegroundServicesButtonViewModel,
    model: FooterActionsForegroundServicesButtonViewModel
) {
    if (model.displayText) {
        TextButton(
@@ -271,10 +259,7 @@ private fun RowScope.ForegroundServicesButton(

/** A button with an icon. */
@Composable
private fun IconButton(
    model: FooterActionsButtonViewModel,
    modifier: Modifier = Modifier,
) {
private fun IconButton(model: FooterActionsButtonViewModel, modifier: Modifier = Modifier) {
    Expandable(
        color = colorAttr(model.backgroundColor),
        shape = CircleShape,
@@ -282,11 +267,7 @@ private fun IconButton(
        modifier = modifier,
    ) {
        val tint = model.iconTint?.let { Color(it) } ?: Color.Unspecified
        Icon(
            model.icon,
            tint = tint,
            modifier = Modifier.size(20.dp),
        )
        Icon(model.icon, tint = tint, modifier = Modifier.size(20.dp))
    }
}

@@ -316,10 +297,7 @@ private fun NumberButton(
            Box(
                Modifier.fillMaxSize()
                    .clip(CircleShape)
                    .indication(
                        interactionSource,
                        LocalIndication.current,
                    )
                    .indication(interactionSource, LocalIndication.current)
            ) {
                Text(
                    number.toString(),
+2 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import androidx.compose.animation.graphics.res.animatedVectorResource
import androidx.compose.animation.graphics.res.rememberAnimatedVectorPainter
import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -57,7 +58,6 @@ import androidx.compose.ui.semantics.stateDescription
import androidx.compose.ui.semantics.toggleableState
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.android.compose.modifiers.background
import com.android.compose.modifiers.thenIf
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.ui.compose.Icon
@@ -93,7 +93,7 @@ fun LargeTileContent(
                Modifier.size(CommonTileDefaults.ToggleTargetSize).thenIf(toggleClickSupported) {
                    Modifier.clip(iconShape)
                        .verticalSquish(squishiness)
                        .background(colors.iconBackground, { 1f })
                        .background(colors.iconBackground)
                        .combinedClickable(
                            onClick = onClick,
                            onLongClick = onLongClick,
+4 −3
Original line number Diff line number Diff line
@@ -96,7 +96,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.util.fastMap
import com.android.compose.animation.bounceable
import com.android.compose.modifiers.background
import com.android.compose.modifiers.height
import com.android.systemui.common.ui.compose.load
import com.android.systemui.qs.panels.shared.model.SizedTile
@@ -382,8 +381,10 @@ fun LazyGridScope.EditTiles(
                    // If the tile is being moved, replace it with a visible spacer
                    SpacerGridCell(
                        Modifier.background(
                                color = MaterialTheme.colorScheme.secondary,
                                alpha = { EditModeTileDefaults.PLACEHOLDER_ALPHA },
                                color =
                                    MaterialTheme.colorScheme.secondary.copy(
                                        alpha = EditModeTileDefaults.PLACEHOLDER_ALPHA
                                    ),
                                shape = RoundedCornerShape(InactiveCornerRadius),
                            )
                            .animateItem()