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

Commit cd38fe7c authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Partially revert ag/31525412

This CL partially reverts ag/31525412 because the change in Icon.kt
seems to have broken the QS icon drawing (see b/394738023).

Note that this CL is now using `remember` to remember the drawable
bitmap, to avoid unnecessary work during composition.

Bug: 394738023
Test: Manual, observed that the icon is now centered and sized correctly
Flag: EXEMPT bug fix
Change-Id: I5d4dc7288850645c7650c2cd9097dee948cbd29a
parent e018f198
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -19,10 +19,12 @@ package com.android.systemui.common.ui.compose
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.res.painterResource
import com.android.compose.ui.graphics.painter.rememberDrawablePainter
import androidx.core.graphics.drawable.toBitmap
import com.android.systemui.common.shared.model.Icon

/**
@@ -35,7 +37,12 @@ fun Icon(icon: Icon, modifier: Modifier = Modifier, tint: Color = LocalContentCo
    val contentDescription = icon.contentDescription?.load()
    when (icon) {
        is Icon.Loaded -> {
            Icon(rememberDrawablePainter(icon.drawable), contentDescription, modifier, tint)
            Icon(
                remember(icon.drawable) { icon.drawable.toBitmap().asImageBitmap() },
                contentDescription,
                modifier,
                tint,
            )
        }
        is Icon.Resource -> Icon(painterResource(icon.res), contentDescription, modifier, tint)
    }