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

Commit fdb74fe8 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge changes from topic "mShouldForceThemeIconProtected" into main

* changes:
  [AOD RONs] Update small icon bg and padding for app icons
  [AOD RONs] Extract skeleton app icons
  Set shouldForceThemeIcon = true in app icon factory
parents 7be12110 c326b5be
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager.REDACTIO
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder
import com.android.systemui.statusbar.notification.promoted.AutomaticPromotionCoordinator.Companion.EXTRA_WAS_AUTOMATICALLY_PROMOTED
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Style
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.When
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModels
@@ -669,7 +668,10 @@ class PromotedNotificationContentExtractorImplTest : SysuiTestCase() {
        if (notif.creationTime != 0L) {
            notif.creationTime = systemClock.currentTimeMillis()
        }
        return NotificationEntryBuilder().setNotification(notif).build()
        return NotificationEntryBuilder()
            .setPkg("com.android.systemui") // use a real package name, since we're fetching icons
            .setNotification(notif)
            .build()
    }

    companion object {
+36 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Flags.notificationsRedesignTemplates
import android.app.Notification
import android.content.Context
import android.graphics.PorterDuff
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.util.Log
import android.view.LayoutInflater
@@ -304,6 +305,10 @@ private class AODPromotedNotificationViewUpdater(root: View) {
                0
            }

    private data class SmallIconSavedState(val background: Drawable?, val padding: Rect)

    private var smallIconSavedState: SmallIconSavedState? = null

    init {
        // Hide views that are never visible in the skeleton promoted notification.
        alternateExpandTarget?.visibility = GONE
@@ -555,10 +560,10 @@ private class AODPromotedNotificationViewUpdater(root: View) {
    ) {
        smallIconView ?: return

        // TODO: set/clear padding, background, etc. depending on icon type.

        when (notifIcon) {
            is PromotedNotificationContentModel.NotifIcon.SmallIcon -> {
                restoreNotifIconState(smallIconView)

                // Icon binding must be called in this order
                updateImageView(smallIconView, notifIcon.imageModel)
                smallIconView.setImageLevel(iconLevel)
@@ -567,6 +572,9 @@ private class AODPromotedNotificationViewUpdater(root: View) {
            }

            is PromotedNotificationContentModel.NotifIcon.AppIcon -> {
                saveNotifIconState(smallIconView)
                resetNotifIconState(smallIconView)

                updateImageView(smallIconView, notifIcon.drawable)
            }

@@ -576,6 +584,32 @@ private class AODPromotedNotificationViewUpdater(root: View) {
        }
    }

    private fun saveNotifIconState(smallIconView: CachingIconView) {
        smallIconSavedState == null || return

        smallIconSavedState =
            smallIconView.let {
                SmallIconSavedState(
                    background = it.background,
                    padding = Rect(it.paddingLeft, it.paddingTop, it.paddingRight, it.paddingBottom),
                )
            }
    }

    private fun resetNotifIconState(smallIconView: CachingIconView) {
        smallIconView.background = null
        smallIconView.setPadding(0, 0, 0, 0)
    }

    private fun restoreNotifIconState(smallIconView: CachingIconView) {
        val savedState = smallIconSavedState ?: return

        smallIconView.background = savedState.background
        savedState.padding.let { smallIconView.setPadding(it.left, it.top, it.right, it.bottom) }

        smallIconSavedState = null
    }

    private fun inflateChronometer() {
        if (chronometer != null) {
            return
+22 −7
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.app.Notification.ProgressStyle
import android.app.Person
import android.content.Context
import android.graphics.drawable.Icon
import android.service.notification.StatusBarNotification
import com.android.systemui.Flags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.shade.ShadeDisplayAware
@@ -47,10 +48,13 @@ import com.android.systemui.statusbar.notification.promoted.AutomaticPromotionCo
import com.android.systemui.statusbar.notification.promoted.AutomaticPromotionCoordinator.Companion.EXTRA_WAS_AUTOMATICALLY_PROMOTED
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Companion.isPromotedForStatusBarChip
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.NotifIcon
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.OldProgress
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Style
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.When
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModels
import com.android.systemui.statusbar.notification.row.icon.AppIconProvider
import com.android.systemui.statusbar.notification.row.icon.NotificationIconStyleProvider
import com.android.systemui.statusbar.notification.row.shared.ImageModel
import com.android.systemui.statusbar.notification.row.shared.ImageModelProvider
import com.android.systemui.statusbar.notification.row.shared.ImageModelProvider.ImageSizeClass.MediumSquare
@@ -73,6 +77,8 @@ class PromotedNotificationContentExtractorImpl
@Inject
constructor(
    @ShadeDisplayAware private val context: Context,
    private val notificationIconStyleProvider: NotificationIconStyleProvider,
    private val appIconProvider: AppIconProvider,
    private val skeletonImageTransform: SkeletonImageTransform,
    private val systemClock: SystemClock,
    private val logger: PromotedNotificationLogger,
@@ -109,7 +115,7 @@ constructor(
        val privateVersion =
            extractPrivateContent(
                key = entry.key,
                notification = notification,
                sbn = entry.sbn,
                recoveredBuilder = recoveredBuilder,
                lastAudiblyAlertedMs = entry.lastAudiblyAlertedMs,
                imageModelProvider = imageModelProvider,
@@ -189,11 +195,12 @@ constructor(

    private fun extractPrivateContent(
        key: String,
        notification: Notification,
        sbn: StatusBarNotification,
        recoveredBuilder: Notification.Builder,
        lastAudiblyAlertedMs: Long,
        imageModelProvider: ImageModelProvider,
    ): PromotedNotificationContentModel {
        val notification = sbn.notification

        val contentBuilder = PromotedNotificationContentModel.Builder(key)

@@ -202,10 +209,10 @@ constructor(

        contentBuilder.wasPromotedAutomatically =
            notification.extras.getBoolean(EXTRA_WAS_AUTOMATICALLY_PROMOTED, false)

        contentBuilder.skeletonNotifIcon =
            notification.smallIconModel(imageModelProvider)?.let {
                PromotedNotificationContentModel.NotifIcon.SmallIcon(it)
            }
            sbn.skeletonAppIcon() ?: notification.skeletonSmallIcon(imageModelProvider)

        contentBuilder.iconLevel = notification.iconLevel
        contentBuilder.appName = notification.loadHeaderAppName(context)
        contentBuilder.subText = notification.subText()
@@ -230,8 +237,16 @@ constructor(
        return contentBuilder.build()
    }

    private fun Notification.smallIconModel(imageModelProvider: ImageModelProvider): ImageModel? =
        imageModelProvider.getImageModel(smallIcon, SmallSquare)
    private fun Notification.skeletonSmallIcon(
        imageModelProvider: ImageModelProvider
    ): NotifIcon.SmallIcon? =
        imageModelProvider.getImageModel(smallIcon, SmallSquare)?.let { NotifIcon.SmallIcon(it) }

    private fun StatusBarNotification.skeletonAppIcon(): NotifIcon.AppIcon? {
        if (!android.app.Flags.notificationsRedesignAppIcons()) return null
        if (!notificationIconStyleProvider.shouldShowAppIcon(this, context)) return null
        return NotifIcon.AppIcon(appIconProvider.getOrFetchSkeletonAppIcon(packageName, context))
    }

    private fun Notification.title(): CharSequence? = getCharSequenceExtraUnlessEmpty(EXTRA_TITLE)

+4 −2
Original line number Diff line number Diff line
@@ -109,13 +109,14 @@ constructor(@ShadeDisplayAware private val sysuiContext: Context, dumpManager: D
                // Initialize the controller so that we can support themed icons.
                mThemeController =
                    MonoIconThemeController(
                        shouldForceThemeIcon = true,
                        colorProvider = { ctx ->
                            val res = ctx.resources
                            intArrayOf(
                                /* background */ res.getColor(R.color.materialColorPrimary),
                                /* icon */ res.getColor(R.color.materialColorSurfaceContainerHigh),
                            )
                        }
                        },
                    )
            }
        }
@@ -129,9 +130,10 @@ constructor(@ShadeDisplayAware private val sysuiContext: Context, dumpManager: D
        init {
            mThemeController =
                MonoIconThemeController(
                    shouldForceThemeIcon = true,
                    colorProvider = { _ ->
                        intArrayOf(/* background */ Color.BLACK, /* icon */ Color.WHITE)
                    }
                    },
                )
        }
    }
+4 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import com.android.systemui.kosmos.Kosmos
import com.android.systemui.statusbar.NotificationLockscreenUserManager.REDACTION_TYPE_PUBLIC
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.row.RowImageInflater
import com.android.systemui.statusbar.notification.row.icon.appIconProvider
import com.android.systemui.statusbar.notification.row.icon.notificationIconStyleProvider
import com.android.systemui.statusbar.notification.row.shared.skeletonImageTransform
import com.android.systemui.util.time.systemClock

@@ -29,6 +31,8 @@ var Kosmos.promotedNotificationContentExtractor by
    Kosmos.Fixture {
        PromotedNotificationContentExtractorImpl(
            applicationContext,
            notificationIconStyleProvider,
            appIconProvider,
            skeletonImageTransform,
            systemClock,
            promotedNotificationLogger,
Loading