InteractiveWatchFaceClient

interface InteractiveWatchFaceClient


Controls a stateful remote interactive watch face. Typically this will be used for the current active watch face.

Note clients should call close when finished.

Summary

Nested types

InteractiveWatchFaceClient.ClientDisconnectListener

Callback that observes when the client disconnects.

InteractiveWatchFaceClient.Companion

Public fields

abstract @NonNull Map<@NonNull Integer, @NonNull ComplicationSlotState>

Map of androidx.wear.watchface.ComplicationSlot ids to ComplicationSlotState for each ComplicationSlot registered with the watch face's ComplicationSlotsManager.

abstract @NonNull List<@NonNull ContentDescriptionLabel>

Returns the ContentDescriptionLabels describing the watch face, for the use by screen readers.

abstract @NonNull String

Returns the ID of this watch face instance.

abstract @NonNull Instant

The UTC reference preview time for this watch face in milliseconds since the epoch.

abstract @NonNull UserStyleSchema

The watch face's UserStyleSchema.

Public methods

abstract @AnyThread void

Registers a ClientDisconnectListener.

@Nullable Integer
getComplicationIdAt(@Px int x, @Px int y)

Returns the ID of the androidx.wear.watchface.ComplicationSlot at the given coordinates or null if there isn't one.

abstract @AnyThread boolean

Returns true if the connection to the server side is alive.

abstract void

Triggers watch face rendering into the surface when in ambient mode.

abstract @AnyThread void

Removes a ClientDisconnectListener previously registered by addClientDisconnectListener.

abstract @RequiresApi(value = "27") @NonNull Bitmap
renderWatchFaceToBitmap(
    @NonNull RenderParameters renderParameters,
    @NonNull Instant instant,
    @Nullable UserStyle userStyle,
    @Nullable Map<@NonNull Integer, @NonNull ComplicationData> idAndComplicationData
)

Renders the watchface to a shared memory backed Bitmap with the given settings.

abstract void
sendTouchEvent(@Px int xPosition, @Px int yPosition, @TapType int tapType)

Sends a tap event to the watch face for processing.

abstract void

Updates the watch faces WatchUiState.

abstract void
updateComplicationData(
    @NonNull Map<@NonNull Integer, @NonNull ComplicationData> slotIdToComplicationData
)

Sends new ComplicationData to the watch face.

abstract void
updateWatchFaceInstance(
    @NonNull String newInstanceId,
    @NonNull UserStyle userStyle
)

Renames this instance to newInstanceId (must be unique, usually this would be different from the old ID but that's not a requirement).

abstract void
updateWatchFaceInstance(
    @NonNull String newInstanceId,
    @NonNull UserStyleData userStyle
)

Renames this instance to newInstanceId (must be unique, usually this would be different from the old ID but that's not a requirement).

Inherited methods

From class AutoCloseable
abstract void

Public fields

complicationSlotsState

@NonNull
public abstract @NonNull Map<@NonNull Integer, @NonNull ComplicationSlotStatecomplicationSlotsState

Map of androidx.wear.watchface.ComplicationSlot ids to ComplicationSlotState for each ComplicationSlot registered with the watch face's ComplicationSlotsManager. The ComplicationSlotState is based on the initial state of each androidx.wear.watchface.ComplicationSlot plus any overrides from a ComplicationSlotsUserStyleSetting. As a consequence ComplicationSlotState may update based on style changes.

contentDescriptionLabels

@NonNull
public abstract @NonNull List<@NonNull ContentDescriptionLabelcontentDescriptionLabels

Returns the ContentDescriptionLabels describing the watch face, for the use by screen readers.

instanceId

@NonNull
public abstract @NonNull String instanceId

Returns the ID of this watch face instance.

previewReferenceInstant

@NonNull
public abstract @NonNull Instant previewReferenceInstant

The UTC reference preview time for this watch face in milliseconds since the epoch.

userStyleSchema

@NonNull
public abstract @NonNull UserStyleSchema userStyleSchema

The watch face's UserStyleSchema.

Public methods

addClientDisconnectListener

@AnyThread
@NonNull
public abstract @AnyThread void addClientDisconnectListener(
    @NonNull InteractiveWatchFaceClient.ClientDisconnectListener listener,
    @NonNull Executor executor
)

Registers a ClientDisconnectListener.

getComplicationIdAt

@Nullable
public Integer getComplicationIdAt(@Px int x, @Px int y)

Returns the ID of the androidx.wear.watchface.ComplicationSlot at the given coordinates or null if there isn't one.

Note this currently doesn't support Edge complications.

isConnectionAlive

@AnyThread
@NonNull
public abstract @AnyThread boolean isConnectionAlive()

Returns true if the connection to the server side is alive.

performAmbientTick

@NonNull
public abstract void performAmbientTick()

Triggers watch face rendering into the surface when in ambient mode.

removeClientDisconnectListener

@AnyThread
@NonNull
public abstract @AnyThread void removeClientDisconnectListener(
    @NonNull InteractiveWatchFaceClient.ClientDisconnectListener listener
)

Removes a ClientDisconnectListener previously registered by addClientDisconnectListener.

renderWatchFaceToBitmap

@RequiresApi(value = "27")
@NonNull
public abstract @RequiresApi(value = "27") Bitmap renderWatchFaceToBitmap(
    @NonNull RenderParameters renderParameters,
    @NonNull Instant instant,
    @Nullable UserStyle userStyle,
    @Nullable Map<@NonNull Integer, @NonNull ComplicationData> idAndComplicationData
)

Renders the watchface to a shared memory backed Bitmap with the given settings.

Parameters
@NonNull RenderParameters renderParameters

The RenderParameters to draw with.

@NonNull Instant instant

The Instant render with.

@Nullable UserStyle userStyle

Optional UserStyle to render with, if null the current style is used.

@Nullable Map<@NonNull Integer, @NonNull ComplicationData> idAndComplicationData

Map of complication ids to ComplicationData to render with, or if null then the existing complication data if any is used.

Returns
@RequiresApi(value = "27") Bitmap

A shared memory backed Bitmap containing a screenshot of the watch face with the given settings.

sendTouchEvent

@NonNull
public abstract void sendTouchEvent(@Px int xPosition, @Px int yPosition, @TapType int tapType)

Sends a tap event to the watch face for processing.

setWatchUiState

@NonNull
public abstract void setWatchUiState(@NonNull WatchUiState watchUiState)

Updates the watch faces WatchUiState. NB setWatchUiState and updateWatchFaceInstance can be called in any order.

updateComplicationData

@NonNull
public abstract void updateComplicationData(
    @NonNull Map<@NonNull Integer, @NonNull ComplicationData> slotIdToComplicationData
)

Sends new ComplicationData to the watch face. Note this doesn't have to be a full update, it's possible to update just one complication at a time, but doing so may result in a less visually clean transition.

updateWatchFaceInstance

@NonNull
public abstract void updateWatchFaceInstance(
    @NonNull String newInstanceId,
    @NonNull UserStyle userStyle
)

Renames this instance to newInstanceId (must be unique, usually this would be different from the old ID but that's not a requirement). Sets the current UserStyle and clears any complication data. Setting the new UserStyle may have a side effect of enabling or disabling complicationSlots, which will be visible via ComplicationSlotState.isEnabled.

NB setWatchUiState and updateWatchFaceInstance can be called in any order.

updateWatchFaceInstance

@NonNull
public abstract void updateWatchFaceInstance(
    @NonNull String newInstanceId,
    @NonNull UserStyleData userStyle
)

Renames this instance to newInstanceId (must be unique, usually this would be different from the old ID but that's not a requirement). Sets the current UserStyle represented as a [UserStyleData> and clears any complication data. Setting the new UserStyle may have a side effect of enabling or disabling complicationSlots, which will be visible via ComplicationSlotState.isEnabled.