CanvasComplicationDrawable


open class CanvasComplicationDrawable : CanvasComplication


A complication rendered with ComplicationDrawable which renders complicationSlots in a material design style. This renderer can't be shared by multiple complicationSlots.

use Watch Face Format instead

Summary

Public constructors

CanvasComplicationDrawable(
    drawable: ComplicationDrawable,
    watchState: WatchState,
    invalidateCallback: CanvasComplication.InvalidateCallback
)

This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Public functions

open Unit
drawHighlight(
    canvas: Canvas,
    bounds: Rect,
    boundsType: Int,
    zonedDateTime: ZonedDateTime,
    color: @ColorInt Int
)

This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

open ComplicationData

This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

open Unit
@CallSuper
loadData(
    complicationData: ComplicationData,
    loadDrawablesAsynchronous: Boolean
)

This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

open Unit
render(
    canvas: Canvas,
    bounds: Rect,
    zonedDateTime: ZonedDateTime,
    renderParameters: RenderParameters,
    slotId: Int
)

This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Public properties

ComplicationDrawable

This property is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Inherited functions

From androidx.wear.watchface.CanvasComplication
open Unit
@ComplicationExperimental
drawHighlight(
    canvas: Canvas,
    bounds: Rect,
    boundsType: Int,
    zonedDateTime: ZonedDateTime,
    color: @ColorInt Int,
    boundingArc: BoundingArc?
)

This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

open Unit

This function is deprecated. AndroidX watchface libraries are deprecated, use Watch Face Format instead.

Public constructors

CanvasComplicationDrawable

Added in 1.0.0
Deprecated in 1.3.0-alpha06
CanvasComplicationDrawable(
    drawable: ComplicationDrawable,
    watchState: WatchState,
    invalidateCallback: CanvasComplication.InvalidateCallback
)
Parameters
drawable: ComplicationDrawable

The ComplicationDrawable to render with.

watchState: WatchState

The watch's WatchState which contains details pertaining to (low-bit) ambient mode and burn in protection needed to render correctly.

invalidateCallback: CanvasComplication.InvalidateCallback

The CanvasComplication.InvalidateCallback associated with which can be used to request screen redrawing and to report updates

Public functions

drawHighlight

Added in 1.0.0
Deprecated in 1.3.0-alpha06
open fun drawHighlight(
    canvas: Canvas,
    bounds: Rect,
    boundsType: Int,
    zonedDateTime: ZonedDateTime,
    color: @ColorInt Int
): Unit

Draws a highlight for a ComplicationSlotBoundsType.ROUND_RECT complication. The default implementation does this by drawing a dashed line around the complication, other visual effects may be used if desired.

Parameters
canvas: Canvas

The Canvas to render into

bounds: Rect

A Rect describing the bounds of the complication

boundsType: Int

The ComplicationSlotBoundsTypeIntDef of the complication

zonedDateTime: ZonedDateTime

The ZonedDateTime to render the highlight with

color: @ColorInt Int

The color to render the highlight with

getData

Added in 1.0.0
Deprecated in 1.3.0-alpha06
open fun getData(): ComplicationData

Returns the ComplicationData to render with. This defaults to NoDataComplicationData.

loadData

Added in 1.0.0
Deprecated in 1.3.0-alpha06
@CallSuper
open fun loadData(
    complicationData: ComplicationData,
    loadDrawablesAsynchronous: Boolean
): Unit

Updates the ComplicationData used for rendering and loads any Drawables within the complicationData.

Parameters
complicationData: ComplicationData

The new ComplicationData for which any Drawables should be loaded

loadDrawablesAsynchronous: Boolean

Whether any Drawables within complicationData should be loaded asynchronously or not. If they are loaded asynchronously then upon completion, ComplicationDrawable.setComplicationData will call Drawable.Callback.invalidateDrawable registered in our init section above, which invalidates the attachedComplication and ultimately the watch face.

render

Added in 1.0.0
Deprecated in 1.3.0-alpha06
open fun render(
    canvas: Canvas,
    bounds: Rect,
    zonedDateTime: ZonedDateTime,
    renderParameters: RenderParameters,
    slotId: Int
): Unit

Draws the complication defined by getData into the canvas with the specified bounds. This will usually be called by user watch face drawing code, but the system may also call it for complication selection UI rendering. The width and height will be the same as that computed by computeBounds but the translation and canvas size may differ.

Parameters
canvas: Canvas

The Canvas to render into

bounds: Rect

A Rect describing the bounds of the complication

zonedDateTime: ZonedDateTime

The ZonedDateTime to render with

renderParameters: RenderParameters

The current RenderParameters

slotId: Int

The Id of the ComplicationSlot being rendered

Public properties

drawable

Added in 1.0.0
Deprecated in 1.3.0-alpha06
var drawableComplicationDrawable

The ComplicationDrawable to render with.