Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/AODPromotedNotification.kt +31 −13 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.Flags.notificationsRedesignTemplates import android.app.Notification import android.content.Context import android.graphics.PorterDuff import android.graphics.drawable.Drawable import android.util.Log import android.view.LayoutInflater import android.view.NotificationTopLineView Loading Loading @@ -63,7 +64,6 @@ import com.android.internal.widget.ImageFloatingTextView import com.android.internal.widget.NotificationExpandButton import com.android.internal.widget.NotificationProgressBar import com.android.internal.widget.NotificationProgressModel import com.android.internal.widget.NotificationRowIconView import com.android.systemui.lifecycle.rememberViewModel import com.android.systemui.res.R as systemuiR import com.android.systemui.statusbar.notification.promoted.AodPromotedNotificationColor.Background Loading Loading @@ -259,7 +259,7 @@ private class AODPromotedNotificationViewUpdater(root: View) { private val headerTextSecondary: TextView? = root.findViewById(R.id.header_text_secondary) private val headerTextSecondaryDivider: TextView? = root.findViewById(R.id.header_text_secondary_divider) private val icon: NotificationRowIconView? = root.findViewById(R.id.icon) private val icon: CachingIconView? = root.findViewById(R.id.icon) private val leftIcon: ImageView? = root.findViewById(R.id.left_icon) private val mainColumn: View? = root.findViewById(R.id.notification_main_column) private val notificationProgressEndIcon: CachingIconView? = Loading Loading @@ -372,7 +372,7 @@ private class AODPromotedNotificationViewUpdater(root: View) { updateTitle(title, content) } updateText(textView, content) updateSmallIcon(icon, content) updateNotifIcon(icon, content.skeletonNotifIcon, content.iconLevel) updateImageView(rightIcon, content.skeletonLargeIcon) updateOldProgressBar(content) } Loading Loading @@ -487,7 +487,7 @@ private class AODPromotedNotificationViewUpdater(root: View) { updateTopLine(content) updateSmallIcon(conversationIcon, content) updateNotifIcon(conversationIcon, content.skeletonNotifIcon, content.iconLevel) updateTitle(conversationText, content) } Loading Loading @@ -548,19 +548,34 @@ private class AODPromotedNotificationViewUpdater(root: View) { chronometer?.isVisible = (content.time is When.Chronometer) } private fun updateSmallIcon( private fun updateNotifIcon( smallIconView: CachingIconView?, content: PromotedNotificationContentModel, notifIcon: PromotedNotificationContentModel.NotifIcon?, iconLevel: Int, ) { smallIconView ?: return // TODO: set/clear padding, background, etc. depending on icon type. when (notifIcon) { is PromotedNotificationContentModel.NotifIcon.SmallIcon -> { // Icon binding must be called in this order updateImageView(smallIconView, content.smallIcon) smallIconView.setImageLevel(content.iconLevel) updateImageView(smallIconView, notifIcon.imageModel) smallIconView.setImageLevel(iconLevel) smallIconView.setBackgroundColor(Background.colorInt) smallIconView.originalIconColor = PrimaryText.colorInt } is PromotedNotificationContentModel.NotifIcon.AppIcon -> { updateImageView(smallIconView, notifIcon.drawable) } else -> { smallIconView.isVisible = false } } } private fun inflateChronometer() { if (chronometer != null) { return Loading Loading @@ -607,8 +622,11 @@ private class AODPromotedNotificationViewUpdater(root: View) { } private fun updateImageView(view: ImageView?, model: ImageModel?) { if (view == null) return val drawable = model?.drawable updateImageView(view, model?.drawable) } private fun updateImageView(view: ImageView?, drawable: Drawable?) { view ?: return view.setImageDrawable(drawable) view.isVisible = drawable != null } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/PromotedNotificationContentExtractor.kt +5 −2 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ constructor( privateModel: PromotedNotificationContentModel, publicBuilder: PromotedNotificationContentModel.Builder, ) { publicBuilder.smallIcon = privateModel.smallIcon publicBuilder.skeletonNotifIcon = privateModel.skeletonNotifIcon publicBuilder.iconLevel = privateModel.iconLevel publicBuilder.appName = privateModel.appName publicBuilder.time = privateModel.time Loading Loading @@ -196,7 +196,10 @@ constructor( contentBuilder.wasPromotedAutomatically = notification.extras.getBoolean(EXTRA_WAS_AUTOMATICALLY_PROMOTED, false) contentBuilder.smallIcon = notification.smallIconModel(imageModelProvider) contentBuilder.skeletonNotifIcon = notification.smallIconModel(imageModelProvider)?.let { PromotedNotificationContentModel.NotifIcon.SmallIcon(it) } contentBuilder.iconLevel = notification.iconLevel contentBuilder.appName = notification.loadHeaderAppName(context) contentBuilder.subText = notification.subText() Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/shared/model/PromotedNotificationContentModel.kt +18 −7 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.annotation.CurrentTimeMillisLong import android.annotation.DrawableRes import android.annotation.ElapsedRealtimeLong import android.app.Notification import android.app.Notification.FLAG_PROMOTED_ONGOING import android.graphics.drawable.Drawable import androidx.annotation.ColorInt import com.android.internal.widget.NotificationProgressModel import com.android.systemui.Flags Loading Loading @@ -67,7 +67,7 @@ data class PromotedNotificationContentModel( * True if this notification was automatically promoted - see [AutomaticPromotionCoordinator]. */ val wasPromotedAutomatically: Boolean, val smallIcon: ImageModel?, val skeletonNotifIcon: NotifIcon?, val iconLevel: Int, val appName: CharSequence?, val subText: CharSequence?, Loading Loading @@ -95,7 +95,7 @@ data class PromotedNotificationContentModel( ) { class Builder(val key: String) { var wasPromotedAutomatically: Boolean = false var smallIcon: ImageModel? = null var skeletonNotifIcon: NotifIcon? = null var iconLevel: Int = 0 var appName: CharSequence? = null var subText: CharSequence? = null Loading @@ -121,7 +121,7 @@ data class PromotedNotificationContentModel( PromotedNotificationContentModel( identity = Identity(key, style), wasPromotedAutomatically = wasPromotedAutomatically, smallIcon = smallIcon, skeletonNotifIcon = skeletonNotifIcon, iconLevel = iconLevel, appName = appName, subText = subText, Loading @@ -143,6 +143,12 @@ data class PromotedNotificationContentModel( data class Identity(val key: String, val style: Style) sealed class NotifIcon { data class SmallIcon(val imageModel: ImageModel) : NotifIcon() data class AppIcon(val drawable: Drawable) : NotifIcon() } /** The timestamp associated with a notification, along with the mode used to display it. */ sealed class When { /** Show the notification's time as a timestamp. */ Loading Loading @@ -180,7 +186,7 @@ data class PromotedNotificationContentModel( return ("PromotedNotificationContentModel(" + "identity=$identity, " + "wasPromotedAutomatically=$wasPromotedAutomatically, " + "smallIcon=${smallIcon?.toRedactedString()}, " + "skeletonNotifIcon=${skeletonNotifIcon?.toRedactedString()}, " + "appName=$appName, " + "subText=${subText?.toRedactedString()}, " + "shortCriticalText=$shortCriticalText, " + Loading @@ -200,6 +206,12 @@ data class PromotedNotificationContentModel( private fun CharSequence.toRedactedString(): String = "[$length]" private fun NotifIcon.toRedactedString(): String = when (this) { is NotifIcon.SmallIcon -> "SmallIcon(${imageModel.toRedactedString()})" is NotifIcon.AppIcon -> "AppIcon([${drawable.javaClass.simpleName}])" } private fun ImageModel.toRedactedString(): String { return when (this) { is LazyImage -> this.toRedactedString() Loading @@ -223,8 +235,7 @@ data class PromotedNotificationContentModel( } companion object { @JvmStatic fun featureFlagEnabled(): Boolean = PromotedNotificationUi.isEnabled @JvmStatic fun featureFlagEnabled(): Boolean = PromotedNotificationUi.isEnabled /** * Returns true if the given notification should be considered promoted when deciding Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/AODPromotedNotification.kt +31 −13 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.Flags.notificationsRedesignTemplates import android.app.Notification import android.content.Context import android.graphics.PorterDuff import android.graphics.drawable.Drawable import android.util.Log import android.view.LayoutInflater import android.view.NotificationTopLineView Loading Loading @@ -63,7 +64,6 @@ import com.android.internal.widget.ImageFloatingTextView import com.android.internal.widget.NotificationExpandButton import com.android.internal.widget.NotificationProgressBar import com.android.internal.widget.NotificationProgressModel import com.android.internal.widget.NotificationRowIconView import com.android.systemui.lifecycle.rememberViewModel import com.android.systemui.res.R as systemuiR import com.android.systemui.statusbar.notification.promoted.AodPromotedNotificationColor.Background Loading Loading @@ -259,7 +259,7 @@ private class AODPromotedNotificationViewUpdater(root: View) { private val headerTextSecondary: TextView? = root.findViewById(R.id.header_text_secondary) private val headerTextSecondaryDivider: TextView? = root.findViewById(R.id.header_text_secondary_divider) private val icon: NotificationRowIconView? = root.findViewById(R.id.icon) private val icon: CachingIconView? = root.findViewById(R.id.icon) private val leftIcon: ImageView? = root.findViewById(R.id.left_icon) private val mainColumn: View? = root.findViewById(R.id.notification_main_column) private val notificationProgressEndIcon: CachingIconView? = Loading Loading @@ -372,7 +372,7 @@ private class AODPromotedNotificationViewUpdater(root: View) { updateTitle(title, content) } updateText(textView, content) updateSmallIcon(icon, content) updateNotifIcon(icon, content.skeletonNotifIcon, content.iconLevel) updateImageView(rightIcon, content.skeletonLargeIcon) updateOldProgressBar(content) } Loading Loading @@ -487,7 +487,7 @@ private class AODPromotedNotificationViewUpdater(root: View) { updateTopLine(content) updateSmallIcon(conversationIcon, content) updateNotifIcon(conversationIcon, content.skeletonNotifIcon, content.iconLevel) updateTitle(conversationText, content) } Loading Loading @@ -548,19 +548,34 @@ private class AODPromotedNotificationViewUpdater(root: View) { chronometer?.isVisible = (content.time is When.Chronometer) } private fun updateSmallIcon( private fun updateNotifIcon( smallIconView: CachingIconView?, content: PromotedNotificationContentModel, notifIcon: PromotedNotificationContentModel.NotifIcon?, iconLevel: Int, ) { smallIconView ?: return // TODO: set/clear padding, background, etc. depending on icon type. when (notifIcon) { is PromotedNotificationContentModel.NotifIcon.SmallIcon -> { // Icon binding must be called in this order updateImageView(smallIconView, content.smallIcon) smallIconView.setImageLevel(content.iconLevel) updateImageView(smallIconView, notifIcon.imageModel) smallIconView.setImageLevel(iconLevel) smallIconView.setBackgroundColor(Background.colorInt) smallIconView.originalIconColor = PrimaryText.colorInt } is PromotedNotificationContentModel.NotifIcon.AppIcon -> { updateImageView(smallIconView, notifIcon.drawable) } else -> { smallIconView.isVisible = false } } } private fun inflateChronometer() { if (chronometer != null) { return Loading Loading @@ -607,8 +622,11 @@ private class AODPromotedNotificationViewUpdater(root: View) { } private fun updateImageView(view: ImageView?, model: ImageModel?) { if (view == null) return val drawable = model?.drawable updateImageView(view, model?.drawable) } private fun updateImageView(view: ImageView?, drawable: Drawable?) { view ?: return view.setImageDrawable(drawable) view.isVisible = drawable != null } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/PromotedNotificationContentExtractor.kt +5 −2 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ constructor( privateModel: PromotedNotificationContentModel, publicBuilder: PromotedNotificationContentModel.Builder, ) { publicBuilder.smallIcon = privateModel.smallIcon publicBuilder.skeletonNotifIcon = privateModel.skeletonNotifIcon publicBuilder.iconLevel = privateModel.iconLevel publicBuilder.appName = privateModel.appName publicBuilder.time = privateModel.time Loading Loading @@ -196,7 +196,10 @@ constructor( contentBuilder.wasPromotedAutomatically = notification.extras.getBoolean(EXTRA_WAS_AUTOMATICALLY_PROMOTED, false) contentBuilder.smallIcon = notification.smallIconModel(imageModelProvider) contentBuilder.skeletonNotifIcon = notification.smallIconModel(imageModelProvider)?.let { PromotedNotificationContentModel.NotifIcon.SmallIcon(it) } contentBuilder.iconLevel = notification.iconLevel contentBuilder.appName = notification.loadHeaderAppName(context) contentBuilder.subText = notification.subText() Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/shared/model/PromotedNotificationContentModel.kt +18 −7 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.annotation.CurrentTimeMillisLong import android.annotation.DrawableRes import android.annotation.ElapsedRealtimeLong import android.app.Notification import android.app.Notification.FLAG_PROMOTED_ONGOING import android.graphics.drawable.Drawable import androidx.annotation.ColorInt import com.android.internal.widget.NotificationProgressModel import com.android.systemui.Flags Loading Loading @@ -67,7 +67,7 @@ data class PromotedNotificationContentModel( * True if this notification was automatically promoted - see [AutomaticPromotionCoordinator]. */ val wasPromotedAutomatically: Boolean, val smallIcon: ImageModel?, val skeletonNotifIcon: NotifIcon?, val iconLevel: Int, val appName: CharSequence?, val subText: CharSequence?, Loading Loading @@ -95,7 +95,7 @@ data class PromotedNotificationContentModel( ) { class Builder(val key: String) { var wasPromotedAutomatically: Boolean = false var smallIcon: ImageModel? = null var skeletonNotifIcon: NotifIcon? = null var iconLevel: Int = 0 var appName: CharSequence? = null var subText: CharSequence? = null Loading @@ -121,7 +121,7 @@ data class PromotedNotificationContentModel( PromotedNotificationContentModel( identity = Identity(key, style), wasPromotedAutomatically = wasPromotedAutomatically, smallIcon = smallIcon, skeletonNotifIcon = skeletonNotifIcon, iconLevel = iconLevel, appName = appName, subText = subText, Loading @@ -143,6 +143,12 @@ data class PromotedNotificationContentModel( data class Identity(val key: String, val style: Style) sealed class NotifIcon { data class SmallIcon(val imageModel: ImageModel) : NotifIcon() data class AppIcon(val drawable: Drawable) : NotifIcon() } /** The timestamp associated with a notification, along with the mode used to display it. */ sealed class When { /** Show the notification's time as a timestamp. */ Loading Loading @@ -180,7 +186,7 @@ data class PromotedNotificationContentModel( return ("PromotedNotificationContentModel(" + "identity=$identity, " + "wasPromotedAutomatically=$wasPromotedAutomatically, " + "smallIcon=${smallIcon?.toRedactedString()}, " + "skeletonNotifIcon=${skeletonNotifIcon?.toRedactedString()}, " + "appName=$appName, " + "subText=${subText?.toRedactedString()}, " + "shortCriticalText=$shortCriticalText, " + Loading @@ -200,6 +206,12 @@ data class PromotedNotificationContentModel( private fun CharSequence.toRedactedString(): String = "[$length]" private fun NotifIcon.toRedactedString(): String = when (this) { is NotifIcon.SmallIcon -> "SmallIcon(${imageModel.toRedactedString()})" is NotifIcon.AppIcon -> "AppIcon([${drawable.javaClass.simpleName}])" } private fun ImageModel.toRedactedString(): String { return when (this) { is LazyImage -> this.toRedactedString() Loading @@ -223,8 +235,7 @@ data class PromotedNotificationContentModel( } companion object { @JvmStatic fun featureFlagEnabled(): Boolean = PromotedNotificationUi.isEnabled @JvmStatic fun featureFlagEnabled(): Boolean = PromotedNotificationUi.isEnabled /** * Returns true if the given notification should be considered promoted when deciding Loading