Updating a watchface

Hi,

I have a problem regarding updating my watchface properly:

I try to implement a theme switch which changes the entire theme of my watchface. If one likes his current watchface settings he can store those settings. By doing this my watchface creates a so called theme string which represents all the settings. The theme string is stored in the object store and so the user can load this theme string again at any time. This works pretty well. At the same time all user settings in the object store are adjusted according the theme string. By using this theme switch, onSettingsChanged() is called and there I placed an Ui.requestUpdate().

Nevertheless, I also implemented a way that the user can specify a time when the theme string is loaded. The functions behind the theme loading are the very same as in the upper case. Also the user settings in the object store are adjusted in the very same way. Unfortunately this method to switch a theme works not very well. Either the watchface hangs up or the watchface is messed up by mixing different settings. I can easily repair this by switching for and back to another widget, which means that the adjusting of the settings in the object store is OK. I am wondering why the watchface hangs up then. I had a look in the CIQ_log.txt and it says it's an unexpected error or so, nothing really helpful.

I am wondering what the differences are between an Ui.requestUpdate() called from the onSettingsChanged() and a method which is called at the very beginning of onUpdate() when a certain time was reached.
  • Former Member
    Former Member over 8 years ago
    Don't know if this is the issue, but recently I found out, that if application mixes settings sent from GCM and object store, then object store is messed after receiving new settings from GCM.
    E.g.:
    properties.xml:
    <properties>
    <property id="bgColor" type="number">0x000000</property>
    <property id="localSetting" type="string">default</property>
    </properties>

    settings.xml:
    <settings>
    <setting propertyKey="@Properties.bgColor" 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>
    </settingConfig>
    </setting>
    </settings>



    After I update my object store with
    App.getApp().setProperty("localSetting", "local value");

    sequential calls to
    App.getApp().getProperty("localSetting")

    return me "local value" string until I send settings from GCM (works in the same way with simulator + settings editor). After that the above call returns me float value of 0.0. Since it didn't bother me much I just accepted this behavior as is and just created an "instanceof" check before using this value and replacing it with the default value if it wasn't of String type. But in your case, if this is the problem you're facing, you actually may loose some data due to this bug. Therefore maybe it's worth posting to IQ bug reports forum.
  • I think you really mean app settings and not the Object Store, or are some things based on a user changing the app setting, and you use that app setting to store things in the object store? Or are you changing things back in the app settings? (the object store is in your app's .str file, while app settings are in your app's .set file). The .str can only be changed by your app, while the .set can be changed by your app or by a user with GCM/GE. (even indirectly)

    (the Object Store vs App Settings can be confusing, as you use the same calls to access them both, but they behave a bit differently)
  • easuvorov - actually, in your code, it seems you are not using the object store, but only app settings. (the .set file and not the .str)

    The "number being a float" is talked about in the new developer FAQ #2, point 10, and what it is that when you use Android to do App settings, it might return a float instead of a number, but only returns a number with GE and GCM on iOS.

    So if someone uses Android for app settings, your app might see a float where a number is expected in the .set, and there's a way to handle that.
  • easuvorov - if you want to use the Object Store for a value, and not have it impacted by app settings at all, comment out or delete this line:

    <property id="localSetting" type="string">default</property>

    If you have an existing app, you may want to change the key (localSettings), as you could wind up with the same key in both the .set and .str, and I'm not sure what may happen then. By putting it in the ObjectStore, it also isn't sent back and forth with GCM when a user wants to change something.

    You don't define a property for things in the Object Store, and can use whatever you want for a key, and use them as you need. Say you want to store a varying number of things. You could have one key that specifies the number of items, and then use Numeric keys (0 to x) for each item, for example, where X varies based on what your app needs. I use the Object store for some things, and settings for things I allow the user to modify.
  • Former Member
    Former Member over 8 years ago
    jim_m_58 I didn't know that object store key may exist without it's "property" as it's not outlined explicitly in progguide and ObjectStore example combines properties and settings, my comment was related exactly to having the property and an object store key with the same name, as I thought that it's necessary to define property to use an object store. Glad that I was mistaking and it no bug.
  • The Object store sample is a bit confusing, as it was written for just the Object Store, but app settings was added to in in 1.2.0. On screen 1 of the sample, is the Object Store, and the 2nd screen is app settings. For page 1, it uses numbers for keys, and on page 2, stings, that are defined by properties. For screen 1, you modify with "Edit Object Store" in the sim, and screen 2, the "App Settings Editor" in Eclipse.
  • Hi Jim,

    I don't understand every word but it sounds very interesting. Nevertheless, in my case the problem was probably a not properly initialized variable. I will observe this behaviour and will set up some know how in this area. Thanks also for the hint to the object store example app.