NotificationViewModel

open class NotificationViewModel<P : NotificationPanel>(panel: P) : FrontendViewModel<P>

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.

A schematic overview of the notification template:

 __________________________________________________________
| _____ | |
| | | | Header title |
| | | | Header description | Header section
| |_____| | |
|___________|______________________________________________|
| |
| Body text | Body section
|__________________________________________________________|
| ___________________ | ____________________ |
| | | | | | |
| | Primary button | | | Secondary button | | Button section
| |___________________| | |____________________| |
|____________________________|_____________________________|
| __ | |
| |__| | Option 1 |
|________|_________________________________________________|
| __ | |
| |__| | Option 2 | Options section
|________|_________________________________________________|
| __ | |
| |__| | 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.

Constructors

Link copied to clipboard
fun <P : NotificationPanel> NotificationViewModel(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 headerViewModel: NotificationViewModel.HeaderViewModel? = null

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
val isSafetyLockEnabled: LiveData<Boolean>
Link copied to clipboard
val panel: P

Inherited functions

Link copied to clipboard
fun clear()
Link copied to clipboard
override fun getLifecycle(): Lifecycle
Link copied to clipboard
open fun <T : Any> getTag(p0: String): T
Link copied to clipboard
open fun <T : Any> setTagIfAbsent(p0: String, p1: T): T