UserStyleSchema


class UserStyleSchema


Describes the list of UserStyleSettings the user can configure. Note style schemas can be hierarchical (see UserStyleSetting.Option.childSettings), editors should use rootUserStyleSettings rather than userStyleSettings for populating the top level UI.

Summary

Public constructors

UserStyleSchema(userStyleSettings: List<UserStyleSetting>)

Public functions

UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption?

When a UserStyleSchema contains hierarchical styles, only part of it is deemed to be active based on the user’s options in userStyle.

operator UserStyleSetting?

Returns the UserStyleSetting whose UserStyleSetting.Id matches settingId or null if none match.

ByteArray

Computes a SHA-1 MessageDigest hash of the UserStyleSchema.

open String

Public properties

List<UserStyleSetting>

For use with hierarchical schemas, lists all the settings with no parent Option.

List<UserStyleSetting>

Public constructors

UserStyleSchema

UserStyleSchema(userStyleSettings: List<UserStyleSetting>)
Parameters
userStyleSettings: List<UserStyleSetting>

The user configurable style categories associated with this watch face. Empty if the watch face doesn't support user styling. Note we allow at most one UserStyleSetting.CustomValueUserStyleSetting in the list. Prior to android T at most one UserStyleSetting.ComplicationSlotsUserStyleSetting is allowed, however from android T it's possible with hierarchical styles for there to be more than one, but at most one can be active at any given time.

Public functions

findComplicationSlotsOptionForUserStyle

Added in 1.2.0
fun findComplicationSlotsOptionForUserStyle(userStyle: UserStyle): UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption?

When a UserStyleSchema contains hierarchical styles, only part of it is deemed to be active based on the user’s options in userStyle. Conversely if the UserStyleSchema doesn’t contain any hierarchical styles then all of it is considered to be active all the time.

From the active portion of the UserStyleSchema we only allow there to be at most one UserStyleSetting.ComplicationSlotsUserStyleSetting. This function searches the active portion of the UserStyleSchema for the UserStyleSetting.ComplicationSlotsUserStyleSetting, if one is found then it returns the selected ComplicationSlotsOption from that, based on the userStyle. If a UserStyleSetting.ComplicationSlotsUserStyleSetting is not found in the active portion of the UserStyleSchema it returns null.

Parameters
userStyle: UserStyle

The UserStyle for which the function will search for the selected ComplicationSlotsOption, if any.

get

Added in 1.1.0
operator fun get(settingId: UserStyleSetting.Id): UserStyleSetting?

Returns the UserStyleSetting whose UserStyleSetting.Id matches settingId or null if none match.

getDigestHash

Added in 1.1.0
fun getDigestHash(): ByteArray

Computes a SHA-1 MessageDigest hash of the UserStyleSchema. Note that for performance reasons where possible the resource id or url for Icons in the schema are used rather than the image bytes. This means that this hash should be considered insensitive to changes to the contents of icons between APK versions, which the developer should account for accordingly.

toString

open fun toString(): String

Public properties

rootUserStyleSettings

Added in 1.1.0
val rootUserStyleSettingsList<UserStyleSetting>

For use with hierarchical schemas, lists all the settings with no parent Option.

userStyleSettings

Added in 1.0.0
Deprecated in 1.2.0
val userStyleSettingsList<UserStyleSetting>