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
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
@get:FrequentlyChangingValue public val windowWidth: Dp
The current width of the application window.
windowHeight
@get:FrequentlyChangingValue public val windowHeight: Dp
The current height of the application window.
pointerPrecision
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
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
@get:Suppress("GetterSetterNames") public val hasMicrophone: Boolean
Whether the microphone is supported on the current device.
hasCamera
@get:Suppress("GetterSetterNames") public val hasCamera: Boolean
Whether the camera is supported on the current device.
viewingDistance
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
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
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
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
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
public class FoldState internal constructor(internal val value: Int)
Describes the layout fold state of the window, typically on a foldable device.
Members
Companion
public companion object
Properties
Flat
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
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
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
public companion object
Properties
Horizontal
public val Horizontal: FoldOrientation = FoldOrientation(0)
Represents a horizontal hinge or fold.
Vertical
public val Vertical: FoldOrientation = FoldOrientation(1)
Represents a vertical hinge or fold.
PointerPrecision
public class PointerPrecision private constructor(private val value: Int)
Describes the precision of the available pointing devices.
Members
Companion
public companion object
Properties
Fine
public val Fine: PointerPrecision
Represents a pointing device with high precision, such as a mouse, trackpad, or stylus.
Coarse
public val Coarse: PointerPrecision
Represents a pointing device with limited precision, such as a touchscreen.
Blunt
public val Blunt: PointerPrecision
Represents a pointing device with low precision, such as a joystick.
None
public val None: PointerPrecision
Indicates that no pointing device is available.
KeyboardKind
public class KeyboardKind private constructor(private val value: Int)
Describes the kind of keyboard available.
Members
Companion
public companion object
Properties
Physical
public val Physical: KeyboardKind
Represents a physical hardware keyboard.
Virtual
public val Virtual: KeyboardKind
Represents an on-screen virtual keyboard (IME).
None
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
public class ViewingDistance private constructor(private val value: Int)
Describes the typical distance between the user and the screen.
Members
Companion
public companion object
Properties
Near
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
public val Medium: ViewingDistance
Represents a device positioned slightly further away, such as an automotive device, or a tablet in a dock mode.
Far
public val Far: ViewingDistance
Represents a device viewed from a significant distance, such as a television.