test to see if watchface settings have changed?

Former Member
Former Member
Hi.

Is there a way for my watchface to test to see if the user has changed the settings (via GCM or however) without having to go and test each one individually against the previously stored value?

Basically i want to do a re-calculation of something that depends on some of the settings when they're changed, without having to do checks on each setting every second/minute, given the user is probably only going to make a setting change once a month or more.

Thanks.
  • Former Member
    Former Member over 7 years ago
    AppBase.onSettingsChanged() gets called when a Connect IQ app receives new settings from GCM.
  • Like Ken said, onSettingsChanged().

    In my apps there are only two times I ever use getProperty() for setting - when the app starts and when onSettingsChanged() is called. The value for setting is then stored/used locally. You should be able to do your recalculations as part of the same code and never have to check if it needs to be done outside of that code.
  • Former Member
    Former Member over 7 years ago
    AppBase.onSettingsChanged() gets called when a Connect IQ app receives new settings from GCM.


    Looked for and couldn't find that. Thanks!!
  • Former Member
    Former Member over 7 years ago
    So for some reason i can't get this to work, even though the logic makes sense to me.

    I have a global variable called settingsChanged that is initially set to false. I then have the following ...

    function onSettingsChanged() {
    settingsChanged = true;
    requestUpdate();
    }


    ... and then within onUpdate(dc) i test settingsChanged and if it's true i execute some additional code. Except that this code doesn't run after i've changed the settings through GCM.

    :(

    Have i misunderstood how this should work?

  • Where do you have onSettingsChanged? It's in AppBase, so for example
    class SimpleApp extends App.AppBase {

    function initialize() {
    AppBase.initialize();
    }

    function onSettingsChanged() {
    //do what you do here
    }

    //other stuff that's normally here
    }

  • Former Member
    Former Member over 7 years ago
    Thanks Jim. Yeah i had it in the wrong place. Here's what worked ...

    using Toybox.Application as App;

    var settingsChanged = false;

    class SnapshotWatchDevApp extends App.AppBase {

    function initialize() {
    AppBase.initialize();
    }

    function onSettingsChanged() {
    settingsChanged = true;
    requestUpdate();
    }

    // onStart() is called on application start up
    function onStart(state) {
    }

    // onStop() is called when your application is exiting
    function onStop(state) {
    }

    // Return the initial view of your application here
    function getInitialView() {
    return [ new SnapshotWatchDevView() ];
    }

    }


    And then in onUpdate(dc) i test settingsChanged and execute the appropriate additional code if true. Note i had to make settingsChanged a global variable so i could track it throughout the code.

    Works great now!
  • Yup, it's got to be in the proper place :)
  • hi, i would like to know how do you get settingChanged inside the onUpdate function... mywatchfaceApp.onsettingChanged?? tks

  • sorry i meant the variab le settingChanged...

  • For me, I don't do it in the view.  When onSettingsChange is called, I load all the settings and then just reference those values in onUpdate.  I also load them in the view's initialize().  That way getValue() is not called every second or minute - only when needed.  So in onUpdate, I'll just have

    dc.setColors(MySettings.timeColor,Mysettings.backgroundColor);

    for example