RangedValueComplicationData


public final class RangedValueComplicationData extends ComplicationData


Type used for complications including a numerical value within a range, such as a percentage. The value may be accompanied by an icon and/or short text and title.

The min and max fields are required for this type, as well as one of value or dynamicValue. The value within the range is expected to always be displayed.

The icon, title, and text fields are optional and the watch face may choose which of these fields to display, if any.

If a monochromaticImage and a smallImage are both specified then only one should be displayed. If the complication is drawn with a single color it's recommended to choose monochromaticImage and apply a tint. If the complication is rendered with multiple colors it's recommended to choose the smallImage. It's best practice for a ComplicationDataSource to specify both a monochromaticImage and a smallImage.

A data source that wants to serve a RangedValueComplicationData must include the following meta data in its manifest (NB the value is a comma separated list):

<meta-data android:name="android.support.wearable.complications.SUPPORTED_TYPES"
android:value="RANGED_VALUE"/>

Summary

Nested types

Builder for RangedValueComplicationData.

Constants

static final int

The ranged value represents a percentage in the range 0..100.

static final int

The ranged value represents a rating or score for something unrelated to the user, e.g. the air quality index or the UV index.

static final int

The ranged value's semantic hasn't been explicitly defined, most commonly it's a percentage however.

Public fields

static final float

Used to signal the range should be rendered as a placeholder.

static final @NonNull ComplicationType

The ComplicationType corresponding to objects of this type.

Public methods

final ColorRamp

Optional hint to render the value with the specified ColorRamp.

final ComplicationText

The content description field for accessibility.

final DynamicBuilders.DynamicFloat

The DynamicFloat optionally set by the data source.

final float

The maximum Float value for this complication.

final float

The minimum Float value for this complication.

final MonochromaticImage

A simple MonochromaticImage image that can be tinted by the watch face.

@NonNull Instant

Returns the next Instant after afterInstant at which any field of the complication may change.

final SmallImage

A SmallImage that is expected to cover a small fraction of a watch face occupied by a single complication.

final ComplicationText

The body ComplicationText of the complication.

final ComplicationText

The optional title ComplicationText.

final float

The Float value of this complication which is >= min and <= max or equal to PLACEHOLDER.

final int

The semantic meaning of value.

boolean

Returns true if any of the fields of this ComplicationData are placeholders.

@NonNull String

Inherited methods

From androidx.wear.watchface.complications.data.ComplicationData
boolean
equals(Object other)
final ComponentName

The ComponentName of the androidx.wear.watchface.complications.datasource.ComplicationDataSourceService that provided the ComplicationData.

final int

The display policy for this complication.

final ComplicationData

Used in case any dynamic value has been invalidated.

final int

The persistence policy for this complication.

final PendingIntent

The PendingIntent to send when the complication is tapped on.

final boolean

tapAction which is a PendingIntent unfortunately can't be serialized.

final @NonNull ComplicationType

The ComplicationType of this complication data.

final @NonNull TimeRange

The TimeRange within which the complication should be displayed.

int
final void
setTapActionLostDueToSerialization(
    boolean tapActionLostDueToSerialization
)

tapAction which is a PendingIntent unfortunately can't be serialized.

Constants

TYPE_PERCENTAGE

public static final int TYPE_PERCENTAGE = 2

The ranged value represents a percentage in the range 0..100. E.g. Battery charge.

TYPE_RATING

public static final int TYPE_RATING = 1

The ranged value represents a rating or score for something unrelated to the user, e.g. the air quality index or the UV index.

TYPE_UNDEFINED

public static final int TYPE_UNDEFINED = 0

The ranged value's semantic hasn't been explicitly defined, most commonly it's a percentage however.

Public fields

PLACEHOLDER

public static final float PLACEHOLDER

Used to signal the range should be rendered as a placeholder. It's suggested that a placeholder ranged value be drawn as a grey arc with a percentage value selected by the renderer.

Note a placeholder may only be used in the context of NoDataComplicationData.placeholder.

TYPE

public static final @NonNull ComplicationType TYPE

The ComplicationType corresponding to objects of this type.

Public methods

getColorRamp

Added in 1.2.0
public final ColorRamp getColorRamp()

Optional hint to render the value with the specified ColorRamp. When present the renderer may choose to use the ColorRamp when rendering the progress bar.

getContentDescription

Added in 1.0.0
public final ComplicationText getContentDescription()

The content description field for accessibility.

getDynamicValue

Added in 1.2.0
@RequiresApi(value = 33)
public final DynamicBuilders.DynamicFloat getDynamicValue()

The DynamicFloat optionally set by the data source. If present the system will dynamically evaluate this and store the result in value. Watch faces can typically ignore this field.

getMax

Added in 1.0.0
public final float getMax()

The maximum Float value for this complication.

getMin

Added in 1.0.0
public final float getMin()

The minimum Float value for this complication.

getMonochromaticImage

Added in 1.0.0
public final MonochromaticImage getMonochromaticImage()

A simple MonochromaticImage image that can be tinted by the watch face. If the monochromaticImage is equal to MonochromaticImage.PLACEHOLDER the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

getNextChangeInstant

public @NonNull Instant getNextChangeInstant(@NonNull Instant afterInstant)

Returns the next Instant after afterInstant at which any field of the complication may change. If there's no scheduled changes then Instant.MAX will be returned.

See ComplicationText.getNextChangeTime

Parameters
@NonNull Instant afterInstant

The reference Instant, after which changes will be reported.

getSmallImage

Added in 1.2.0
public final SmallImage getSmallImage()

A SmallImage that is expected to cover a small fraction of a watch face occupied by a single complication. If the smallImage is equal to SmallImage.PLACEHOLDER the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

getText

Added in 1.0.0
public final ComplicationText getText()

The body ComplicationText of the complication. The length of the text, including any time-dependent values at any valid time, is expected to not exceed seven characters. When using this text, the watch face should be able to display any string of up to seven characters (reducing the text size appropriately if the string is very wide). Although not expected, it is possible that strings of more than seven characters might be seen, in which case they may be truncated. If the text is equal to ComplicationText.PLACEHOLDER the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

getTitle

Added in 1.0.0
public final ComplicationText getTitle()

The optional title ComplicationText. The length of the title, including any time-dependent values at any valid time, is expected to not exceed seven characters. When using this text, the watch face should be able to display any string of up to seven characters (reducing the text size appropriately if the string is very wide). Although not expected, it is possible that strings of more than seven characters might be seen, in which case they may be truncated. If the title is equal to ComplicationText.PLACEHOLDER the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

getValue

Added in 1.0.0
public final float getValue()

The Float value of this complication which is >= min and <= max or equal to PLACEHOLDER. If it's equal to PLACEHOLDER the renderer must treat it as a placeholder rather than rendering normally, its suggested to be drawn as a grey arc with a percentage value selected by the renderer. The semantic meaning of value is described by valueType.

getValueType

Added in 1.2.0
public final int getValueType()

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.

hasPlaceholderFields

public boolean hasPlaceholderFields()

Returns true if any of the fields of this ComplicationData are placeholders. I.e. if any fields are equal to: ComplicationText.PLACEHOLDER, SmallImage.PLACEHOLDER, MonochromaticImage.PLACEHOLDER, PhotoImageComplicationData.PLACEHOLDER, or RangedValueComplicationData.PLACEHOLDER.

toString

public @NonNull String toString()