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 optional icon associated with the complication data.

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

setMonochromaticImage

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

Sets optional icon associated with the complication data.

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.