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

UserStyleSetting

sealed class UserStyleSetting
kotlin.Any
   ↳ androidx.wear.watchface.style.UserStyleSetting

Watch faces often have user configurable styles, the definition of what is a style is left up to the watch face but it typically incorporates a variety of settings such as: color, visual theme for watch hands, font, tick shape, complications, audio elements, etc...

A UserStyleSetting represents one of these dimensions. See also UserStyleSchema which defines the list of UserStyleSettings provided by the watch face.

Styling data gets shared with the companion phone to support editors (typically over bluetooth), as a result the size of serialized UserStyleSettings could become an issue if large.

Summary

Nested classes

A BooleanUserStyleSetting represents a setting with a true and a false setting.

ComplicationsUserStyleSetting is the recommended UserStyleSetting for representing complication configuration options such as the number of active complications, their location, etc.

An application specific style setting.

A DoubleRangeUserStyleSetting represents a setting with a Double value in the range [minimumValue .. maximumValue].

open

A ListStyleCategory represents a setting with options selected from a List.

A LongRangeUserStyleSetting represents a setting with a Long value in the range minimumValue..maximumValue.

abstract

Represents a choice within a style setting which can either be an option from the list or a an arbitrary value depending on the nature of the style setting.

Public methods
UserStyleSetting.Option

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

open UserStyleSetting.Option

Translates an option name into an option.

List<OptionWireFormat>

open String

abstract UserStyleSettingWireFormat

Properties
Collection<Layer>

Used by the style configuration UI.

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 style selection UI.

String

Identifier for the element, must be unique.

List<UserStyleSetting.Option>

List of options for this UserStyleSetting.

Companion properties
Int

Maximum length of the id field.

Public methods

getDefaultOption

fun getDefaultOption(): UserStyleSetting.Option

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

getOptionForId

open fun getOptionForId(optionId: String): UserStyleSetting.Option

Translates an option name into an option. This will need to be overridden for userStyle categories that can't sensibly be fully enumerated (e.g. a full 24-bit color picker).

Parameters
optionId: String The ID of the option
Return
An Option corresponding to the name. This could either be one of the options from userStyleSettings or a newly constructed Option depending on the nature of the UserStyleSetting. If optionName is unrecognized then the default value for the setting should be returned.

getWireFormatOptionsList

fun getWireFormatOptionsList(): List<OptionWireFormat>

toString

open fun toString(): String

toWireFormat

abstract fun toWireFormat(): UserStyleSettingWireFormat

Properties

affectsLayers

val affectsLayers: Collection<Layer>

Used by the style configuration UI. Describes which rendering layers this style affects.

defaultOptionIndex

val defaultOptionIndex: Int

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

description

val description: CharSequence

Localized description string displayed under the displayName.

displayName

val