GoalProgressComplicationData.Builder

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


Builder for GoalProgressComplicationData.

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

Summary

Public constructors

Builder(
    float value,
    float targetValue,
    @NonNull ComplicationText contentDescription
)

Creates a Builder for a GoalProgressComplicationData with a Float value.

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

Creates a Builder for a GoalProgressComplicationData with a DynamicFloat value.

Public methods

@NonNull GoalProgressComplicationData

Builds the GoalProgressComplicationData.

final @NonNull GoalProgressComplicationData.Builder

Sets an optional hint which suggests the renderer draws the complication using a ColorRamp.

final @NonNull GoalProgressComplicationData.Builder

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

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

Sets the complication's display policy.

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

Sets optional icon associated with the complication data.

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

Sets the complication's persistence policy.

final @NonNull GoalProgressComplicationData.Builder

Sets optional image associated with the complication data.

final @NonNull GoalProgressComplicationData.Builder

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

final @NonNull GoalProgressComplicationData.Builder

Sets optional text associated with the complication data.

final @NonNull GoalProgressComplicationData.Builder

Sets optional title associated with the complication data.

final @NonNull GoalProgressComplicationData.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(
    float value,
    float targetValue,
    @NonNull ComplicationText contentDescription
)

Creates a Builder for a GoalProgressComplicationData with a Float value.

Parameters
float value

The value of the goal complication which should be >= 0.

float targetValue

The target value. This must be less than Float.MAX_VALUE.

@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 targetValue,
    @NonNull ComplicationText contentDescription
)

Creates a Builder for a GoalProgressComplicationData with a DynamicFloat value.

Parameters
@NonNull DynamicBuilders.DynamicFloat dynamicValue

The DynamicFloat of the goal complication which will be evaluated into a value dynamically, and should be >= 0.

float fallbackValue

The fallback value of the goal complication which will be used on systems that don't support dynamicValue, and should be >= 0.

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 the dynamicValue cannot be evaluated, e.g. when a data source is not available.

float targetValue

The target value. This must be less than Float.MAX_VALUE.

@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 GoalProgressComplicationData.Builder setColorRamp(ColorRamp colorRamp)

Sets an optional hint which suggests the renderer draws the complication using a ColorRamp.

setDataSource

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

Sets the complication's display policy.

setDynamicValueInvalidationFallback

Added in 1.3.0-alpha01
public final @NonNull GoalProgressComplicationData.Builder setDynamicValueInvalidationFallback(
    GoalProgressComplicationData 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.2.0
public final @NonNull GoalProgressComplicationData.Builder setMonochromaticImage(MonochromaticImage monochromaticImage)

Sets optional icon associated with the complication data.

setPersistencePolicy

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

Sets the complication's persistence policy.

setSmallImage

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

Sets optional image associated with the complication data.

setTapAction

Added in 1.2.0
public final @NonNull GoalProgressComplicationData.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 GoalProgressComplicationData.Builder setText(ComplicationText text)

Sets optional text associated with the complication data.

setTitle

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

Sets optional title associated with the complication data.

setValidTimeRange

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

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