RangedValueComplicationData.Builder

public final class RangedValueComplicationData.Builder


Builder for RangedValueComplicationData.

You must at a minimum set the min, max and contentDescription fields, at least one of value or dynamicValue, and at least one of monochromaticImage, smallImage, text or title.

Summary

Public constructors

@RequiresApi(value = 34)
Builder(
    @NonNull DynamicBuilders.DynamicFloat dynamicValue,
    float min,
    float max,
    @NonNull ComplicationText contentDescription
)

Creates a Builder for a RangedValueComplicationData with a DynamicFloat value, and no fallbackValue for API levels known to support dynamic values.

Builder(
    float value,
    float min,
    float max,
    @NonNull ComplicationText contentDescription
)

Creates a Builder for a RangedValueComplicationData with a Float value.

@RequiresApi(value = 33)
Builder(
    @NonNull DynamicBuilders.DynamicFloat dynamicValue,
    float fallbackValue,
    float min,
    float max,
    @NonNull ComplicationText contentDescription
)

Creates a Builder for a RangedValueComplicationData with a DynamicFloat value.

Public methods

@NonNull RangedValueComplicationData

Builds the RangedValueComplicationData.

final @NonNull RangedValueComplicationData.Builder

Sets an optional hint that the renderer should draw the progress bar using the ColorRamp.

final @NonNull RangedValueComplicationData.Builder

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

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

Sets the complication's display policy.

final @NonNull RangedValueComplicationData.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 RangedValueComplicationData.Builder

Sets optional icon associated with the complication data.

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

Sets the complication's persistence policy.

final @NonNull RangedValueComplicationData.Builder

Sets optional image associated with the complication data.

final @NonNull RangedValueComplicationData.Builder

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

final @NonNull RangedValueComplicationData.Builder

Sets optional text associated with the complication data.

final @NonNull RangedValueComplicationData.Builder

Sets optional title associated with the complication data.

final @NonNull RangedValueComplicationData.Builder
setValidTimeRange(TimeRange validTimeRange)

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

final @NonNull RangedValueComplicationData.Builder
setValueType(int valueType)

Sets the semantic meaning of value.

Public constructors

Builder

Added in 1.3.0-alpha01
@RequiresApi(value = 34)
public Builder(
    @NonNull DynamicBuilders.DynamicFloat dynamicValue,
    float min,
    float max,
    @NonNull ComplicationText contentDescription
)

Creates a Builder for a RangedValueComplicationData with a DynamicFloat value, and no fallbackValue for API levels known to support dynamic values.

Parameters
@NonNull DynamicBuilders.DynamicFloat dynamicValue

The DynamicFloat of the ranged complication which will be evaluated into a value dynamically, and should be in the range [min] .. [max]. The semantic meaning of value can be specified via setValueType.

float min

The minimum value. For TYPE_PERCENTAGE this must be 0f.

float max

The maximum value. This must be less than Float.MAX_VALUE. For TYPE_PERCENTAGE this must be 0f.

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

Builder

Added in 1.0.0
public Builder(
    float value,
    float min,
    float max,
    @NonNull ComplicationText contentDescription
)

Creates a Builder for a RangedValueComplicationData with a Float value.

Parameters
float value

The value of the ranged complication which should be in the range [min] .. [max]. The semantic meaning of value can be specified via setValueType.

float min

The minimum value. For TYPE_PERCENTAGE this must be 0f.

float max

The maximum value. This must be less than Float.MAX_VALUE. For TYPE_PERCENTAGE this must be 0f.

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

Builder

Added in 1.2.0
@RequiresApi(value = 33)
public Builder(
    @NonNull DynamicBuilders.DynamicFloat dynamicValue,
    float fallbackValue,
    float min,
    float max,
    @NonNull ComplicationText contentDescription
)

Creates a Builder for a RangedValueComplicationData with a DynamicFloat value.

Parameters
@NonNull DynamicBuilders.DynamicFloat dynamicValue

The DynamicFloat of the ranged complication which will be evaluated into a value dynamically, and should be in the range [min] .. [max]. The semantic meaning of value can be specified via setValueType.

float fallbackValue

The fallback value of the ranged complication used on systems that don't support dynamicValue, which should be in the range [min] .. [max]. The semantic meaning of value can be specified via setValueType.

This is only relevant before Build.VERSION_CODES.UPSIDE_DOWN_CAKE, use the no-fallback constructor if you target an equal or higher API level.

IMPORTANT: This is only used when the system does not support dynamicValue at all. See setDynamicValueInvalidationFallback for the situation where dynamicValue cannot be evaluated, e.g. when a data source is not available.

float min

The minimum value. For TYPE_PERCENTAGE this must be 0f.

float max

The maximum value. This must be less than Float.MAX_VALUE. For TYPE_PERCENTAGE this must be 0f.

@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

setColorRamp

Added in 1.2.0
public final @NonNull RangedValueComplicationData.Builder setColorRamp(ColorRamp colorRamp)

Sets an optional hint that the renderer should draw the progress bar using the ColorRamp.

setDataSource

Added in 1.1.0
public final @NonNull RangedValueComplicationData.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 RangedValueComplicationData.Builder setDisplayPolicy(int displayPolicy)

Sets the complication's display policy.

setDynamicValueInvalidationFallback

Added in 1.3.0-alpha01
public final @NonNull RangedValueComplicationData.Builder setDynamicValueInvalidationFallback(
    RangedValueComplicationData 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.

setMonochromaticImage

Added in 1.0.0
public final @NonNull RangedValueComplicationData.Builder setMonochromaticImage(MonochromaticImage monochromaticImage)

Sets optional icon associated with the complication data.

setPersistencePolicy

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

Sets the complication's persistence policy.

setSmallImage

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

Sets optional image associated with the complication data.

setTapAction

Added in 1.0.0
public final @NonNull RangedValueComplicationData.Builder setTapAction(PendingIntent tapAction)

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

setText

Added in 1.0.0
public final @NonNull RangedValueComplicationData.Builder setText(ComplicationText text)

Sets optional text associated with the complication data.

setTitle

Added in 1.0.0
public final @NonNull RangedValueComplicationData.Builder setTitle(ComplicationText title)

Sets optional title associated with the complication data.

setValidTimeRange

Added in 1.0.0
public final @NonNull RangedValueComplicationData.Builder setValidTimeRange(TimeRange validTimeRange)

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

setValueType

Added in 1.2.0
public final @NonNull RangedValueComplicationData.Builder setValueType(int valueType)

Sets the semantic meaning of value. The complication renderer may choose to visually differentiate between the different types, for example rendering a dot on a line/arc to indicate the value for a TYPE_RATING. Defaults to TYPE_UNDEFINED if not set.