Package-level declarations

Types

Link copied to clipboard
sealed interface AmbientState
Link copied to clipboard
data class AmbientStateUpdate(val ambientState: AmbientState, val changeTimeMillis: Long = System.currentTimeMillis())

Represent Ambient as updates, with the state and time of change. This is necessary to ensure that when the system provides a (typically) 1min-frequency callback to onUpdateAmbient, the developer may wish to update composables, but the state hasn't changed.

Functions

Link copied to clipboard
fun AmbientAware(isAlwaysOnScreen: Boolean = true, block: @Composable (AmbientStateUpdate) -> Unit)

Composable for general handling of changes and updates to ambient status. A new AmbientStateUpdate is generated with any change of ambient state, as well as with any periodic update generated whilst the screen is in ambient mode.

Link copied to clipboard
@RequiresApi(value = 26)
fun AmbientAwareTime(stateUpdate: AmbientStateUpdate, updatePeriodMillis: Long = 1000, block: @Composable (dateTime: ZonedDateTime, isAmbient: Boolean) -> Unit)

An example of using AmbientAware: Provides the time, at the specified update frequency, whilst in interactive mode, or when ambient-generated updates occur (typically every 1 min).