NotificationViewModel

A ViewModel that provides the information to show within a NotificationFragment.

The notification template is divided in several sections. Each section can be populated by its own data field in this ViewModel. A section is only visible if its view model is set.

There are two view variants of the notification, a narrow one and a wide one. Depending on whether the panel is shown in the notification center, the header description will include the date/time and the close icon will be visible. In the schematic overview below both are marked with an asterisk (*).

A schematic overview of the narrow notification template:

                   Header section                Close section
__________________________________________________________
| _____ | |
| | | Header title | Close icon (*) |
| | | Header description | [X] |
| |_____| Header time (*) | |
|_________________________________________|________________|
| |
| Body text | Body section
|__________________________________________________________|
| ___________________ ____________________ |
| | | | | |
| | Primary button | | Secondary button | | Button section
| |___________________| |____________________| |
|__________________________________________________________|
| __ | |
| |__| | Option 1 |
|________|_________________________________________________|
| __ | |
| |__| | Option 2 | Options section
|________|_________________________________________________|
| __ | |
| |__| | Option N |
|________|_________________________________________________|

A schematic overview of the wide notification template:

          Header section                             Button section                 Close section
______________________________________________________________________________________________
| _____ | ________________ __________________ | |
| | | Header title | | | | | | Close icon (*) |
| | | Header description | | Primary button | | Secondary button | | [X] |
| |_____| Header time (*) | |________________| |__________________| | |
|_________________________________|___________________________________________|________________|
| | |
| | Body text |
|____________|_________________________________________________________________________________|
| | __ | |
| | |__| | Option 1 |
|____________|________|________________________________________________________________________|
| | __ | |
| | |__| | Option 2 |
|____________|________|________________________________________________________________________|
| | __ | |
| | |__| | Option N |
|____________|________|________________________________________________________________________|

The header section gives the user a context on the notifications appearing (e.g. someone's calling, car warning, etc.). The body section is used to provide a description of a notification. The button section provides the user the ability to act upon the notification (if applicable). The options section provides the user a set of extra options to choose from (e.g. send quick replies, multiple options given by VPA, etc.).

Parameters

P

The type of the panel.

panel

The NotificationPanel of type P that hosts this NotificationViewModel.

Inheritors

Constructors

Link copied to clipboard
constructor(panel: P)

Types

Link copied to clipboard
open class HeaderViewModel(val imageDescriptor: LiveData<ImageDescriptor?> = EmptyLiveData(), val title: LiveData<StringResolver?> = EmptyLiveData(), val description: LiveData<StringResolver?> = EmptyLiveData())

A view model used to populate the header section of the notification template. The header summarizes the main contents of the notification. E.g., the image and the name of the contact of an incoming call.

Link copied to clipboard
open class OptionViewModel(val imageDescriptor: LiveData<ImageDescriptor?> = EmptyLiveData(), val description: LiveData<StringResolver?> = EmptyLiveData(), val onClick: LiveData<() -> Unit?> = EmptyLiveData())

A view model be used to populate one item in the options section.

Properties

Link copied to clipboard
open val bodyText: LiveData<StringResolver?>

The text shown in the body section.

Link copied to clipboard
open val creationTime: LiveData<StringResolver>

The text shown in the creation time section. By default it returns RelativeTimeSpanStringResolver of the panel's creation time.

Link copied to clipboard

The view model for the header section containing the thumbnail, title and description.

Link copied to clipboard

The view models for options in the options section. Each view model populates an additional item in the options section. Each item represents one option a user can choose from(e.g. send quick replies, an option given by VPA, etc.).

Link copied to clipboard
open val primaryActionButtonViewModel: LiveData<TtButtonViewModel?>

The view model for the primary button in the button section.

Link copied to clipboard
open val secondaryActionButtonViewModel: LiveData<TtButtonViewModel?>

The view model for the secondary action button in the button section.

Inherited properties

Link copied to clipboard
Link copied to clipboard
override val lifecycle: Lifecycle
Link copied to clipboard
open override val panel: P

Functions

Link copied to clipboard

The close button click callback. Dismisses the notification panel.

Inherited functions

Link copied to clipboard