Advice for watch face with settings from newbie

Former Member
Former Member
Hi,

This is a long post/question and I apologise for asking too much, so don't feel compelled to answer. :-D

I am going to attempt to create a watch face with settings. Basically, the only thing I want the user to be able to configure is the choice of data displayed (eg: steps, floors climbed, active minutes, heart rate, calories, etc) while date and time format is fixed more or less. How do I go about this?

jim_m_58 advised me to look at the ObjectStore sample in the SDK but the example went right over my head but the Programmer's Guide did help a bit. So I was wondering if someone could point me in the right direction.

When I created a brand new watch face with settings project, I noticed that there are a few new files that weren't there in the basic watch face project and I am guessing their role.

bin/watchface-settings.json (Configuration with the choices?)
resources/settings/properties.xml (The default choice?)
resources/settings/settings.xml (The choices available to the users?)
resources/strings/strings.xml (listEntry in settings.xml mapped to string id here?)
source/watchfaceBackground.mc (I am guessing the background at initiation?)

1) Is my guess about their roles right and what files I should edit if I want to create the requirements I set above?

2) Are there fixed terms to use in properties.xml, settings.xml and string.xml or can I used my own terms?

For example, in settings.xml:

<setting propertyKey="@Properties.BackgroundColor" title="@Strings.BackgroundColorTitle">
<settingConfig type="list">
<listEntry value="0x000000">@Strings.ColorBlack</listEntry>
<listEntry value="0x555555">@Strings.ColorDarkGray</listEntry>
<listEntry value="0xAAAAAA">@Strings.ColorLightGray</listEntry>
<listEntry value="0xFFFFFF">@Strings.ColorWhite</listEntry>


Can I use say....

<setting propertyKey="@Properties.DataChoice" title="@Strings.BackgroundColorTitle">
<settingConfig type="list">
<listEntry value="S">@Strings.Steps</listEntry>
<listEntry value="F">@Strings.FloorsClimbed</listEntry>
<listEntry value="A">@Strings.ActiveMinutes</listEntry>
<listEntry value="H">@Strings.HeartRate</listEntry>


I guess I need to map the above choices in string.xml too.

3) Lastly, where do I set the code to pull the data (eg: steps, floors climbed, active minutes, heart rate, etc.) in? watchfaceView.mc? What method would you use in such a scenario? My only guess for this would be a sort of "if" thing.

var data = App.getApp().getProperty("DataChoice")
if data = S {
var activityInfo = Act.getInfo();
var steps = View.findDrawableById("DataLabel");
steps.setText(activityInfo.steps.toString());}


Of course if someone can share their source code for a very simple example of a watch face with settings for me to pick apart and understand, I would be grateful. :-)

Thanks!
  • For me, I tend to put everything for settings in "properties.xml". Properties, strings, and settings - all in one file so it's a bit easier to change/add something with eveything involved is in one file. (so that's addresses your properties.xml, strings.xml, and settings.xml question - you can of course have the different parts in different files). The .json gets built when you compile(you don't change that one directly, and is what actually gets used by the app settings editor in Eclipse, and actually gets sent in the .iq to the app store, as it's used by Garmin Connect Mobile or Garmin Express to actually do the settings.

    The watchfaceBackground.mc is used so you can change the background when using layouts, and you may not need to change that one (or even have it if you're not changing the background color).

    Here's a simple properties.xml that allows to two settings - a boolean and a list of colors.
    <resources>

    <properties>
    <property id="bgcolor" type="number">3</property>
    <property id="show7daySteps" type="boolean">true</property>
    </properties>

    <strings>
    <string id="show7daySteps_title">Show 7 Day Steps</string>

    <string id="bgcolorT">Background Color</string>

    <string id="white">White</string>
    <string id="ltgray">Light Gray</string>
    <string id="dkgray">Dark Gray</string>
    <string id="black">Black</string>

    <string id="red">Red</string>
    <string id="dkred">Dark Red</string>
    <string id="orange">Orange</string>
    <string id="yellow">Yellow</string>

    <string id="green">Green</string>
    <string id="dkgreen">Dark Green</string>
    <string id="blue">Blue</string>
    <string id="dkblue">Dark Blue</string>

    <string id="purple">Purple</string>
    <string id="pink">Pink</string>
    </strings>

    <settings>
    <setting propertyKey="@Properties.show7daySteps" title="@Strings.show7daySteps_title">
    <settingConfig type="boolean" />
    </setting>

    <setting propertyKey="@Properties.bgcolor" title="@Strings.bgcolorT">
    <settingConfig type="list">
    <listEntry value="0">@Strings.white</listEntry>
    <listEntry value="1">@Strings.ltgray</listEntry>
    <listEntry value="2">@Strings.dkgray</listEntry>
    <listEntry value="3">@Strings.black</listEntry>
    <listEntry value="4">@Strings.red</listEntry>
    <listEntry value="5">@Strings.dkred</listEntry>
    <listEntry value="6">@Strings.orange</listEntry>
    <listEntry value="7">@Strings.yellow</listEntry>
    <listEntry value="8">@Strings.green</listEntry>
    <listEntry value="9">@Strings.dkgreen</listEntry>
    <listEntry value="10">@Strings.blue</listEntry>
    <listEntry value="11">@Strings.dkblue</listEntry>
    <listEntry value="12">@Strings.purple</listEntry>
    <listEntry value="13">@Strings.pink</listEntry>
    </settingConfig>
    </setting>

    </settings>
    </resources>


    Properties define the key you'll use and the initial value for that key (3, for example when it comes to the background color.
    Strings are just that - the strings needed to do the settings.
    Settings, is what you want to show the user.

    Notice for listEntry, I use numbers. In what you posted, you're using characters for steps/floors/etc, and I believe that will throw an error as lists returns numbers.
    You're using numbers for the colors though, so what you have should work. My own personal preference, is to just use a simple index there instead of the hex values, and then I have an array in my app that I use to map that index into a color value. (seems there was a pink/purple thing on the F3, and this way the app uses the value for that specific device)


    In the app itself, don't forget about point 10 in the new developer FAQ #2 for numbers and Android!
  • Looks like I'll do this in parts (forum error)

    for point 10, it's just a simple wrapper function for getProperty() when you expect a number. It does the check, conversion, and allows for a default value if the property doesn't exists.

    I use it where I read my settings.

    For example, In one app, I have a key where I expect a number, in this case, a range:

    <setting propertyKey="@Properties.secondswitch" title="@Strings.secondswitch">
    <settingConfig min="0" max="60" type="numeric"/>
    </setting>


    to read it, I use:

    secondSwitch=readKeyInt(app,"secondswitch",secondSwitch);

    The range checking is done by the setting (the number can only be 0 to 60).

    But let's say I wanted to a range check. Then I'd use something like:
  • var temp=readKeyInt(app,"secondswitch",secondSwitch);

    and if temp is in range, secondSwitch=temp;