UserStyleSetting.ComplicationSlotsUserStyleSetting


class UserStyleSetting.ComplicationSlotsUserStyleSetting : UserStyleSetting


ComplicationSlotsUserStyleSetting is the recommended UserStyleSetting for representing complication slot configuration, options such as the number of active complication slots, their location, etc... The ComplicationSlotsOption class allows you to apply a list of ComplicationSlotOverlays on top of the base config as specified by the androidx.wear.watchface.ComplicationSlot constructor.

The ComplicationsManager listens for style changes with this setting and when a ComplicationSlotsOption is selected the overrides are automatically applied. Note its suggested that the default ComplicationSlotOverlay (the first entry in the list) does not apply any overrides.

From android T multiple ComplicationSlotsUserStyleSetting are allowed in a style hierarchy as long as at most one is active for any permutation of UserStyle. Prior to android T only a single ComplicationSlotsUserStyleSetting was allowed.

Not to be confused with complication data source selection.

Summary

Nested types

Overrides to be applied to the corresponding androidx.wear.watchface.ComplicationSlot's initial config (as specified in it's constructor) when the setting is selected.

Constructs a ComplicationSlotOverlay.Builder.

Represents an override to the initial androidx.wear.watchface.ComplicationSlotsManager configuration.

Public constructors

ComplicationSlotsUserStyleSetting(
    id: UserStyleSetting.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    descriptionResourceId: @StringRes Int,
    icon: Icon?,
    complicationConfig: List<UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption>,
    affectsWatchFaceLayers: Collection<WatchFaceLayer>,
    defaultOption: UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption,
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData?
)

Constructs a ComplicationSlotsUserStyleSetting where ComplicationSlotsUserStyleSetting.displayName and ComplicationSlotsUserStyleSetting.description are specified as resources.

ComplicationSlotsUserStyleSetting(
    id: UserStyleSetting.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    descriptionResourceId: @StringRes Int,
    iconProvider: () -> Icon,
    complicationConfig: List<UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption>,
    affectsWatchFaceLayers: Collection<WatchFaceLayer>,
    defaultOption: UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption,
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData?
)

Constructs a ComplicationSlotsUserStyleSetting with a lazily evaluated icon, where ComplicationSlotsUserStyleSetting.displayName and ComplicationSlotsUserStyleSetting.description are specified as resources.

Inherited functions

From androidx.wear.watchface.style.UserStyleSetting
open operator Boolean
equals(other: Any?)
open UserStyleSetting.Option

Translates an option name into an option.

open Int
open String

Inherited properties

From androidx.wear.watchface.style.UserStyleSetting
Collection<WatchFaceLayer>

Used by the style configuration UI.

UserStyleSetting.Option

Returns the default for when the user hasn't selected an option.

Int

The default option index, used if nothing has been selected within the options list.

CharSequence

Localized description string displayed under the displayName.

CharSequence

Localized human readable name for the element, used in the userStyle selection UI.

Icon?

Icon for use in the companion editor style selection UI.

UserStyleSetting.Id

Identifier for the element, must be unique.

List<UserStyleSetting.Option>

List of options for this UserStyleSetting.

UserStyleSetting.WatchFaceEditorData?

Optional data for an on watch face editor, this will not be sent to the companion and its contents may be used in preference to other fields by an on watch face editor.

Public constructors

ComplicationSlotsUserStyleSetting

ComplicationSlotsUserStyleSetting(
    id: UserStyleSetting.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    descriptionResourceId: @StringRes Int,
    icon: Icon?,
    complicationConfig: List<UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption>,
    affectsWatchFaceLayers: Collection<WatchFaceLayer>,
    defaultOption: UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption = complicationConfig.first(),
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData? = null
)

Constructs a ComplicationSlotsUserStyleSetting where ComplicationSlotsUserStyleSetting.displayName and ComplicationSlotsUserStyleSetting.description are specified as resources.

Parameters
id: UserStyleSetting.Id

Id for the element, must be unique.

resources: Resources

The Resources from which displayNameResourceId and descriptionResourceId are loaded.

displayNameResourceId: @StringRes Int

String resource id for a human readable name for the element, used in the userStyle selection UI.

descriptionResourceId: @StringRes Int

String resource id for a human readable description string displayed under the displayName.

icon: Icon?

Icon for use in the companion userStyle selection UI. This gets sent to the companion over bluetooth and should be small (ideally a few kb in size).

complicationConfig: List<UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption>

The configuration for affected complications.

affectsWatchFaceLayers: Collection<WatchFaceLayer>

Used by the style configuration UI. Describes which watch face rendering layers this style affects, must include WatchFaceLayer.COMPLICATIONS.

defaultOption: UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption = complicationConfig.first()

The default option, used when data isn't persisted. Optional parameter which defaults to the first element of complicationConfig.

watchFaceEditorData: UserStyleSetting.WatchFaceEditorData? = null

Optional data for an on watch face editor, this will not be sent to the companion and its contents may be used in preference to other fields by an on watch face editor.

ComplicationSlotsUserStyleSetting

ComplicationSlotsUserStyleSetting(
    id: UserStyleSetting.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    descriptionResourceId: @StringRes Int,
    iconProvider: () -> Icon,
    complicationConfig: List<UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption>,
    affectsWatchFaceLayers: Collection<WatchFaceLayer>,
    defaultOption: UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption = complicationConfig.first(),
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData? = null
)

Constructs a ComplicationSlotsUserStyleSetting with a lazily evaluated icon, where ComplicationSlotsUserStyleSetting.displayName and ComplicationSlotsUserStyleSetting.description are specified as resources.

Parameters
id: UserStyleSetting.Id

Id for the element, must be unique.

resources: Resources

The Resources from which displayNameResourceId and descriptionResourceId are loaded.

displayNameResourceId: @StringRes Int

String resource id for a human readable name for the element, used in the userStyle selection UI.

descriptionResourceId: @StringRes Int

String resource id for a human readable description string displayed under the displayName.

iconProvider: () -> Icon

A provider of an Icon for use in the companion userStyle selection UI. This gets lazily evaluated and is sent to the companion over bluetooth and should be small (ideally a few kb in size). Note this is not guaranteed to be called on the calling thread.

complicationConfig: List<UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption>

The configuration for affected complications.

affectsWatchFaceLayers: Collection<WatchFaceLayer>

Used by the style configuration UI. Describes which watch face rendering layers this style affects, must include WatchFaceLayer.COMPLICATIONS.

defaultOption: UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption = complicationConfig.first()

The default option, used when data isn't persisted. Optional parameter which defaults to the first element of complicationConfig.

watchFaceEditorData: UserStyleSetting.WatchFaceEditorData? = null

Optional data for an on watch face editor, this will not be sent to the companion and its contents may be used in preference to other fields by an on watch face editor.