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

Commit 4ebe88f1 authored by Andreas Miko's avatar Andreas Miko
Browse files

Wire up BundleIcon

The BundleIcon is now shown according to BundleSpec and stored as resId

Bug: b/389839492
Test: icon is now visible
Flag: com.android.systemui.notification_bundle_ui
Change-Id: I2fdca5caac31a1a15819afa05019f802144f504c
parent 9c54983d
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.notifications.ui.composable.row

import android.graphics.drawable.Drawable
import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
@@ -46,6 +47,7 @@ import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.android.compose.animation.scene.ContentScope
@@ -71,7 +73,7 @@ object NotificationRowPrimitives {

/** The Icon displayed at the start of any notification row. */
@Composable
fun ContentScope.BundleIcon(drawable: Drawable?, modifier: Modifier = Modifier) {
fun ContentScope.BundleIcon(@DrawableRes drawable: Int?, modifier: Modifier = Modifier) {
    val surfaceColor = notificationElementSurfaceColor()
    Box(
        modifier =
@@ -82,7 +84,7 @@ fun ContentScope.BundleIcon(drawable: Drawable?, modifier: Modifier = Modifier)
                .background(color = surfaceColor, shape = CircleShape)
    ) {
        if (drawable == null) return@Box
        val painter = rememberDrawablePainter(drawable)
        val painter = painterResource(drawable)
        Image(
            painter = painter,
            contentDescription = null,
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
class BundleEntry(spec: BundleSpec) : PipelineEntry(spec.key) {

    /** The model used by UI. */
    val bundleRepository = BundleRepository(spec.titleTextResId)
    val bundleRepository = BundleRepository(spec.titleTextResId, spec.icon)

    // TODO(b/394483200): move NotificationEntry's implementation to PipelineEntry?
    val isSensitive: MutableStateFlow<Boolean> = MutableStateFlow(false)
+11 −1
Original line number Diff line number Diff line
@@ -17,35 +17,45 @@
package com.android.systemui.statusbar.notification.collection

import android.app.NotificationChannel
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import com.android.internal.R

data class BundleSpec(val key: String, @StringRes val titleTextResId: Int) {
data class BundleSpec(
    val key: String,
    @StringRes val titleTextResId: Int,
    @DrawableRes val icon: Int,
) {
    companion object {
        val PROMOTIONS =
            BundleSpec(
                key = NotificationChannel.PROMOTIONS_ID,
                titleTextResId = R.string.promotional_notification_channel_label,
                icon = com.android.settingslib.R.drawable.ic_promotions,
            )
        val SOCIAL_MEDIA =
            BundleSpec(
                key = NotificationChannel.SOCIAL_MEDIA_ID,
                titleTextResId = R.string.social_notification_channel_label,
                icon = com.android.settingslib.R.drawable.ic_social,
            )
        val NEWS =
            BundleSpec(
                key = NotificationChannel.NEWS_ID,
                titleTextResId = R.string.news_notification_channel_label,
                icon = com.android.settingslib.R.drawable.ic_news,
            )
        val RECOMMENDED =
            BundleSpec(
                key = NotificationChannel.RECS_ID,
                titleTextResId = R.string.recs_notification_channel_label,
                icon = com.android.settingslib.R.drawable.ic_recs,
            )
        val DEBUG =
            BundleSpec(
                key = "debug_bundle",
                titleTextResId = R.string.notification_channel_developer,
                icon = com.android.systemui.res.R.drawable.ic_person,
            )
    }
}
+3 −7
Original line number Diff line number Diff line
@@ -17,22 +17,18 @@
package com.android.systemui.statusbar.notification.row.data.repository

import android.graphics.drawable.Drawable
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue

/** Holds information about a BundleEntry that is relevant to UI. */
class BundleRepository(@StringRes titleTextResId: Int) {

    var titleTextResId by mutableIntStateOf(titleTextResId)
class BundleRepository(@StringRes val titleTextResId: Int, @DrawableRes val bundleIcon: Int) {

    var numberOfChildren by mutableStateOf<Int?>(0)

    var hasUnreadMessages by mutableStateOf(true)

    var bundleIcon by mutableStateOf<Drawable?>(null)
    var hasUnreadMessages by mutableStateOf(false)

    var previewIcons by mutableStateOf(listOf<Drawable>())
}
+1 −1
Original line number Diff line number Diff line
@@ -3148,7 +3148,7 @@ class TestBundler extends NotifBundler {

    public static final TestBundler INSTANCE = new TestBundler();

    List<BundleSpec> mBundleSpecs = List.of(new BundleSpec("bundle_1",0));
    List<BundleSpec> mBundleSpecs = List.of(new BundleSpec("bundle_1",0, 0));

    List<String> mBundleIds = this.mBundleSpecs.stream()
            .map(BundleSpec::getKey)
Loading