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

Commit 7a4d2765 authored by Andreas Miko's avatar Andreas Miko Committed by Android (Google) Code Review
Browse files

Merge changes from topic "bundle-icon" into main

* changes:
  Enable easy and deterministic debug bundle
  Wire up BundleIcon
  Fix ConcurrentModificationException when dismissing bundled notifs
parents c415a5ce efea2f25
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
@@ -29,7 +29,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,
            )
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.service.notification.NotificationListenerService
import android.service.notification.StatusBarNotification
import com.android.internal.logging.MetricsLogger
import com.android.systemui.statusbar.notification.NotificationActivityStarter
import com.android.systemui.statusbar.notification.collection.coordinator.BundleCoordinator
import com.android.systemui.statusbar.notification.collection.coordinator.BundleCoordinator.Companion.debugBundleAppName
import com.android.systemui.statusbar.notification.collection.coordinator.VisualStabilityCoordinator
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifLifetimeExtender
import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider
@@ -270,7 +270,7 @@ class NotificationEntryAdapter(
    }

    override fun isBundled(): Boolean {
        return entry.isBundled || (BundleCoordinator.Companion.debugBundleUi && hasBundleParent())
        return entry.isBundled || (!debugBundleAppName.isNullOrEmpty() && hasBundleParent())
    }

    private fun hasBundleParent(): Boolean {
+2 −4
Original line number Diff line number Diff line
@@ -294,9 +294,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {

        mIdToBundleEntry.clear();
        for (BundleSpec spec : mNotifBundler.getBundleSpecs()) {
            if (BundleCoordinator.debugBundleUi) {
                Log.i(TAG, "create BundleEntry with id: " + spec.getKey());
            }
            debugBundleLog(TAG, () -> "create BundleEntry with id: " + spec.getKey());
            mIdToBundleEntry.put(spec.getKey(), new BundleEntry(spec));
        }
    }
@@ -722,7 +720,7 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
    }

    private void debugList(String s) {
        if (!BundleCoordinator.debugBundleUi) {
        if (!BundleCoordinator.debugBundleLogs) {
            return;
        }
        StringBuilder listStr = new StringBuilder();
Loading