Android 12 Developer Preview is here! Try it out, and give us your feedback!

EditorSession

abstract class EditorSession : AutoCloseable
kotlin.Any
   ↳ androidx.wear.watchface.editor.EditorSession

Interface for manipulating watch face state during an editing session for a watch face editing session. The editor should adjust userStyle and call launchComplicationProviderChooser to configure the watch face and call close when done. This reports the updated EditorState to the EditorObserverCallbacks registered via EditorServiceClient.registerObserver.

Summary

Public constructors

Interface for manipulating watch face state during an editing session for a watch face editing session.

Public methods
abstract Int?
getComplicationIdAt(@Px x: Int, @Px y: Int)

Returns the ID of the complication at the given coordinates or null if there isn't one.

abstract suspend Map<Int, ComplicationData>

Returns a map of complication ids to preview ComplicationData suitable for use in rendering the watch face.

abstract suspend Boolean

Launches the complication provider chooser and returns true if the user made a selection or false if the activity was canceled.

abstract Bitmap
takeWatchFaceScreenshot(renderParameters: RenderParameters, calendarTimeMillis: Long, idToComplicationData: Map<Int, ComplicationData>?)

Takes a screen shot of the watch face using the current userStyle.

Companion functions
EditorSession?
createHeadlessEditingSession(activity: ComponentActivity, editIntent: Intent, headlessWatchFaceClient: HeadlessWatchFaceClient)

Constructs an EditorSession for a remote watch face editor.

Deferred<EditorSession?>

Constructs an EditorSession for an on watch face editor.

Properties
abstract Int?

The ID of the background complication or null if there isn't one.

Boolean

Whether any changes should be committed when the session is closed (defaults to true).

abstract Map<Int, ComplicationState>

Map of complication ids to ComplicationState for each complication slot.

abstract String?

Unique ID for the instance of the watch face being edited, only defined for Android R and beyond, it's null on Android P and earlier.

abstract Long

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

abstract UserStyle

The current UserStyle.

abstract UserStyleSchema

The watch face's UserStyleSchema.

abstract ComponentName

The ComponentName of the watch face being edited.

Public constructors

<init>

EditorSession()

Interface for manipulating watch face state during an editing session for a watch face editing session. The editor should adjust userStyle and call launchComplicationProviderChooser to configure the watch face and call close when done. This reports the updated EditorState to the EditorObserverCallbacks registered via EditorServiceClient.registerObserver.

Public methods

getComplicationIdAt

@UiThread abstract fun getComplicationIdAt(
    @Px x: Int,
    @Px y: Int
): Int?

Returns the ID of the complication at the given coordinates or null if there isn't one.

getComplicationPreviewData

abstract suspend fun getComplicationPreviewData(): Map<Int, ComplicationData>

Returns a map of complication ids to preview ComplicationData suitable for use in rendering the watch face. Note if a slot is configured to be empty then it will not appear in the map, however disabled complications are included. Note also unlike live data this is static per provider, but it may change (on the UIThread) as a result of