UiMediaScope


A receiver scope that provides access to the properties of the current media environment. This scope is used by mediaQuery to evaluate conditions based on the device and window state.

Summary

Nested types

Describes the kind of keyboard available.

Describes the precision of the available pointing devices.

Describes the posture of the window, typically on a foldable device.

Describes the typical distance between the user and the screen.

Public properties

Boolean

Whether the camera is supported on the current device.

Cmn
Boolean

Whether the microphone is supported on the current device.

Cmn
UiMediaScope.KeyboardKind

The type of keyboard currently available or connected.

Cmn
UiMediaScope.PointerPrecision

The highest-precision pointing device currently available.

Cmn
UiMediaScope.ViewingDistance

The typical distance between the user and the device screen.

Cmn
Dp

The current height of the application window.

Cmn
UiMediaScope.Posture

The current posture of the application window.

Cmn
Dp

The current width of the application window.

Cmn

Public properties

hasCamera

val hasCamera: Boolean

Whether the camera is supported on the current device.

hasMicrophone

val hasMicrophone: Boolean

Whether the microphone is supported on the current device.

keyboardKind

val keyboardKind: UiMediaScope.KeyboardKind

The type of keyboard currently available or connected.

This property prioritizes a physical keyboard connection (KeyboardKind.Physical) over an on-screen soft keyboard (KeyboardKind.Virtual). If neither is detected, it returns KeyboardKind.None.

pointerPrecision

val pointerPrecision: UiMediaScope.PointerPrecision

The highest-precision pointing device currently available.

This property resolves the pointer type based on all connected input devices, prioritizing higher precision (e.g., PointerPrecision.Fine takes precedence over PointerPrecision.Coarse if both are present). See PointerPrecision for all possible values.

viewingDistance

val viewingDistance: UiMediaScope.ViewingDistance

The typical distance between the user and the device screen.

This property provides an estimate of the viewing distance, which can be useful for adjusting UI scale, content density, or hit target sizes for better ergonomics and readability.

Note that this is a broad categorization and does not represent a precise physical measurement. It is based on the device type and its typical usage context.

windowHeight

val windowHeight: Dp

The current height of the application window.

windowPosture

val windowPosture: UiMediaScope.Posture

The current posture of the application window.

This reflects how the window is laid out on the screen, which may be affected by the device's physical state. See Posture for possible values.

windowWidth

val windowWidth: Dp

The current width of the application window.