Reordering menus

Hi, I'm working on modifying an app already on GitHub to interact with a Tesla vehicle. One feature of the app is an 'Option' menu that allows you to interact with less frequently used commands. I would like to be able to change the order of the menu items that appears in that menu so people could have at the top those they would use the most (like now, Defrost would be at the top but moved much lower during warmer months).

Is it possible to do within the app itself and if not, can it be done within the Apps settings on the phone?

Thanks.

  • Taking a quick look at the code, it looks like the menu is being defined in menu.xml.  Instead of doing that, you can build the menu in your code,  For example, here's one I build in one of my apps:

    var thisMenu = new WatchUi.Menu();
    thisMenu.setTitle("Paused");
    thisMenu.addItem("Resume", :item_resume);
    thisMenu.addItem("Save", :item_save);
    thisMenu.addItem("Also Save WPs", :item_saveroute);
    thisMenu.addItem("Discard", :item_discard);
    
    WatchUi.pushView(thisMenu, new HikeRSDMenuDelegate(), Ui.SLIDE_IMMEDIATE );

    Using defrost as an example, this way your code can build the menu you want at the time and only show defrost based on an app setting, only show it from Oct to March (when it might be needed), or even do something like only show it if the temperature is below 45F using the Weather Module

  • Thanks for the quick reply

    That will help ordering the Options menu, but what can I do to allow the end users to customize the menu order themselves? Defrost was just an option, someone might something else on top or anywhere else on the list. How can I make it so they can customize it?

    Thinking about it as I type this, could I use the App setting to have all option menu 'slots' be a drop down where they would choose which option goes into which slot? I don't find this very elegant and would prefer if the reordering can be done on the watch, like for widgets or activities displaying order.

    Thanks again.

  • You can do that with app settings, where the user can say defrost is 3rd, Wipers is 1st, lights are 2nd,etc.  Then based on those app settings, build the menu in your code

  • Got the Option menu built with the snippet of codes you gave :-) I'll work on the settings.xml file to configure this option. Thanks again.

    Edit: I'll use the way crystal-face watchface does this. It's similar and I worked on that one too so I know it.

  • Thanks again. All done :-) It looks like this and is regionalized. Now I just need the owner of the main repo to accept the changes.