Interface

UiMediaScope

A receiver scope that provides access to the properties of the current media environment.

Source set: Common
public interface 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.

Properties

windowPosture

Source set: Common
public val windowPosture: WindowPosture

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 WindowPosture for possible values.

windowWidth

Source set: Common
@get:FrequentlyChangingValue public val windowWidth: Dp

The current width of the application window.

windowHeight

Source set: Common
@get:FrequentlyChangingValue public val windowHeight: Dp

The current height of the application window.

pointerPrecision

Source set: Common
public val pointerPrecision: 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.

keyboardKind

Source set: Common
public val keyboardKind: 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.

hasMicrophone

Source set: Common
@get:Suppress("GetterSetterNames") public val hasMicrophone: Boolean

Whether the microphone is supported on the current device.

hasCamera

Source set: Common
@get:Suppress("GetterSetterNames") public val hasCamera: Boolean

Whether the camera is supported on the current device.

viewingDistance

Source set: Common
public val viewingDistance: 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.

Members

WindowFold

Source set: Common
public class WindowFold(public val state: FoldState, public val orientation: FoldOrientation)

Represents a single physical fold or hinge intersecting the window.

A WindowFold describes a geometric screen feature that actively crosses the bounds of the current window. It maps directly to the state of underlying hardware hinge sensors.

Parameters

state The geometric layout state of the fold (e.g. FoldState.Flat or FoldState.HalfOpened).
orientation The axis of the fold relative to the window bounds (e.g. FoldOrientation.Horizontal or FoldOrientation.Vertical).

WindowPosture

Source set: Common
public class WindowPosture(public val folds: List<WindowFold>)

Represents the overall physical posture of the window, aggregating all underlying hardware folding features into a unified state.

Note that this describes the window's state, which may differ from the physical device's posture. For example, if a foldable device is physically half-opened, but the current app is in split-screen mode entirely on one side of the hinge, the window is not intersected by the hinge and its posture will evaluate as isFlat == true.

Parameters

folds A list of all active WindowFold features intersecting the window.

Properties

isFlat

Source set: Common
public val isFlat: Boolean

Whether the physical footprint of the window has no active bends disrupting its surface.

This gracefully evaluates to true for traditional non-foldable slab devices, foldables that are completely opened to 180 degrees, and multi-window apps that do not span across a hinge.

isTabletop

Source set: Common
public val isTabletop: Boolean

Whether the device is in a semi-open tabletop state, similar to a laptop.

This evaluates to true if the window is intersected by at least one horizontal, half-opened hinge, logically splitting the horizontal display into top and bottom halves.

FoldState

Source set: Common
public class FoldState internal constructor(internal val value: Int)

Describes the layout fold state of the window, typically on a foldable device.

Members

Companion

Source set: Common
public companion object

Properties

Flat

Source set: Common
public val Flat: FoldState = FoldState(0)

Represents a flat fold state, where the window's display area on a foldable device is flat (either fully open or closed). It's the default state for non-foldable devices, or when the window does not span across a hinge or fold (such as in split-screen mode on a single panel).

HalfOpened

Source set: Common
public val HalfOpened: FoldState = FoldState(1)

Represents a device in a semi-open state. The window spans across a hinge or fold, splitting the display area into two logical parts.

FoldOrientation

Source set: Common
public class FoldOrientation internal constructor(internal val value: Int)

Describes the hardware orientation of a physical folding hinge.

This orientation is strictly relative to the bounds of the window, regardless of how the physical device is currently rotated in gravitational space.

Members

Companion

Source set: Common
public companion object

Properties

Horizontal

Source set: Common
public val Horizontal: FoldOrientation = FoldOrientation(0)

Represents a horizontal hinge or fold.

Vertical

Source set: Common
public val Vertical: FoldOrientation = FoldOrientation(1)

Represents a vertical hinge or fold.

PointerPrecision

Source set: Common
public class PointerPrecision private constructor(private val value: Int)

Describes the precision of the available pointing devices.

Members

Companion

Source set: Common
public companion object

Properties

Fine

Source set: Common
public val Fine: PointerPrecision

Represents a pointing device with high precision, such as a mouse, trackpad, or stylus.

Coarse

Source set: Common
public val Coarse: PointerPrecision

Represents a pointing device with limited precision, such as a touchscreen.

Blunt

Source set: Common
public val Blunt: PointerPrecision

Represents a pointing device with low precision, such as a joystick.

None

Source set: Common
public val None: PointerPrecision

Indicates that no pointing device is available.

KeyboardKind

Source set: Common
public class KeyboardKind private constructor(private val value: Int)

Describes the kind of keyboard available.

Members

Companion

Source set: Common
public companion object

Properties

Physical

Source set: Common
public val Physical: KeyboardKind

Represents a physical hardware keyboard.

Virtual

Source set: Common
public val Virtual: KeyboardKind

Represents an on-screen virtual keyboard (IME).

None

Source set: Common
public val None: KeyboardKind

Indicates that no keyboard is currently available for input.

This state occurs when no physical keyboard is connected to the device, and the on-screen software keyboard (IME) is currently hidden or closed.

ViewingDistance

Source set: Common
public class ViewingDistance private constructor(private val value: Int)

Describes the typical distance between the user and the screen.

Members

Companion

Source set: Common
public companion object

Properties

Near

Source set: Common
public val Near: ViewingDistance

Represents a device used within close range, such as a handheld phone, tablet, laptop, or desktop monitor. This is the default for most personal devices.

Medium

Source set: Common
public val Medium: ViewingDistance

Represents a device positioned slightly further away, such as an automotive device, or a tablet in a dock mode.

Far

Source set: Common
public val Far: ViewingDistance

Represents a device viewed from a significant distance, such as a television.

Content updated: