ComplicationData.Builder
public
static
final
class
ComplicationData.Builder
extends Object
| java.lang.Object | |
| ↳ | com.google.wear.services.complications.ComplicationData.Builder |
Builder class for ComplicationData.
Summary
Public constructors | |
|---|---|
Builder(ComplicationData data)
|
|
Builder(int type)
|
|
Builder(int type, Map<String, Object> fields)
|
|
Public methods | |
|---|---|
ComplicationData
|
build()
Constructs and returns |
ComplicationData.Builder
|
clearColorRampInterpolated()
Clears the value of the color ramp interpolated field. |
ComplicationData.Builder
|
clearEndDateTime()
Removes the end time for this complication data. |
ComplicationData.Builder
|
clearRangedMaxValue()
Clears the ranged max value for this Complication Data. |
ComplicationData.Builder
|
clearRangedMinValue()
Clears the ranged min value for this Complication Data. |
ComplicationData.Builder
|
clearRangedValue()
Removes the ranged value for this complication data. |
ComplicationData.Builder
|
clearStartDateTime()
Removes the start time for this complication data. |
ComplicationData.Builder
|
clearTargetValue()
Clears the target value for this Complication Data. |
ComplicationData.Builder
|
setBurnInProtectionIcon(Icon icon)
Sets the burn-in protection version of the icon field. |
ComplicationData.Builder
|
setBurnInProtectionSmallImage(Icon smallImage)
Sets the burn-in protection version of the small image field. |
ComplicationData.Builder
|
setColorRamp(int[] colorRamp)
Optional. |
ComplicationData.Builder
|
setColorRampInterpolated(boolean colorRampInterpolated)
Optional. |
ComplicationData.Builder
|
setContentDescription(ComplicationText description)
Sets the content description field for accessibility. |
ComplicationData.Builder
|
setDataSource(ComponentName provider)
Sets the |
ComplicationData.Builder
|
setDisplayPolicy(int displayPolicy)
Sets the complication's complication display policy. |
ComplicationData.Builder
|
setElementBackgroundColor(int elementBackgroundColor)
Sets the background color to use between elements for this complication. |
ComplicationData.Builder
|
setElementColors(int[] elementColors)
Sets the element colors for this complication. |
ComplicationData.Builder
|
setElementWeights(float[] elementWeights)
Sets the element weights for this complication. |
ComplicationData.Builder
|
setEndDateTimeMillis(long endDateTimeMillis)
Sets the end time for this complication data. |
ComplicationData.Builder
|
setExtras(PersistableBundle extras)
Sets any extras. |
ComplicationData.Builder
|
setIcon(Icon icon)
Sets the icon field for this Complication Data. |
ComplicationData.Builder
|
setInvalidatedData(ComplicationData invalidatedData)
Sets the invalidated |
ComplicationData.Builder
|
setLargeImage(Icon largeImage)
Sets the large image field for this Complication Data. |
ComplicationData.Builder
|
setLongText(ComplicationText longText)
Sets long text field. |
ComplicationData.Builder
|
setLongTitle(ComplicationText longTitle)
Sets the long title field for this Complication Data. |
ComplicationData.Builder
|
setPersistencePolicy(int cachePolicy)
Sets the complication's |
ComplicationData.Builder
|
setPlaceholder(ComplicationData placeholder)
Sets the placeholder. |
ComplicationData.Builder
|
setRangedDynamicValue(ProtoLayoutDynamicFloat value)
Sets a dynamic float value for a ranged Complication Data. |
ComplicationData.Builder
|
setRangedMaxValue(float maxValue)
Sets the ranged max value field for this Complication Data. |
ComplicationData.Builder
|
setRangedMinValue(float minValue)
Sets the ranged min value field for this Complication Data. |
ComplicationData.Builder
|
setRangedValue(float value)
Sets the ranged value field for this Complication Data. |
ComplicationData.Builder
|
setRangedValueType(int valueType)
Sets the ranged value type field which provides meta data about the value. |
ComplicationData.Builder
|
setShortText(ComplicationText shortText)
Sets the short text field. |
ComplicationData.Builder
|
setShortTitle(ComplicationText shortTitle)
Sets the short title field. |
ComplicationData.Builder
|
setSmallImage(Icon smallImage)
Sets the small image field for this Complication Data. |
ComplicationData.Builder
|
setSmallImageStyle(int imageStyle)
Sets the display style for this complication data. |
ComplicationData.Builder
|
setStartDateTimeMillis(long startDateTimeMillis)
Sets the start time for this complication data. |
ComplicationData.Builder
|
setTapAction(PendingIntent pendingIntent)
Sets the tap action field for this Complication Data. |
ComplicationData.Builder
|
setTapActionLostDueToSerialization(boolean tapActionLostDueToSerialization)
Sets whether or not this ComplicationData has been serialized. |
ComplicationData.Builder
|
setTargetValue(float targetValue)
Sets the ranged target value field for this Complication Data. |
ComplicationData.Builder
|
setTimelineEndEpochSecond(long epochSecond)
For timeline entries. |
ComplicationData.Builder
|
setTimelineEntries(Collection<ComplicationData> timelineEntries)
Sets the list of |
ComplicationData.Builder
|
setTimelineStartEpochSecond(long epochSecond)
For timeline entries. |
Inherited methods | |
|---|---|
Public constructors
Builder
public Builder (ComplicationData data)
| Parameters | |
|---|---|
data |
ComplicationData |
Builder
public Builder (int type,
Map<String, Object> fields)| Parameters | |
|---|---|
type |
int: Value is one of the following:
|
fields |
Map |
Public methods
build
public ComplicationData build ()
Constructs and returns ComplicationData with the provided fields. All required
fields must be populated before this method is called.
| Returns | |
|---|---|
ComplicationData |
|
| Throws | |
|---|---|
IllegalStateException |
if the required fields have not been populated |
clearColorRampInterpolated
public ComplicationData.Builder clearColorRampInterpolated ()
Clears the value of the color ramp interpolated field. No-op if the field is not set.
Returns this Builder to allow chaining.
| Returns | |
|---|---|
ComplicationData.Builder |
|
clearEndDateTime
public ComplicationData.Builder clearEndDateTime ()
Removes the end time for this complication data.
Returns this Builder to allow chaining.
| Returns | |
|---|---|
ComplicationData.Builder |
|
clearRangedMaxValue
public ComplicationData.Builder clearRangedMaxValue ()
Clears the ranged max value for this Complication Data.
Returns Builder to allow chaining.
| Returns | |
|---|---|
ComplicationData.Builder |
|
clearRangedMinValue
public ComplicationData.Builder clearRangedMinValue ()
Clears the ranged min value for this Complication Data.
Returns Builder to allow chaining.
| Returns | |
|---|---|
ComplicationData.Builder |
|
clearRangedValue
public ComplicationData.Builder clearRangedValue ()
Removes the ranged value for this complication data.
Returns this Builder to allow chaining.
| Returns | |
|---|---|
ComplicationData.Builder |
|
clearStartDateTime
public ComplicationData.Builder clearStartDateTime ()
Removes the start time for this complication data.
Returns this Builder to allow chaining.
| Returns | |
|---|---|
ComplicationData.Builder |
|
clearTargetValue
public ComplicationData.Builder clearTargetValue ()
Clears the target value for this Complication Data.
Returns Builder to allow chaining.
| Returns | |
|---|---|
ComplicationData.Builder |
|
setBurnInProtectionIcon
public ComplicationData.Builder setBurnInProtectionIcon (Icon icon)
Sets the burn-in protection version of the icon field. This should be provided if the icon field is provided, unless the main icon is already safe for use with burn-in protection. This icon should have fewer lit pixels, and should use darker colors to prevent LCD burn in issues.
The provided image must be single-color, so that watch faces can tint it as required.
The provided image must not contain solid blocks of pixels - it should instead be composed of outlines or lines only.
If this field is set, the icon field must also be set using setIcon(Icon).
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
icon |
Icon |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setBurnInProtectionSmallImage
public ComplicationData.Builder setBurnInProtectionSmallImage (Icon smallImage)
Sets the burn-in protection version of the small image field. This should be provided if the small image field is provided, unless the main small image is already safe for use with burn-in protection.
The provided image must not contain solid blocks of pixels - it should instead be composed of outlines or lines only.
If this field is set, the small image field must also be set using setSmallImage(Icon).
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
smallImage |
Icon |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setColorRamp
public ComplicationData.Builder setColorRamp (int[] colorRamp)
Optional. Sets the color the color ramp should be drawn with.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
colorRamp |
int |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setColorRampInterpolated
public ComplicationData.Builder setColorRampInterpolated (boolean colorRampInterpolated)
Optional. Sets whether or not the color ramp should be smoothly shaded or drawn with steps.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
colorRampInterpolated |
boolean |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setContentDescription
public ComplicationData.Builder setContentDescription (ComplicationText description)
Sets the content description field for accessibility. This is optional for any non-empty type. It is recommended to provide a content description whenever the data includes an image.
The provided text will be read aloud by a Text-to-speech converter for users who may be vision-impaired. It will be read aloud in addition to any long, short, or range text in the complication.
If using to describe an image/icon that is purely stylistic and doesn't convey any information to the user, you may set the image content description to an empty string ("").
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
description |
ComplicationText |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setDataSource
public ComplicationData.Builder setDataSource (ComponentName provider)
Sets the ComponentName of the ComplicationDataSourceService that provided this
ComplicationData. Generally this field should be set and is only nullable for backwards
compatibility.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
provider |
ComponentName |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setDisplayPolicy
public ComplicationData.Builder setDisplayPolicy (int displayPolicy)
Sets the complication's display policy.
| Parameters | |
|---|---|
displayPolicy |
int: Value is either 0 or a combination of the following:
|
| Returns | |
|---|---|
ComplicationData.Builder |
|
setElementBackgroundColor
public ComplicationData.Builder setElementBackgroundColor (int elementBackgroundColor)
Sets the background color to use between elements for this complication.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
elementBackgroundColor |
int |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setElementColors
public ComplicationData.Builder setElementColors (int[] elementColors)
Sets the element colors for this complication.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
elementColors |
int |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setElementWeights
public ComplicationData.Builder setElementWeights (float[] elementWeights)
Sets the element weights for this complication.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
elementWeights |
float |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setEndDateTimeMillis
public ComplicationData.Builder setEndDateTimeMillis (long endDateTimeMillis)
Sets the end time for this complication data. This is optional for any type.
The complication data will be considered inactive (i.e. should not be displayed) if the current time is greater than the end time. If not specified, the data is considered active for all time after the start time (or always active if start time is also not specified).
Any non-positive values of endDateTimeMillis will leave this field unset.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
endDateTimeMillis |
long |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setExtras
public ComplicationData.Builder setExtras (PersistableBundle extras)
Sets any extras.
Requires "com.google.wear.permission.SET_COMPLICATION_EXTRAS"
| Parameters | |
|---|---|
extras |
PersistableBundle |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setIcon
public ComplicationData.Builder setIcon (Icon icon)
Sets the icon field for this Complication Data. This is required for the MONOCHROMATIC_IMAGE type, and is optional for the SHORT_TEXT, LONG_TEXT, and RANGED_VALUE types.
The provided image must be single-color, so that watch faces can tint it as required.
If the icon provided here is not suitable for display in ambient mode with burn-in
protection (e.g. if it includes solid blocks of pixels), then a burn-in safe version of
the icon must be provided via setBurnInProtectionIcon(android.graphics.drawable.Icon).
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
icon |
Icon |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setInvalidatedData
public ComplicationData.Builder setInvalidatedData (ComplicationData invalidatedData)
Sets the invalidated ComplicationData, used in ComplicationType.NO_DATA when generated by dynamic value
invalidation.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
invalidatedData |
ComplicationData |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setLargeImage
public ComplicationData.Builder setLargeImage (Icon largeImage)
Sets the large image field for this Complication Data. This is required for the LARGE_IMAGE type, and is not valid for any other
type.
The provided image should be suitably sized to fill the screen of the watch.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
largeImage |
Icon |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setLongText
public ComplicationData.Builder setLongText (ComplicationText longText)
Sets long text field. This is required for the LONG_TEXT type, and is not valid for any other
type.
The value must be provided as a ComplicationText object, so that
time-dependent values may be included.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
longText |
ComplicationText |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setLongTitle
public ComplicationData.Builder setLongTitle (ComplicationText longTitle)
Sets the long title field for this Complication Data. This is optional for the LONG_TEXT type, and is not valid for any other
type.
The value must be provided as a ComplicationText object, so that
time-dependent values may be included.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
longTitle |
ComplicationText |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setPersistencePolicy
public ComplicationData.Builder setPersistencePolicy (int cachePolicy)
Sets the complication's persistence policy.
| Parameters | |
|---|---|
cachePolicy |
int: Value is either 0 or a combination of the following:
|
| Returns | |
|---|---|
ComplicationData.Builder |
|
setPlaceholder
public ComplicationData.Builder setPlaceholder (ComplicationData placeholder)
Sets the placeholder.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
placeholder |
ComplicationData |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setRangedDynamicValue
public ComplicationData.Builder setRangedDynamicValue (ProtoLayoutDynamicFloat value)
Sets a dynamic float value for a ranged Complication Data. It is evaluated to a value
with the same limitations as setRangedValue(float).
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
value |
ProtoLayoutDynamicFloat |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setRangedMaxValue
public ComplicationData.Builder setRangedMaxValue (float maxValue)
Sets the ranged max value field for this Complication Data. This is required for the
RANGED_VALUE type, and is not valid for
any other type. A RANGED_VALUE complication visually presents a single value, which is usually a percentage. E.g. you
complication visually presents a single value, which is usually a percentage. E.g. you
have completed 70% of today's target of 10000 steps.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
maxValue |
float |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setRangedMinValue
public ComplicationData.Builder setRangedMinValue (float minValue)
Sets the ranged min value field for this Complication Data. This is required for the
ComplicationType.RANGED_VALUE type, and is not valid for
any other type. A ComplicationType.RANGED_VALUE
complication visually presents a single value, which is usually a percentage. E.g. you
have completed 70% of today's target of 10000 steps.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
minValue |
float |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setRangedValue
public ComplicationData.Builder setRangedValue (float value)
Sets the ranged value field for this Complication Data. This is required for the RANGED_VALUE type, and the GOAL_PROGRESS type. For RANGED_VALUE value must be in the range [min ..
max} for GOAL_PROGRESS value must be >=
and may be greater than target value.
Both the RANGED_VALUE complication and
the GOAL_PROGRESS complication visually
present a single value, which is usually a percentage. E.g. you have completed 70% of
today's target of 10000 steps.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
value |
float |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setRangedValueType
public ComplicationData.Builder setRangedValueType (int valueType)
Sets the ranged value type field which provides meta data about the value. This is
optional for the ComplicationType.RANGED_VALUE type.
| Parameters | |
|---|---|
valueType |
int |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setShortText
public ComplicationData.Builder setShortText (ComplicationText shortText)
Sets the short text field. This is required for the ComplicationType.SHORT_TEXT type, is optional for the ComplicationType.RANGED_VALUE and ComplicationType.NO_PERMISSION types, and is not valid for any
other type.
The value must be provided as a ComplicationText object, so that
time-dependent values may be included.
The length of the text, including any time-dependent values, should not exceed seven characters. If it does, the text may be truncated by the watch face or might not fit in the complication.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
shortText |
ComplicationText |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setShortTitle
public ComplicationData.Builder setShortTitle (ComplicationText shortTitle)
Sets the short title field. This is valid for the ComplicationType.SHORT_TEXT, ComplicationType.RANGED_VALUE, and ComplicationType.NO_PERMISSION types, and is not valid for any
other type.
The value must be provided as a ComplicationText object, so that
time-dependent values may be included.
The length of the text, including any time-dependent values, should not exceed seven characters. If it does, the text may be truncated by the watch face or might not fit in the complication.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
shortTitle |
ComplicationText |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setSmallImage
public ComplicationData.Builder setSmallImage (Icon smallImage)
Sets the small image field for this Complication Data. This is required for the ComplicationType.SMALL_IMAGE type, and is optional for the ComplicationType.LONG_TEXT type.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
smallImage |
Icon |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setSmallImageStyle
public ComplicationData.Builder setSmallImageStyle (int imageStyle)
Sets the display style for this complication data. This is valid only for types that
contain small images, i.e. ComplicationType.SMALL_IMAGE and ComplicationType.LONG_TEXT.
This affects how watch faces will draw the image in the complication.
If not specified, the default is IMAGE_STYLE_PHOTO.
| Parameters | |
|---|---|
imageStyle |
int: Value is one of the following:
|
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setStartDateTimeMillis
public ComplicationData.Builder setStartDateTimeMillis (long startDateTimeMillis)
Sets the start time for this complication data. This is optional for any type.
The complication data will be considered inactive (i.e. should not be displayed) if the current time is less than the start time. If not specified, the data is considered active for all time up to the end time (or always active if end time is also not specified).
Any non-positive values of startDateTimeMillis will leave this field unset.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
startDateTimeMillis |
long |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setTapAction
public ComplicationData.Builder setTapAction (PendingIntent pendingIntent)
Sets the tap action field for this Complication Data. This is optional for any non-empty type.
The provided PendingIntent may be fired if the complication is tapped on. Note
that some complications might not be tappable, in which case this field will be ignored.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
pendingIntent |
PendingIntent |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setTapActionLostDueToSerialization
public ComplicationData.Builder setTapActionLostDueToSerialization (boolean tapActionLostDueToSerialization)
Sets whether or not this ComplicationData has been serialized.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
tapActionLostDueToSerialization |
boolean |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setTargetValue
public ComplicationData.Builder setTargetValue (float targetValue)
Sets the ranged target value field for this Complication Data. This is required for the
ComplicationType.GOAL_PROGRESS type, and is not valid for
any other type. A ComplicationType.GOAL_PROGRESS
complication visually presents a single value, which is usually a percentage. E.g. you
have completed 70% of today's target of 10000 steps.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
targetValue |
float |
| Returns | |
|---|---|
ComplicationData.Builder |
|
| Throws | |
|---|---|
IllegalStateException |
if this field is not valid for the complication type |
setTimelineEndEpochSecond
public ComplicationData.Builder setTimelineEndEpochSecond (long epochSecond)
For timeline entries. Sets the epoch second at which this timeline entry becomes invalid.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
epochSecond |
long |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setTimelineEntries
public ComplicationData.Builder setTimelineEntries (Collection<ComplicationData> timelineEntries)
Sets the list of ComplicationData timeline entries.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
timelineEntries |
Collection |
| Returns | |
|---|---|
ComplicationData.Builder |
|
setTimelineStartEpochSecond
public ComplicationData.Builder setTimelineStartEpochSecond (long epochSecond)
For timeline entries. Sets the epoch second at which this timeline entry becomes valid.
Returns this Builder to allow chaining.
| Parameters | |
|---|---|
epochSecond |
long |
| Returns | |
|---|---|
ComplicationData.Builder |
|