WatchFace

public final class WatchFace


The return value of WatchFaceService.createWatchFace which brings together rendering, styling, complicationSlots and state observers.

Summary

Nested types

WatchFace.Companion
WatchFace.LegacyWatchFaceOverlayStyle

Legacy Wear 2.0 watch face styling.

WatchFace.TapListener

Listens for taps on the watchface which didn't land on ComplicationSlots.

Public fields

final @NonNull WatchFace.LegacyWatchFaceOverlayStyle

The legacy LegacyWatchFaceOverlayStyle which only affects Wear 2.0 devices.

final @Nullable Instant

The Instant to use for preview rendering, or null if not set in which case the system chooses the Instant to use.

final @NonNull Renderer

The Renderer for this WatchFace.

final int

The type of watch face, whether it's digital or analog.

Public constructors

WatchFace(@WatchFaceType int watchFaceType, @NonNull Renderer renderer)

Public methods

final @NonNull WatchFace

Sets the legacy LegacyWatchFaceOverlayStyle which only affects Wear 2.0 devices.

final @NonNull WatchFace
setOverridePreviewReferenceInstant(
    @NonNull Instant previewReferenceTimeMillis
)

Overrides the reference time for editor preview images.

final @NonNull WatchFace

Sets an optional TapListener which if not null gets called on the ui thread whenever the user taps on the watchface but doesn't hit a ComplicationSlot.

Public fields

legacyWatchFaceStyle

@NonNull
public final @NonNull WatchFace.LegacyWatchFaceOverlayStyle legacyWatchFaceStyle

The legacy LegacyWatchFaceOverlayStyle which only affects Wear 2.0 devices.

overridePreviewReferenceInstant

@Nullable
public final @Nullable Instant overridePreviewReferenceInstant

The Instant to use for preview rendering, or null if not set in which case the system chooses the Instant to use.

renderer

@NonNull
public final @NonNull Renderer renderer

The Renderer for this WatchFace.

watchFaceType

@NonNull
public final int watchFaceType

The type of watch face, whether it's digital or analog. Used to determine the default time for editor preview screenshots.

Public constructors

WatchFace

public final WatchFace(@WatchFaceType int watchFaceType, @NonNull Renderer renderer)
Parameters
@WatchFaceType int watchFaceType

The type of watch face, whether it's digital or analog. Used to determine the default time for editor preview screenshots.

@NonNull Renderer renderer

The Renderer for this WatchFace.

Public methods

setLegacyWatchFaceStyle

@NonNull
public final WatchFace setLegacyWatchFaceStyle(
    @NonNull WatchFace.LegacyWatchFaceOverlayStyle legacyWatchFaceStyle
)

Sets the legacy LegacyWatchFaceOverlayStyle which only affects Wear 2.0 devices.

setOverridePreviewReferenceInstant

@NonNull
public final WatchFace setOverridePreviewReferenceInstant(
    @NonNull Instant previewReferenceTimeMillis
)

Overrides the reference time for editor preview images.

Parameters
@NonNull Instant previewReferenceTimeMillis

The UTC preview time in milliseconds since the epoch

setTapListener

@NonNull
public final WatchFace setTapListener(@Nullable WatchFace.TapListener tapListener)

Sets an optional TapListener which if not null gets called on the ui thread whenever the user taps on the watchface but doesn't hit a ComplicationSlot.