What is the best practice to add a device specific setting item

Hi,

I wanna add a field floorsClimbed for my WF. As we know , this api only supports the devices with a barometer,like fr255. So this setting item is pointless to show for a fr245 user.

At first , share my implementation.

resources/settings.xml 

The base setting. Not floorsClimbed choice.

<setting propertyKey="@Properties.Grid1DataType" title="@Strings.g1dtt" prompt="@Strings.g1dtt">
<settingConfig type="list">
<listEntry value="1">@Strings.lunarDate</listEntry>
<listEntry value="2">@Strings.solarDate</listEntry>
<listEntry value="3">@Strings.steps</listEntry>
<listEntry value="4">@Strings.heartRate</listEntry>
<listEntry value="5">@Strings.sunriseTime</listEntry>
<listEntry value="8">@Strings.batteryLeft</listEntry>
</settingConfig>
</setting>

resources-floorclimbed/settings.xml

Add  floorsClimbed choice

<setting propertyKey="@Properties.Grid1DataType" title="@Strings.g1dtt" prompt="@Strings.g1dtt">
<settingConfig type="list">
<listEntry value="1">@Strings.lunarDate</listEntry>
<listEntry value="2">@Strings.solarDate</listEntry>
<listEntry value="3">@Strings.steps</listEntry>
<listEntry value="4">@Strings.heartRate</listEntry>
<listEntry value="5">@Strings.sunriseTime</listEntry>
<listEntry value="8">@Strings.batteryLeft</listEntry>
<listEntry value="13">@Strings.floorsClimbed</listEntry>
</settingConfig>
</setting>
monkey.jungle
fr255.resourcePath = resources;resources-logo-40x40;resources-round-260x260;resources-alwayson;resources-floorclimbed
fr255m.resourcePath = resources;resources-logo-40x40;resources-round-260x260;resources-alwayson;resources-floorclimbed
Now everything works as it is expected.
But a big drawback comes out.
If I wanna add another field for all devices, I have to add twice.
If I merely add it for the existed setting config in resources/settings.xml, the new item won't take effect on fr255 as the config is overrided.
SO is there any better approach to modify once decently?
  • you spend hours to analyse specification every device and preparing settings and if you don't plan to remove monkey code saving will be small

    so rather show all settings and use HAS, check null and draw something 'disabled colour' with ---- value

  • if you don't mind that you don't control the order of the things in the settings editor (the compiler will "decide for you") then you can do this:

    have all the common settings in resources/settings.xml and resources/properties.xml
    have the additional settings in resources-floorsclimbed/settings.xml and resources-floorsclimbed/properties.xml

    This works and probably the settings you add in floorsclimbed will show up at the end of the settings editor page.

    I didn't like that so I chose to do the other option that you also came up with to edit 2 separate settings.xml and always only include one of them so I have full control of what's in it and in what order.

  • This works and probably the settings you add in floorsclimbed will show up at the end of the settings editor page.

    I find it won't happen if both of resources/settings and resources-floorclimbed/settings have the <setting>.

    While if the setting only exists in the latter settings.xml, it will show up at the end. LOL

    Have a nice day.

    Mr. Gavriel.

  • There is no problem for single property and simple setting but for list? A lot of work to prepare all combination, than assign to device... but of course possible.

  • I think you can set a variable and then use that. Someone also posted a php script that generates the monkey.jungle for him

  • I've used a really simple approach for this since settings came about.  Instead of just using "Floors" for the string, use "Floors (if available)", and then in the code, if the device doesn't support floors, leave that field blank, use "--" or "N.A.".

    I can't recall a single user complaining over the last 6 years.  If you add things like Stress and BB to this, you could wind up with a bunch of other sets of settings, adding to the maintenance.

    On devices without a baro, you also don't have access to things in SensorHistory, such as temperatue history, and in the current SDKs, your settings all get reset if the settings change when running in the sim.

  • Thanks JIM. I will remove the buggy and hard-maintenable resources folders