UI switches for getting user input?

Former Member
Former Member
Hello All,

I was wondering if there exists a "switch" UI element that allows you to collect user settings. An example can be seen on connect IQ watches in the screen where you can enable/disable a particular alarm. I attached a picture that illustrates what I am talking about. If it does exist how does one get access to it?

Ultimately I am trying to provide an interface for users to change settings on my app. If there is no switch ui element does anyone else have ideas for getting and storing user settings?

Thanks in advance,

Braden
  • thats the native menu. Look up the SDK for menu. (Can't remember what. The code goes like menu.additem()

    User input storing - look up user store.

    It's in the prog guide in the SDK. Read it up. Some good info
  • The built-in ConnectIQ menus are rather simple. The built-in menu system don't provide a way to display both a name and value and they most certainly do not have facilities for displaying a switch as you've shown on the Fenix. If you want this, you'll have to create your own menu system and render your own switch using Dc.drawCircle() and Dc.drawRoundedRectangle().

    If you get tricky, you can use the built-in menu system to display a setting name and value.

    Travis
  • Former Member
    Former Member over 9 years ago
    The built-in ConnectIQ menus are rather simple. The built-in menu system don't provide a way to display both a name and value and they most certainly do not have facilities for displaying a switch as you've shown on the Fenix. If you want this, you'll have to create your own menu system and render your own switch using Dc.drawCircle() and Dc.drawRoundedRectangle().

    If you get tricky, you can use the built-in menu system to display a setting name and value.

    Travis


    Ok I think I see what you are getting at. So I would start by drawing the menu, and then drawing that switch using Dc.drawCircle() and Dc.drawRoundedRectangle()?

    What's this bit about using the built-in menu system to display a setting name and value? Would I just be changing the text of the menu item on the fly?
  • So I would start by drawing the menu, and then drawing that switch using Dc.drawCircle() and Dc.drawRoundedRectangle()?

    Yes. You would have to write all of the code to render the menu. I posted code for a working menu system that looks much like that on a 920xt a while back. The menu has a menu title and each menu item has a name and an optional value that is displayed. It works fine on a 920, but not so well on a vivoactive. It is a little laggy on the vivoactive, and doesn't work very well with the touch screen.

    What's this bit about using the built-in menu system to display a setting name and value? Would I just be changing the text of the menu item on the fly?

    You can add menu items with the menu item name and value. i.e., GPS Enabled or GPS Disabled. Assume that the menu displays GPS Enabled and the user taps that menu item. In response, your code disables GPS, pops the current menu, and then pushes a new menu that is exactly the same as the one just popped except it displays GPS Disabled.
  • Former Member
    Former Member over 9 years ago
    Yes. You would have to write all of the code to render the menu. I posted code for a working menu system that looks much like that on a 920xt a while back. The menu has a menu title and each menu item has a name and an optional value that is displayed. It works fine on a 920, but not so well on a vivoactive. It is a little laggy on the vivoactive, and doesn't work very well with the touch screen.


    You can add menu items with the menu item name and value. i.e., GPS Enabled or GPS Disabled. Assume that the menu displays GPS Enabled and the user taps that menu item. In response, your code disables GPS, pops the current menu, and then pushes a new menu that is exactly the same as the one just popped except it displays GPS Disabled.



    Awesome! I think I'll go with one of these approaches.

    I was tinkering around with making a class that extends the WatchUI.Menu class. I was wondering if it would be possible to draw the slider on the menu item currently visible. I am not sure how that would work exactly if it is possible. Do you think its possible to use inheritance to achieve the task at hand?
  • I don't think you'll be able to do much by inheriting from Ui.Menu. It seems that this type is a thin wrapper around a native menu system and it does not provide any hook to render your own stuff. The only thing I see for you to do is to write something that inherits from Ui.View and draws what you need.

    Travis
  • Former Member
    Former Member over 9 years ago
    I don't think you'll be able to do much by inheriting from Ui.Menu. It seems that this type is a thin wrapper around a native menu system and it does not provide any hook to render your own stuff. The only thing I see for you to do is to write something that inherits from Ui.View and draws what you need.

    Travis


    Ahh I see. Well thank you for all the pointers. I greatly appreciate the help!

    I ended up going with a customized implementation of Ui.Menu. In the initialization function I addItems that pertain to my settings. However, I discovered that on vivoactive hardware the menu takes a decent amount of time until it is displayed (almost 2 full seconds). This is not the case on the simulator as well as fenix 3 hardware which is nearly instant.

    Without giving away too much of my secret sauce, here is roughly what I am doing.

    class SettingsMenu extends Ui.Menu {
    hidden var settings;
    hidden var device_settings;

    function initialize(settings)
    {
    var is_vibe_enabled;
    var is_sound_enabled;

    self.settings = settings;
    self.device_settings = System.getDeviceSettings();

    if(device_settings.vibrateOn)
    {
    is_vibe_enabled = self.settings.isVibeEnabled();
    self.addItem("Vibrate: " + is_vibe_enabled, :item_vibe);
    }
    }
    }


    This menu is nested inside a top level Menu view access via the menu button. The code that pushes this view looks like:
    Ui.popView(Ui.SLIDE_DOWN);
    Ui.pushView( new SettingsMenu(settings), new SettingsDelegate(settings), Ui.SLIDE_IMMEDIATE );


    The goal of the popView followed by pushView is to free up some memory of the top level menu (since switchView didn't work for my SettingsMenu() ).

    If anyone has any ideas please let me know. I would greatly appreciate it :)

    Cheers,

    Braden
  • You do know that with CIQ you have NO WAY to change any standard system settings, right?
  • Former Member
    Former Member over 9 years ago
    You do know that with CIQ you have NO WAY to change any standard system settings, right?


    Yup. This is just an internal setting. If my internal vibe setting is disabled my app won't vibrate regardless of how the user sets their device.
  • Yup. This is just an internal setting. If my internal vibe setting is disabled my app won't vibrate regardless of how the user sets their device.

    So you are only controlling the vide in your app, and not those from the FW when you start or stop a recording?