1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar.notification.promoted.shared.model 18 19 import android.annotation.DrawableRes 20 import android.graphics.drawable.Icon 21 import com.android.internal.widget.NotificationProgressModel 22 import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips 23 import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi 24 25 /** 26 * The content needed to render a promoted notification to surfaces besides the notification stack, 27 * like the skeleton view on AOD or the status bar chip. 28 */ 29 data class PromotedNotificationContentModel( 30 val key: String, 31 32 // for all styles: 33 val skeletonSmallIcon: Icon?, // TODO(b/377568176): Make into an IconModel. 34 val appName: CharSequence?, 35 val subText: CharSequence?, 36 val time: When?, 37 val lastAudiblyAlertedMs: Long, 38 @DrawableRes val profileBadgeResId: Int?, 39 val title: CharSequence?, 40 val text: CharSequence?, 41 val skeletonLargeIcon: Icon?, // TODO(b/377568176): Make into an IconModel. 42 val style: Style, 43 44 // for CallStyle: 45 val personIcon: Icon?, // TODO(b/377568176): Make into an IconModel. 46 val personName: CharSequence?, 47 val verificationIcon: Icon?, // TODO(b/377568176): Make into an IconModel. 48 val verificationText: CharSequence?, 49 50 // for ProgressStyle: 51 val progress: NotificationProgressModel?, 52 ) { 53 class Builder(val key: String) { 54 var skeletonSmallIcon: Icon? = null 55 var appName: CharSequence? = null 56 var subText: CharSequence? = null 57 var time: When? = null 58 var lastAudiblyAlertedMs: Long = 0L 59 @DrawableRes var profileBadgeResId: Int? = null 60 var title: CharSequence? = null 61 var text: CharSequence? = null 62 var skeletonLargeIcon: Icon? = null 63 var style: Style = Style.Ineligible 64 65 // for CallStyle: 66 var personIcon: Icon? = null 67 var personName: CharSequence? = null 68 var verificationIcon: Icon? = null 69 var verificationText: CharSequence? = null 70 71 // for ProgressStyle: 72 var progress: NotificationProgressModel? = null 73 buildnull74 fun build() = 75 PromotedNotificationContentModel( 76 key = key, 77 skeletonSmallIcon = skeletonSmallIcon, 78 appName = appName, 79 subText = subText, 80 time = time, 81 lastAudiblyAlertedMs = lastAudiblyAlertedMs, 82 profileBadgeResId = profileBadgeResId, 83 title = title, 84 text = text, 85 skeletonLargeIcon = skeletonLargeIcon, 86 style = style, 87 personIcon = personIcon, 88 personName = personName, 89 verificationIcon = verificationIcon, 90 verificationText = verificationText, 91 progress = progress, 92 ) 93 } 94 95 /** The timestamp associated with a notification, along with the mode used to display it. */ 96 data class When(val time: Long, val mode: Mode) { 97 /** The mode used to display a notification's `when` value. */ 98 enum class Mode { 99 Absolute, 100 CountDown, 101 CountUp, 102 } 103 } 104 105 /** The promotion-eligible style of a notification, or [Style.Ineligible] if not. */ 106 enum class Style { 107 BigPicture, 108 BigText, 109 Call, 110 Progress, 111 Ineligible, 112 } 113 114 companion object { 115 @JvmStatic featureFlagEnablednull116 fun featureFlagEnabled(): Boolean = 117 PromotedNotificationUi.isEnabled || StatusBarNotifChips.isEnabled 118 } 119 } 120