UserStyleSchema


public final 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(
    @NonNull List<@NonNull UserStyleSetting> userStyleSettings
)

Public methods

final 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.

final UserStyleSetting

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

final @NonNull byte[]

Computes a SHA-1 MessageDigest hash of the UserStyleSchema.

final @NonNull List<@NonNull UserStyleSetting>

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

final @NonNull List<@NonNull UserStyleSetting>

This method is deprecated. use rootUserStyleSettings instead

@NonNull String

Public constructors

UserStyleSchema

public UserStyleSchema(
    @NonNull List<@NonNull UserStyleSetting> userStyleSettings
)
Parameters
@NonNull List<@NonNull UserStyleSetting> userStyleSettings

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 methods

findComplicationSlotsOptionForUserStyle

Added in 1.2.0
public final UserStyleSetting.ComplicationSlotsUserStyleSetting.ComplicationSlotsOption findComplicationSlotsOptionForUserStyle(@NonNull UserStyle userStyle)

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
@NonNull UserStyle userStyle

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

get

Added in 1.1.0
public final UserStyleSetting get(@NonNull UserStyleSetting.Id settingId)

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

getDigestHash

Added in 1.1.0
public final @NonNull byte[] getDigestHash()

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.

getRootUserStyleSettings

Added in 1.1.0
public final @NonNull List<@NonNull UserStyleSettinggetRootUserStyleSettings()

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

getUserStyleSettings

Added in 1.0.0
Deprecated in 1.2.0
public final @NonNull List<@NonNull UserStyleSettinggetUserStyleSettings()

toString

public @NonNull String toString()