Google is committed to advancing racial equity for Black communities. See how.

Builder

class Builder
kotlin.Any
   ↳ androidx.wear.watchface.WatchFace.Builder

Builder for a WatchFace.

If unreadCountIndicator or notificationIndicator are hidden then the WatchState class will receive updates necessary for the watch to draw its own indicators.

Summary

Public constructors
<init>(watchFaceType: Int, interactiveUpdateRateMillis: Long, userStyleRepository: UserStyleRepository, complicationsManager: ComplicationsManager, renderer: Renderer, watchFaceHost: WatchFaceHost, watchState: WatchState)

Builder for a WatchFace.

Public methods
WatchFace

Constructs the WatchFace.

WatchFace.Builder
setPreviewReferenceTimeMillis(previewReferenceTimeMillis: Long)

Overrides the reference time for editor preview images.

WatchFace.Builder

WatchFace.Builder
setWear2AccentColor(@ColorInt accentColor: Int)

Sets the accent color which can be set by developers to customise watch face.

WatchFace.Builder
setWear2AcceptsTapEvents(acceptsTapEvents: Boolean)

Sets whether this watchface accepts tap events.

WatchFace.Builder
setWear2StatusBarGravity(statusBarGravity: Int)

Sets position of status icons (battery state, lack of connection) on the screen.

WatchFace.Builder
setWear2ViewProtectionMode(viewProtectionMode: Int)

Only has an impact on devices running Wear 2.

Public constructors

<init>

Builder(
    watchFaceType: Int,
    interactiveUpdateRateMillis: Long,
    userStyleRepository: UserStyleRepository,
    complicationsManager: ComplicationsManager,
    renderer: Renderer,
    watchFaceHost: WatchFaceHost,
    watchState: WatchState)

Builder for a WatchFace.

If unreadCountIndicator or notificationIndicator are hidden then the WatchState class will receive updates necessary for the watch to draw its own indicators.

Public methods

build

fun build(): WatchFace

Constructs the WatchFace.

setPreviewReferenceTimeMillis

fun setPreviewReferenceTimeMillis(previewReferenceTimeMillis: Long): WatchFace.Builder

Overrides the reference time for editor preview images.

Parameters
previewReferenceTimeMillis: Long The preview time in milliseconds since the epoch

setSystemTimeProvider

fun setSystemTimeProvider(systemTimeProvider: WatchFace.SystemTimeProvider): WatchFace.Builder

setWear2AccentColor

fun setWear2AccentColor(@ColorInt accentColor: Int): WatchFace.Builder

Sets the accent color which can be set by developers to customise watch face. It will be used when drawing the unread notification indicator. Default color is white.

setWear2AcceptsTapEvents

fun setWear2AcceptsTapEvents(acceptsTapEvents: Boolean): WatchFace.Builder

Sets whether this watchface accepts tap events. The default is false.

Parameters
acceptsTapEvents: Boolean whether to receive touch events.

setWear2StatusBarGravity

fun setWear2StatusBarGravity(statusBarGravity: Int): WatchFace.Builder

Sets position of status icons (battery state, lack of connection) on the screen.

Parameters
statusBarGravity: Int This must be any combination of horizontal Gravity constant (Gravity.LEFT, Gravity.CENTER_HORIZONTAL, Gravity.RIGHT) and vertical Gravity constants (Gravity.TOP, [Gravity,CENTER_VERTICAL}, Gravity,BOTTOM), e.g. {@code Gravity.LEFT | Gravity.BOTTOM}. On circular screens, only the vertical gravity is respected.

setWear2ViewProtectionMode

fun setWear2ViewProtectionMode(viewProtectionMode: Int): WatchFace.Builder

Only has an impact on devices running Wear 2.x, on other devices this is a no-op and the functionality is replaced by... TODO(alexclarke): Design the replacement.

Parameters
viewProtectionMode: Int The view protection mode bit field, must be a combination of zero or more of PROTECT_STATUS_BAR, PROTECT_HOTWORD_INDICATOR, PROTECT_WHOLE_SCREEN.
Exceptions
IllegalArgumentException if viewProtectionMode has an unexpected value