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
diff --git a/packages/SystemUI/compose/core/src/com/android/compose/modifiers/FadingBackground.kt b/packages/SystemUI/compose/core/src/com/android/compose/modifiers/FadingBackground.kt
index 13c2464..794b7a4 100644
--- a/packages/SystemUI/compose/core/src/com/android/compose/modifiers/FadingBackground.kt
+++ b/packages/SystemUI/compose/core/src/com/android/compose/modifiers/FadingBackground.kt
@@ -39,11 +39,7 @@
* @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 @@
properties["color"] = color
properties["alpha"] = alpha
properties["shape"] = shape
- }
+ },
)
)
@@ -65,7 +61,7 @@
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
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/AlternateBouncer.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/AlternateBouncer.kt
index c25a45d..1475795 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/AlternateBouncer.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/AlternateBouncer.kt
@@ -21,6 +21,7 @@
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.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 @@
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 @@
Modifier.width { udfpsLocation.width }
.height { udfpsLocation.height }
.fillMaxHeight()
- .offset {
- IntOffset(
- x = udfpsLocation.left,
- y = udfpsLocation.top,
- )
- },
+ .offset { IntOffset(x = udfpsLocation.left, y = udfpsLocation.top) },
)
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/qs/footer/ui/compose/FooterActions.kt b/packages/SystemUI/compose/features/src/com/android/systemui/qs/footer/ui/compose/FooterActions.kt
index e382e16..20c8c6a3 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/qs/footer/ui/compose/FooterActions.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/qs/footer/ui/compose/FooterActions.kt
@@ -72,7 +72,7 @@
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 @@
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 @@
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 @@
},
verticalAlignment = Alignment.CenterVertically,
) {
- CompositionLocalProvider(
- LocalContentColor provides contentColor,
- ) {
+ CompositionLocalProvider(LocalContentColor provides contentColor) {
if (security == null && foregroundServices == null) {
Spacer(Modifier.weight(1f))
}
@@ -238,19 +232,13 @@
{ 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 @@
/** 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 @@
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 @@
Box(
Modifier.fillMaxSize()
.clip(CircleShape)
- .indication(
- interactionSource,
- LocalIndication.current,
- )
+ .indication(interactionSource, LocalIndication.current)
) {
Text(
number.toString(),
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/CommonTile.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/CommonTile.kt
index 71fa0ac..e146603 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/CommonTile.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/CommonTile.kt
@@ -23,6 +23,7 @@
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.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 @@
Modifier.size(CommonTileDefaults.ToggleTargetSize).thenIf(toggleClickSupported) {
Modifier.clip(iconShape)
.verticalSquish(squishiness)
- .background(colors.iconBackground, { 1f })
+ .background(colors.iconBackground)
.combinedClickable(
onClick = onClick,
onLongClick = onLongClick,
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/EditTile.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/EditTile.kt
index 5c2a2bd..c87f51a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/EditTile.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/infinitegrid/EditTile.kt
@@ -96,7 +96,6 @@
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 @@
// 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()