UserStyleSetting.ListUserStyleSetting.ListOption


class UserStyleSetting.ListUserStyleSetting.ListOption : UserStyleSetting.Option


Represents choice within a ListUserStyleSetting, these must be enumerated up front.

If childSettings is not empty, then an editor needs to treat this as a node in a hierarchy of editor widgets.

Summary

Public constructors

ListOption(
    id: UserStyleSetting.Option.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    icon: Icon?,
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData?
)

This function is deprecated. Use a constructor that sets the screenReaderNameResourceId

ListOption(
    id: UserStyleSetting.Option.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    icon: Icon?,
    childSettings: Collection<UserStyleSetting>,
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData?
)

This function is deprecated. Use a constructor that sets the screenReaderNameResourceId

ListOption(
    id: UserStyleSetting.Option.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    screenReaderNameResourceId: @StringRes Int,
    icon: Icon?,
    childSettings: Collection<UserStyleSetting>,
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData?
)

Constructs a ListOption.

ListOption(
    id: UserStyleSetting.Option.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    screenReaderNameResourceId: @StringRes Int,
    iconProvider: () -> Icon?,
    childSettings: Collection<UserStyleSetting>,
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData?
)

Constructs a ListOption with a lazily evaluated icon.

Public properties

CharSequence

Localized human readable name for the setting, used in the editor style selection UI.

Icon?

Icon for use in the companion style selection UI.

CharSequence?

Optional localized human readable name for the setting, used by screen readers.

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.

Inherited functions

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

Inherited properties

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

The list of child UserStyleSettings, if any, forming a hierarchy of UserStyleSettings.

UserStyleSetting.Option.Id

Machine readable Id for the style setting.

Public constructors

ListOption

Added in 1.1.0
Deprecated in 1.2.0
ListOption(
    id: UserStyleSetting.Option.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    icon: Icon?,
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData? = null
)

Constructs a ListOption.

Parameters
id: UserStyleSetting.Option.Id

The Id of this ListOption, must be unique within the ListUserStyleSetting.

resources: Resources

The Resources used to load displayNameResourceId.

displayNameResourceId: @StringRes Int

String resource id for a human readable name for the element, used in the userStyle selection UI. This should be short, ideally < 20 characters. Note if the resource string contains %1$s that will get replaced with the 1-based ordinal (1st, 2nd, 3rd etc...) of the ListOption in the list of ListOptions.

icon: Icon?

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

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.

ListOption

ListOption(
    id: UserStyleSetting.Option.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    icon: Icon?,
    childSettings: Collection<UserStyleSetting> = emptyList(),
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData? = null
)

Constructs a ListOption.

Parameters
id: UserStyleSetting.Option.Id

The Id of this ListOption, must be unique within the ListUserStyleSetting.

resources: Resources

The Resources used to load displayNameResourceId.

displayNameResourceId: @StringRes Int

String resource id for a human readable name for the element, used in the userStyle selection UI. This should be short, ideally < 20 characters.

icon: Icon?

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

childSettings: Collection<UserStyleSetting> = emptyList()

The list of child UserStyleSettings, which may be empty. Any child settings must be listed in UserStyleSchema.userStyleSettings.

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.

ListOption

ListOption(
    id: UserStyleSetting.Option.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    screenReaderNameResourceId: @StringRes Int,
    icon: Icon?,
    childSettings: Collection<UserStyleSetting> = emptyList(),
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData? = null
)

Constructs a ListOption.

Parameters
id: UserStyleSetting.Option.Id

The Id of this ListOption, must be unique within the ListUserStyleSetting.

resources: Resources

The Resources used to load displayNameResourceId.

displayNameResourceId: @StringRes Int

String resource id for a human readable name for the element, used in the userStyle selection UI. This should be short, ideally < 20 characters. Note if the resource string contains %1$s that will get replaced with the 1-based ordinal (1st, 2nd, 3rd etc...) of the ListOption in the list of ListOptions.

screenReaderNameResourceId: @StringRes Int

String resource id for a human readable name for the element, used by screen readers. This should be more descriptive than displayNameResourceId. Note if the resource string contains %1$s that will get replaced with the 1-based ordinal (1st, 2nd, 3rd etc...) of the ListOption in the list of ListOptions. Note prior to android T this is ignored by companion editors.

icon: Icon?

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

childSettings: Collection<UserStyleSetting> = emptyList()

The list of child UserStyleSettings, which may be empty. Any child settings must be listed in UserStyleSchema.userStyleSettings.

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.

ListOption

ListOption(
    id: UserStyleSetting.Option.Id,
    resources: Resources,
    displayNameResourceId: @StringRes Int,
    screenReaderNameResourceId: @StringRes Int,
    iconProvider: () -> Icon?,
    childSettings: Collection<UserStyleSetting> = emptyList(),
    watchFaceEditorData: UserStyleSetting.WatchFaceEditorData? = null
)

Constructs a ListOption with a lazily evaluated icon.

Parameters
id: UserStyleSetting.Option.Id

The Id of this ListOption, must be unique within the ListUserStyleSetting.

resources: Resources

The Resources used to load displayNameResourceId.

displayNameResourceId: @StringRes Int

String resource id for a human readable name for the element, used in the userStyle selection UI. This should be short, ideally < 20 characters. Note if the resource string contains %1$s that will get replaced with the 1-based ordinal (1st, 2nd, 3rd etc...) of the ListOption in the list of ListOptions.

screenReaderNameResourceId: @StringRes Int

String resource id for a human readable name for the element, used by screen readers. This should be more descriptive than displayNameResourceId. Note if the resource string contains %1$s that will get replaced with the 1-based ordinal (1st, 2nd, 3rd etc...) of the ListOption in the list of ListOptions. Note prior to android T this is ignored by companion editors.

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.

childSettings: Collection<UserStyleSetting> = emptyList()

The list of child UserStyleSettings, which may be empty. Any child settings must be listed in UserStyleSchema.userStyleSettings.

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.

Public properties

displayName

Added in 1.0.0
val displayNameCharSequence

Localized human readable name for the setting, used in the editor style selection UI. This should be short (ideally < 20 characters).

icon

Added in 1.0.0
val iconIcon?

Icon for use in the companion style selection UI.

screenReaderName

Added in 1.2.0
val screenReaderNameCharSequence?

Optional localized human readable name for the setting, used by screen readers. This should be more descriptive than displayName. Note prior to android T this is ignored by companion editors.

watchFaceEditorData

Added in 1.1.0
val watchFaceEditorDataUserStyleSetting.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.