feature/notification/docs/notification-styles.md
During the creation of a SystemNotification implementation, you can decide if you want to have a custom look by
overriding the systemNotificationStyle property.
By default, all System notifications are displayed by showing:
Meaning that its style is always Undefined (Basic notification), unless specified.
We currently support the following styles:
Undefined (default)BigTextStyleInboxStyleNext, we will show how to define each of the custom styles with examples.
BigTextStyle:
The BigTextStyle allows the app to display a larger block of text in the expanded content area of the notification.
The following code is how to define the System Notification with the BigTextStyle as its style:
data class NewMailSingleMail(
// 1.
override val accountUuid: String,
val accountName: String,
val summary: String,
val sender: String,
val subject: String,
val preview: String,
// 2.
override val icon: NotificationIcon = NotificationIcons.NewMailSingleMail,
) : MailNotification() {
// 3.
override val title: String = sender
// 4.
override val contentText: String = subject
// 5.
override val systemNotificationStyle: SystemNotificationStyle =
systemNotificationStyle {
bigText(preview)
}
}
title property is used to display the first text line in the notification, which we choose to be the sender
this timecontentText property is used to display the notification's content text when the notification is in the
collapsed modepreview String as a
parameter, which is used to display the notification's content text when the notification is in the expanded modeSystem Notification with BigTextStyle collapsed:
System Notification with BigTextStyle expanded:
[!IMPORTANT] The System Notification UI may vary between Android OS versions and OEMs, but in general, they will always have the same look and feel, with some differences.
The above screenshots were taken using Android 16 and a Pixel 7 Pro.
InboxStyle:
The InboxStyle is designed to be used when we need to display multiple short summary lines, such as snippets from
incoming emails, grouping them all into one notification.
The following code is how to define the System Notification with the InboxStyle as its style:
@ConsistentCopyVisibility
data class NewMailSummaries private constructor(
override val accountUuid: String,
// 1.1.
override val title: String,
// 1.2.
override val contentText: String,
// 2.1
val expandedTitle: String,
// 2.2
val summary: String,
// 2.3
val lines: List<String>,
// 3.
override val icon: NotificationIcon = NotificationIcons.NewMailSummaries,
) : MailNotification() {
// 4.
override val systemNotificationStyle: SystemNotificationStyle = systemNotificationStyle {
inbox {
title(expandedTitle)
summary(summary)
lines(lines = lines.toTypedArray())
}
}
// 5.
companion object {
suspend operator fun invoke(
accountUuid: String,
accountDisplayName: String,
previews: List<String>,
): NewMailSummaries = NewMailSummaries(
accountUuid = accountUuid,
title = getPluralString(
resource = Res.strings.new_mail_summaries_collapsed_title,
quantity = messageSummaries.size,
messageSummaries.size,
accountDisplayName,
),
contentText = getString(Res.strings.new_mail_summaries_content_text),
expandedTitle = getPluralString(
resource = Res.strings.new_mail_summaries_expanded_title,
quantity = messageSummaries.size,
messageSummaries.size,
),
summary = getString(
resource = Res.strings.new_mail_summaries_additional_messages,
messageSummaries.size,
accountDisplayName,
),
lines = previews,
)
}
}
<resources>
<plurals name="new_mail_summaries_collapsed_title">
<item quantity="one">You've received %1$d new message on %2$s</item>
<item quantity="other">You've received %1$d new messages on %2$s</item>
</plurals>
<string name="new_mail_summaries_content_text">Expand to preview</string>
<plurals name="new_mail_summaries_expanded_title">
<item quantity="one">%1$d new message</item>
<item quantity="other">%1$d new messages</item>
</plurals>
<string name="new_mail_summaries_additional_messages">+ %1$d more on %2$s</string>
</resources>
title property is used to display the first text line in the notification when the notification is
collapsedcontentText property is used to display the notification's content text when the notification is in the
collapsed modeInboxStyle:
expandedTitle property is used to display the first text line in the notification when the notification is
expandedsummary property is used to display the notification's first line of text after the detail section in the
big form of the template.lines property is used to display the previews in the digest section of the Inbox notification.InboxStyle, via the systemNotificationStyle DSL
function, consuming all the data we received via the constructor.During the creation of an InAppNotification implementation, you need to choose how the notification will appear to the
user. Currently, we support the following in-app notification styles:
More In-App notification styles might be introduced in the future. If that happens, we will update this section.
| Error | Warning | Success | Info |
|---|---|---|---|
Used to maintain user awareness of a persistent, irregular state of the application without interrupting the primary
flow. This component is appropriate for warnings that apply globally across the app.
If the warning is caused by a critical error, a Banner Inline Notification should also be
shown in the relevant context (e.g., the message list) to guide direct resolution.
Use for:
Do not use for:
Use inline error banners to surface issues that must be resolved before the user can continue with the main task or content on the screen.
Use for:
Do not use for:
Snackbars are used to inform the user of an error or process outcome, and may optionally offer
a related action. They appear temporarily without interrupting the user's current task.
Use for:
Used to inform the user about a required permission needed to enable or complete a key feature of the app.
The dialog provides a concise explanation of the need for the permission and prompts the user to grant it.
Use for:
Do not use for:
Depending on the Notification Severity, the behaviour of the notification will be different. That could also affect how the notification is displayed to the user. In this section we explain each style change based in the severity of the notification.
[!IMPORTANT]
Currently, the Notification severity only impacts the style of in-app notifications.
| Notification Style | Can use style | Changes | Screenshot |
|---|---|---|---|
| Banner Global | ✅ | The banner will use the error color scheme | |
| Banner Inline | ✅ | No style changes are expected for this style | |
| Snackbar | ❌ | ||
| Dialog | ✅ | No style changes are expected for this style |
| Notification Style | Can use style | Changes | Screenshot |
|---|---|---|---|
| Banner Global | ✅ | The banner will use the error color scheme | |
| Banner Inline | ✅ | No style changes are expected for this style | |
| Snackbar | ❌ | ||
| Dialog | ✅ | No style changes are expected for this style |
| Notification Style | Can use style | Changes | Screenshot |
|---|---|---|---|
| Banner Global | ✅ | The banner will use the warning color scheme | |
| Banner Inline | ❌ | ||
| Snackbar | ✅ | No style changes are expected for this style | |
| Dialog | ❌ |
| Notification Style | Can use style | Changes | Screenshot |
|---|---|---|---|
| Banner Global | ✅ | The banner will use the information color scheme | |
| Banner Inline | ❌ | ||
| Snackbar | ✅ | No style changes are expected for this style | |
| Dialog | ❌ |
| Notification Style | Can use style | Changes | Screenshot |
|---|---|---|---|
| Banner Global | ✅ | The banner will use the information color scheme | |
| Banner Inline | ❌ | ||
| Snackbar | ✅ | No style changes are expected for this style | |
| Dialog | ❌ |