WeightedElementsComplicationData.Builder

@RequiresApi(value = 33)
public final class WeightedElementsComplicationData.Builder


Builder for WeightedElementsComplicationData.

You must at a minimum set the elements field and at least one of monochromaticImage, smallImage, text or title.

Summary

Public constructors

Public methods

@NonNull WeightedElementsComplicationData

Builds the GoalProgressComplicationData.

final @NonNull WeightedElementsComplicationData.Builder

Sets the ComponentName of the ComplicationDataSourceService that provided this ComplicationData, if any.

final @NonNull WeightedElementsComplicationData.Builder
@RequiresApi(value = 33)
setDisplayPolicy(int displayPolicy)

Sets the complication's display policy.

final @NonNull WeightedElementsComplicationData.Builder

Sets the complication's fallback, used in case any dynamic value cannot be evaluated, e.g. when a data source is not available.

final @NonNull WeightedElementsComplicationData.Builder
setElementBackgroundColor(@ColorInt int elementBackgroundColor)

Sets the background color to use between the elements if they are drawn segmented.

final @NonNull WeightedElementsComplicationData.Builder

Sets optional icon associated with the complication data.

final @NonNull WeightedElementsComplicationData.Builder
@RequiresApi(value = 33)
setPersistencePolicy(int persistencePolicy)

Sets the complication's persistence policy.

final @NonNull WeightedElementsComplicationData.Builder

Sets optional image associated with the complication data.

final @NonNull WeightedElementsComplicationData.Builder

Sets optional pending intent to be invoked when the complication is tapped.

final @NonNull WeightedElementsComplicationData.Builder

Sets optional text associated with the complication data.

final @NonNull WeightedElementsComplicationData.Builder

Sets optional title associated with the complication data.

final @NonNull WeightedElementsComplicationData.Builder
setValidTimeRange(TimeRange validTimeRange)

Sets optional time range during which the complication has to be shown.

Public constructors

Builder

Added in 1.2.0
public Builder(
    @NonNull List<@NonNull WeightedElementsComplicationData.Element> elements,
    @NonNull ComplicationText contentDescription
)
Parameters
@NonNull List<@NonNull WeightedElementsComplicationData.Element> elements

The breakdown of the subject into various Elements. E.g. the proportion of calories consumed which were carbohydrates, fats etc... The tapAction must take the user to an experience where the color key becomes obvious. The maximum valid size of this list is provided by getMaxElements.

@NonNull ComplicationText contentDescription

Defines localized text that briefly describes content of the complication. This property is used primarily for accessibility. Since some complications do not have textual representation this attribute can be used for providing such. Please do not include the word 'complication' in the description.

Public methods

setDataSource

Added in 1.2.0
public final @NonNull WeightedElementsComplicationData.Builder setDataSource(ComponentName dataSource)

Sets the ComponentName of the ComplicationDataSourceService that provided this ComplicationData, if any.

Note a ComplicationDataSourceService does not need to call this because the system will set this value on its behalf.

setDisplayPolicy

Added in 1.2.0
@RequiresApi(value = 33)
public final @NonNull WeightedElementsComplicationData.Builder setDisplayPolicy(int displayPolicy)

Sets the complication's display policy.

setDynamicValueInvalidationFallback

Added in 1.3.0-alpha01
public final @NonNull WeightedElementsComplicationData.Builder setDynamicValueInvalidationFallback(
    WeightedElementsComplicationData fallback
)

Sets the complication's fallback, used in case any dynamic value cannot be evaluated, e.g. when a data source is not available.

IMPORTANT: This is only used when the system supports dynamic values. See each dynamic value field's fallback companion field for the situation where the system does not support dynamic values at all.

setElementBackgroundColor

Added in 1.2.0
public final @NonNull WeightedElementsComplicationData.Builder setElementBackgroundColor(@ColorInt int elementBackgroundColor)

Sets the background color to use between the elements if they are drawn segmented. Defaults to Color.TRANSPARENT if not set.

setMonochromaticImage

Added in 1.2.0
public final @NonNull WeightedElementsComplicationData.Builder setMonochromaticImage(MonochromaticImage monochromaticImage)

Sets optional icon associated with the complication data.

setPersistencePolicy

Added in 1.2.0
@RequiresApi(value = 33)
public final @NonNull WeightedElementsComplicationData.Builder setPersistencePolicy(int persistencePolicy)

Sets the complication's persistence policy.

setSmallImage

Added in 1.2.0
public final @NonNull WeightedElementsComplicationData.Builder setSmallImage(SmallImage smallImage)

Sets optional image associated with the complication data.

setTapAction

Added in 1.2.0
public final @NonNull WeightedElementsComplicationData.Builder setTapAction(PendingIntent tapAction)

Sets optional pending intent to be invoked when the complication is tapped.

setText

Added in 1.2.0
public final @NonNull WeightedElementsComplicationData.Builder setText(ComplicationText text)

Sets optional text associated with the complication data.

setTitle

Added in 1.2.0
public final @NonNull WeightedElementsComplicationData.Builder setTitle(ComplicationText title)

Sets optional title associated with the complication data.

setValidTimeRange

Added in 1.2.0
public final @NonNull WeightedElementsComplicationData.Builder setValidTimeRange(TimeRange validTimeRange)

Sets optional time range during which the complication has to be shown.