UserStyleSetting.ListUserStyleSetting.ListOption


public final class UserStyleSetting.ListUserStyleSetting.ListOption extends 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(
    @NonNull UserStyleSetting.Option.Id id,
    @NonNull Resources resources,
    @StringRes int displayNameResourceId,
    Icon icon,
    UserStyleSetting.WatchFaceEditorData watchFaceEditorData
)

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

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

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

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

Constructs a ListOption.

ListOption(
    @NonNull UserStyleSetting.Option.Id id,
    @NonNull Resources resources,
    @StringRes int displayNameResourceId,
    @StringRes int screenReaderNameResourceId,
    @NonNull Function0<Icon> iconProvider,
    @NonNull Collection<@NonNull UserStyleSetting> childSettings,
    UserStyleSetting.WatchFaceEditorData watchFaceEditorData
)

Constructs a ListOption with a lazily evaluated icon.

Public methods

final @NonNull CharSequence

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

final Icon

Icon for use in the companion style selection UI.

final CharSequence

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

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

final void
setScreenReaderNameInternal(DisplayText screenReaderNameInternal)

Backing field for screenReaderName.

Inherited methods

From androidx.wear.watchface.style.UserStyleSetting.Option
boolean
equals(Object other)
final @NonNull Collection<@NonNull UserStyleSetting>

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

final @NonNull UserStyleSetting.Option.Id

Machine readable Id for the style setting.

int
@NonNull String

Public constructors

ListOption

Added in 1.1.0
Deprecated in 1.2.0
public ListOption(
    @NonNull UserStyleSetting.Option.Id id,
    @NonNull Resources resources,
    @StringRes int displayNameResourceId,
    Icon icon,
    UserStyleSetting.WatchFaceEditorData watchFaceEditorData
)

Constructs a ListOption.

Parameters
@NonNull UserStyleSetting.Option.Id id

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

@NonNull Resources resources

The Resources used to load displayNameResourceId.

@StringRes int displayNameResourceId

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)

UserStyleSetting.WatchFaceEditorData 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.

ListOption

public ListOption(
    @NonNull UserStyleSetting.Option.Id id,
    @NonNull Resources resources,
    @StringRes int displayNameResourceId,
    Icon icon,
    @NonNull Collection<@NonNull UserStyleSetting> childSettings,
    UserStyleSetting.WatchFaceEditorData watchFaceEditorData
)

Constructs a ListOption.

Parameters
@NonNull UserStyleSetting.Option.Id id

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

@NonNull Resources resources

The Resources used to load displayNameResourceId.

@StringRes int displayNameResourceId

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

@NonNull Collection<@NonNull UserStyleSetting> childSettings

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

UserStyleSetting.WatchFaceEditorData 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.

ListOption

public ListOption(
    @NonNull UserStyleSetting.Option.Id id,
    @NonNull Resources resources,
    @StringRes int displayNameResourceId,
    @StringRes int screenReaderNameResourceId,
    Icon icon,
    @NonNull Collection<@NonNull UserStyleSetting> childSettings,
    UserStyleSetting.WatchFaceEditorData watchFaceEditorData
)

Constructs a ListOption.

Parameters
@NonNull UserStyleSetting.Option.Id id

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

@NonNull Resources resources

The Resources used to load displayNameResourceId.

@StringRes int displayNameResourceId

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.

@StringRes int screenReaderNameResourceId

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

@NonNull Collection<@NonNull UserStyleSetting> childSettings

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

UserStyleSetting.WatchFaceEditorData 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.

ListOption

public ListOption(
    @NonNull UserStyleSetting.Option.Id id,
    @NonNull Resources resources,
    @StringRes int displayNameResourceId,
    @StringRes int screenReaderNameResourceId,
    @NonNull Function0<Icon> iconProvider,
    @NonNull Collection<@NonNull UserStyleSetting> childSettings,
    UserStyleSetting.WatchFaceEditorData watchFaceEditorData
)

Constructs a ListOption with a lazily evaluated icon.

Parameters
@NonNull UserStyleSetting.Option.Id id

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

@NonNull Resources resources

The Resources used to load displayNameResourceId.

@StringRes int displayNameResourceId

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.

@StringRes int screenReaderNameResourceId

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.

@NonNull Function0<Icon> iconProvider

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.

@NonNull Collection<@NonNull UserStyleSetting> childSettings

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

UserStyleSetting.WatchFaceEditorData 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 methods

getDisplayName

Added in 1.0.0
public final @NonNull CharSequence getDisplayName()

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

getIcon

Added in 1.0.0
public final Icon getIcon()

Icon for use in the companion style selection UI.

getScreenReaderName

Added in 1.2.0
public final CharSequence getScreenReaderName()

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.

getWatchFaceEditorData

Added in 1.1.0
public final UserStyleSetting.WatchFaceEditorData getWatchFaceEditorData()

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.

setScreenReaderNameInternal

public final void setScreenReaderNameInternal(DisplayText screenReaderNameInternal)

Backing field for screenReaderName.