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

Commit 62af491a authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge "Only apply the new tint API in the Volume Panel" into main

parents e97db554 80b21059
Loading
Loading
Loading
Loading
+38 −3
Original line number Diff line number Diff line
@@ -30,17 +30,52 @@ import com.android.systemui.common.shared.model.Icon
 * Icon composable that draws [icon] using [tint].
 *
 * Note: You can use [Color.Unspecified] to disable the tint and keep the original icon colors.
 *
 * Note: Some drawables aren't compatible with [rememberDrawablePainter], used here for
 * [Icon.Loaded] icons, and won't be resized from their intrinsic size (b/394738023).
 */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Icon(icon: Icon, modifier: Modifier = Modifier, tint: Color = LocalContentColor.current) {
    val contentDescription = icon.contentDescription?.load()
    when (icon) {
        is Icon.Loaded -> {
            Icon(rememberDrawablePainter(icon.drawable), { tint }, contentDescription, modifier)
            Icon(rememberDrawablePainter(icon.drawable), contentDescription, modifier, tint)
        }
        is Icon.Resource -> {
            Icon(painterResource(icon.res), contentDescription, modifier, tint)
        }
    }
}

/**
 * Icon composable that draws [icon] using [tint]. Pass null [tint] to use the default tint color.
 *
 * Note: You can use [Color.Unspecified] to disable the tint and keep the original icon colors.
 *
 * Note: Some drawables aren't compatible with [rememberDrawablePainter], used here for
 * [Icon.Loaded] icons, and won't be resized from their intrinsic size (b/394738023).
 */
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun Icon(icon: Icon, tint: (() -> Color)?, modifier: Modifier = Modifier) {
    val localContentColor = LocalContentColor.current
    val contentDescription = icon.contentDescription?.load()
    when (icon) {
        is Icon.Loaded -> {
            Icon(
                rememberDrawablePainter(icon.drawable),
                tint ?: { localContentColor },
                contentDescription,
                modifier,
            )
        }
        is Icon.Resource -> {
            Icon(
                painterResource(icon.res),
                tint ?: { localContentColor },
                contentDescription,
                modifier,
            )
        }
        is Icon.Resource -> Icon(painterResource(icon.res), { tint }, contentDescription, modifier)
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -167,6 +167,7 @@ fun VolumeSlider(
                                            icon = {
                                                Icon(
                                                    icon = icon,
                                                    tint = null,
                                                    modifier =
                                                        Modifier.size(24.dp)
                                                            .testTag(
@@ -186,6 +187,7 @@ fun VolumeSlider(
                                            icon = {
                                                Icon(
                                                    icon = icon,
                                                    tint = null,
                                                    modifier =
                                                        Modifier.size(24.dp)
                                                            .testTag(
+10 −2
Original line number Diff line number Diff line
@@ -139,7 +139,11 @@ private fun VolumeDialogSlider(
                activeTrackEndIcon = { iconsState ->
                    SliderIcon(
                        icon = {
                            Icon(icon = sliderStateModel.icon, modifier = Modifier.size(20.dp))
                            Icon(
                                icon = sliderStateModel.icon,
                                tint = null,
                                modifier = Modifier.size(20.dp),
                            )
                        },
                        isVisible = !iconsState.isInactiveTrackEndIconVisible,
                    )
@@ -147,7 +151,11 @@ private fun VolumeDialogSlider(
                inactiveTrackEndIcon = { iconsState ->
                    SliderIcon(
                        icon = {
                            Icon(icon = sliderStateModel.icon, modifier = Modifier.size(20.dp))
                            Icon(
                                icon = sliderStateModel.icon,
                                tint = null,
                                modifier = Modifier.size(20.dp),
                            )
                        },
                        isVisible = iconsState.isInactiveTrackEndIconVisible,
                    )