ComplicationSlotBounds


public final class ComplicationSlotBounds


ComplicationSlotBounds are defined by fractional screen space coordinates in unit-square 0..1. These bounds will be subsequently clamped to the unit square and converted to screen space coordinates. NB 0 and 1 are included in the unit square.

One bound is expected per ComplicationType to allow androidx.wear.watchface.ComplicationSlots to change shape depending on the type.

Taps on the watch are tested first against each ComplicationSlot's perComplicationTypeBounds for the relevant ComplicationType. Its assumed that perComplicationTypeBounds don't overlap. If no intersection was found then taps are checked against perComplicationTypeBounds expanded by perComplicationTypeMargins. Expanded bounds can overlap so the ComplicationSlot with the lowest id that intersects the coordinates, if any, is selected.

Summary

Public constructors

ComplicationSlotBounds(
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds
)

This method is deprecated. Use a constructor that specifies perComplicationTypeMargins

Constructs a ComplicationSlotBounds where all complication types have the same screen space unit-square bounds and margins.

ComplicationSlotBounds(
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds,
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeMargins
)

Public methods

boolean
equals(Object other)
final @NonNull Map<@NonNull ComplicationType, @NonNull RectF>

Per ComplicationType fractional unit-square screen space complication bounds.

final @NonNull Map<@NonNull ComplicationType, @NonNull RectF>

Per ComplicationType fractional unit-square screen space complication margins for tap detection (doesn't affect rendering).

int
@NonNull String

Public constructors

ComplicationSlotBounds

public ComplicationSlotBounds(
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds
)

ComplicationSlotBounds

Added in 1.2.0
public ComplicationSlotBounds(@NonNull RectF bounds, @NonNull RectF margins)

Constructs a ComplicationSlotBounds where all complication types have the same screen space unit-square bounds and margins.

ComplicationSlotBounds

public ComplicationSlotBounds(
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds,
    @NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeMargins
)
Parameters
@NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeBounds

Per ComplicationType fractional unit-square screen space complication bounds.

@NonNull Map<@NonNull ComplicationType, @NonNull RectF> perComplicationTypeMargins

Per ComplicationType fractional unit-square screen space complication margins for tap detection (doesn't affect rendering).

Public methods

equals

public boolean equals(Object other)

getPerComplicationTypeBounds

Added in 1.0.0
public final @NonNull Map<@NonNull ComplicationType, @NonNull RectFgetPerComplicationTypeBounds()

Per ComplicationType fractional unit-square screen space complication bounds.

getPerComplicationTypeMargins

Added in 1.2.0
public final @NonNull Map<@NonNull ComplicationType, @NonNull RectFgetPerComplicationTypeMargins()

Per ComplicationType fractional unit-square screen space complication margins for tap detection (doesn't affect rendering).

hashCode

public int hashCode()

toString

public @NonNull String toString()