Repository navigation
HeartTextIndicator JSON
This page describes the persisted format of the heartText indicator in a project, in Mixel, and in templates. For the user guide on editing .vttp files by hand, see Heart Text JSON.
-
toJSON(false)- the real Mixel state: contains the selected source and sensor, the current property values, and the size and position of the layer. -
toJSON(true)- the template state: contains values that can be carried between projects. The sensor property (Heart) is saved in a template as an empty object{}: the source and sensor are picked when the indicator is added to a project.
The layer identifier is built from the plugin uid and the indicator name:
{
"name": "com.velitask.plagin.official.heartText",
"data": {
"properties": {}
}
}| Part | Value |
|---|---|
| plugin uid | com.velitask.plagin.official |
| indicator name | heartText |
In a real Mixel, the size and position of the layer are stored next to properties. The exact shape of these State fields depends on the current runtime, so they are shown in abbreviated form. The values sourceId.value and sensorId.value are numeric identifiers of the project source and sensor; they are given below as an example.
{
"name": "com.velitask.plagin.official.heartText",
"data": {
"size": { "...": "layer size state" },
"positionInParent": { "...": "layer position state" },
"properties": {
"Heart": {
"sourceId": {"value": 1},
"sensorId": {"value": 3}
},
"font": {"name":"Dialog","style":0,"size":48,"color":{"r":255,"g":255,"b":255,"a":255}},
"textAlign": {"value":4},
"textTemplate": {"template":"{currNum} {currUnit}","vars":{"currNum":"%d","currUnit":"%s"}}
}
}
}A template stores maket (here auto) instead of the size and position, and the sensor property is empty. The property values match the defaults in the code.
{
"name": "com.velitask.plagin.official.heartText",
"data": {
"maket": { "preset": "auto" },
"properties": {
"Heart": {},
"font": {"name":"Dialog","style":0,"size":48,"color":{"r":255,"g":255,"b":255,"a":255}},
"textAlign": {"value":4},
"textTemplate": {"template":"{currNum} {currUnit}","vars":{"currNum":"%d","currUnit":"%s"}}
}
}
}| JSON key | Java property | SDK type | User meaning | Default |
|---|---|---|---|---|
Heart |
mHeart |
HeartAtomProperty |
The selected heart-rate sensor. | Empty object in a template; sourceId/sensorId in a project. |
font |
mText |
FontColorProperty |
Font and text color. |
name = Dialog, style = 0, size = 48, white color 255,255,255,255. |
textAlign |
mTextAlign |
TextAlignProperty |
Position of the text inside the layer. |
4 (CENTER). |
textTemplate |
mTemplate |
TextTemplateProperty |
A string template with variables. |
{currNum} {currUnit}. |
Formats of the nested values:
-
font- a flat object:name(string),style(number:0plain,1bold,2italic),size(integer,1..999), andcolor(r,g,b,a, each0..255). -
textAlign-{"value": N},Nfrom0to8(orderTOP_LEFT,TOP_CENTER,TOP_RIGHT,CENTER_LEFT,CENTER,CENTER_RIGHT,BOTTOM_LEFT,BOTTOM_CENTER,BOTTOM_RIGHT). A value outside the range is treated asCENTER_LEFT. -
textTemplate-{"template": string, "vars": {name: format}}; thevarskeys are variable names without braces.
Template variables (order of the makeText(...) arguments):
| Variable | Default format | Meaning |
|---|---|---|
{currNum} |
%d |
Heart rate (an integer number of beats per minute), int hr. |
{currUnit} |
%s |
The unit label from the plugin localization (bpm in English, уд/мин in Russian). |
A compact template, with the text pushed to the right and the bottom:
{
"name": "com.velitask.plagin.official.heartText",
"data": {
"maket": { "preset": "auto" },
"properties": {
"Heart": {},
"font": {"name":"Dialog","style":1,"size":64,"color":{"r":255,"g":80,"b":80,"a":255}},
"textAlign": {"value":8},
"textTemplate": {"template":"{currNum}{currUnit}","vars":{"currNum":"%d","currUnit":"%s"}}
}
}
}-
VelitaskPlagin.getUID()(com.velitask.plagin.official) must not be changed without migrating saved projects. -
Indicator.getName()(heartText) must not be changed without a migration. - Property names (
Heart,font,textAlign,textTemplate) must not be renamed without a migration: loading goes by name. - The names of the template variables (
currNum,currUnit) are part of thevarsformat; renaming them breaks saved formats. - The property order mostly affects the UI; renaming is more dangerous than reordering.