watchface settings and properties

Former Member
Former Member
Hi,

I don't know what happened to my other threads, please delete them.

Back to topic: I wan't to create some settings and properties to let the user choice some color for watchface.

I already create some settings and properties which works fine

<properties>
<property id="FONT_COLOR" type="number">1</property>
<property id="BACK_COLOR" type="number">2</property>
</properties>
<strings>
<string id="title_font_color">Font Color</string>
<string id="title_back_color">Background Color</string>

<string id="opt_color_1">White</string>
<string id="opt_color_2">Yellow</string>
<string id="opt_color_3">Orange</string>
<string id="opt_color_4">Red</string>
<string id="opt_color_5">Green</string>
<string id="opt_color_6">Blue</string>
<string id="opt_color_7">Black</string>
</strings>

<settings>
<setting propertyKey="@Properties.FONT_COLOR" title="@Strings.title_font_color">
<settingConfig type="list">
<listEntry value="1">Rez.Strings.opt_color_1</listEntry>
<listEntry value="2">Rez.Strings.opt_color_2</listEntry>
<listEntry value="3">Rez.Strings.opt_color_3</listEntry>
<listEntry value="4">Rez.Strings.opt_color_4</listEntry>
<listEntry value="5">Rez.Strings.opt_color_5</listEntry>
<listEntry value="6">Rez.Strings.opt_color_6</listEntry>
<listEntry value="7">Rez.Strings.opt_color_7</listEntry>
</settingConfig>
</setting>
<setting propertyKey="@Properties.BACK_COLOR" title="@Strings.title_back_color">
<settingConfig type="list">
<listEntry value="1">Rez.Strings.opt_color_1</listEntry>
<listEntry value="2">Rez.Strings.opt_color_2</listEntry>
<listEntry value="3">Rez.Strings.opt_color_3</listEntry>
<listEntry value="4">Rez.Strings.opt_color_4</listEntry>
<listEntry value="5">Rez.Strings.opt_color_5</listEntry>
<listEntry value="6">Rez.Strings.opt_color_6</listEntry>
<listEntry value="7">Rez.Strings.opt_color_7</listEntry>
</settingConfig>
</setting>
</settings>


How can I set the colors?
layout.xml
<label id="TimeLabel" x="center" y="center" font="Gfx.FONT_NUMBER_THAI_HOT" justification="Gfx.TEXT_JUSTIFY_CENTER" color="Gfx.COLOR_WHITE"></label>

watchface.mc
function onSettingsChanged() {
var font_color = App.getApp().getProperty("FONT_COLOR");
handleYourColorChangesHere(back_color);
var back_color = App.getApp().getProperty("BACK_COLOR");
handleYourColorChangesHere(back_color);
Ui.requestUpdate();
}


Greetings Ronny
  • Former Member
    Former Member
    That worked for me :) thanks

    How do I can combine 2 variables?

    var color1 = "BLUE";
    var gfont_color = "Gfx.COLOR_"+color1;


    Sorry, are there documents where I can read about this? I don't want to annoy you. :D
  • Former Member
    Former Member
    That could would create a string variable with a value of "Gfx.COLOR_BLUE" but what you need to set the color is a number/integer value (Gfx.COLOR_BLUE maps to an integer value). There isn't a way to combine these values to get an integer.

    The Programmers Guide in the SDK is a good summary of the language and SDK. It will provide a good base knowledge.
  • Sorry, I was wrong about using a global variable in that context. You can use them in the color attributes of other drawables, but not the label because validation fails. I had tried this before and posted code here. The example code posted by Ken is the only way that I know of to do this.