Trigger Menu app, I can't load the color theme.

Former Member
Former Member

Good day.

Can someone help me and tell me why the color theme that I have made in the application menu - Watch Face is not saved on my watch?

Everything works for me in the simulator.

Thank you

File: TimeApp.mc

using Toybox.Application as App;
using Toybox.WatchUi as Ui;


class TimeApp extends App.AppBase {
  
  
    private var mView;


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

 
    function onStart(state) {
    }

    
    function onStop(state) {
       
    }

   
    function getInitialView() {
       

        mView = new TimeView();
        return [mView];
    }
    
    
    function getView() {
        return mView;
    }
    
    
    function getSettingsView() {
        return [ new SettingsMenu(), new SettingsMenuDelegate() ];
    }

   
    function onSettingsChanged() {
     
           
            mView.onSettingsChanged();
            Ui.requestUpdate();
        }
    }

 

  • Are you talking app-setting (phone or GE) or on device setting?  App settings don't work with side loads.  It needs to be installed from the store (it can be a beta app so only you can install it)

  • Former Member
    Former Member in reply to jim_m_58

    I'm talking about the menu in the watch.

  • Ok, you have code for both.  onSettingsChanged is if you use phone/GE app-settings, and getSettingsView is for on deviceSettings

  • With the menu, when you change something are you saving it in persistent storage so your watch face can see those changes?  Have you looked at the analog sample in the SDK?

  • Former Member
    Former Member in reply to jim_m_58

    exactly, I want the changes to be reflected on the watch, I have made the Theme menu and everything works for me in the simulator, but when I call up the menu option in the watch and want to save the change, it does not save and gives me an error.

  • When you change something with your menu, you want to save it in Application.Storage or Application.Properties, depending on where your watch face is looking for things.  You can't just change a variable in the view or AppBase

  • Former Member
    Former Member in reply to jim_m_58

    I want to save changes to the watch's memory, so Storage?

  • If you are also using app-settings from a phone or GE, you might want to use Application.Properties.  If you Application.Storage.

    Again, look at the appalog sample in the SDK.  In AnalogSettingsMenu.mc, you'll see in onSelect when it saves things to Storage.

  • Former Member
    Former Member in reply to jim_m_58

    Good day.
    Could someone please tell me where I am going wrong when creating the "Application.Storage" watch menu?

    When I try to launch the menu it just shows a white circle with no menu.
    I create the menu according to the sample code in the demo in the SDK.

    I am attaching my code:

    import Toybox.Application.Storage;
    import Toybox.Lang;
    import Toybox.WatchUi;
    
    
    class SettingsMenu extends WatchUi.Menu2 {
    
        var ColorBackground;
        var ColorAreaBorder;
        var ColorAreaBackground;
        var ColorTime;
       
       
       hidden enum {
    		Theme_1,
    		Theme_2,
    		Theme_3,
    		Theme_4,
    		Theme_5,
    		
    	}	
       
        public function initialize() {
            Menu2.initialize({:title=>"Settings"});
            
           
             
            }
            
         //   var displayIcons = Application.getApp().getProperty("DisplayIcons") as boolean;
         //   Menu2.addItem(new WatchUi.ToggleMenuItem("Bar Icons", null, 1, displayIcons, null));
    
         //   var displayValues = Application.getApp().getProperty("DisplayValues") as boolean;
         //   Menu2.addItem(new WatchUi.ToggleMenuItem("Sensor Values", null, 2, displayValues, null));
    
          //  var displaySeconds = Application.getApp().getProperty("DisplaySeconds") as boolean;
          //  Menu2.addItem(new WatchUi.ToggleMenuItem("Seconds Indicator", null, 3, displaySeconds, null));
    
           
           function getTheme() {
    		var selectedTheme = Application.getApp().getProperty("ThemeColor").toNumber();
    		if (selectedTheme == null) {
            	selectedTheme = 0;
            }
            
            switch (selectedTheme) {
    			case Theme_1:
    
    			ColorBackground = Graphics.COLOR_BLACK;
                ColorAreaBorder = Graphics.COLOR_DK_BLUE;
                ColorAreaBackground = Graphics.COLOR_WHITE;
                ColorTime = Graphics.COLOR_GREEN;				
    				
    		 break;
    				
    		
    			case Theme_2:
    			    
    			ColorBackground = Graphics.COLOR_BLACK;
                ColorAreaBorder = Graphics.COLOR_DK_BLUE;
                ColorAreaBackground = Graphics.COLOR_WHITE;
                ColorTime = Graphics.COLOR_YELLOW;
    							
    		break;
    				
    			case Theme_3:
    				
    		    ColorBackground = Graphics.COLOR_BLACK;
                ColorAreaBorder = Graphics.COLOR_ORANGE;
                ColorAreaBackground = Graphics.COLOR_WHITE;
                ColorTime = Graphics.COLOR_RED;
    				
    		break;
    				
    			case Theme_4:
    				
    			ColorBackground = Graphics.COLOR_BLACK;
                ColorAreaBorder = Graphics.COLOR_WHITE;
                ColorAreaBackground = Graphics.COLOR_PINK;
                ColorTime = Graphics.COLOR_WHITE;
    				
    		break;
    				
    			case Theme_5:
    				
    			ColorBackground = Graphics.COLOR_BLACK;
                ColorAreaBorder = Graphics.COLOR_LT_GRAY;
                ColorAreaBackground = Graphics.COLOR_DK_BLUE;
                ColorTime = Graphics.COLOR_DK_GREEN;
    				
    		break;
    				
    			
    		}
    
            Menu2.addItem(
                new WatchUi.MenuItem(
                    "Themes",
                    getTheme,
                    4,
                    null
                )
            );
    
            return true;
            
            
        }
    }
    
    
    class SettingsMenuDelegate extends WatchUi.Menu2InputDelegate {
    
       
        public function initialize() {
            Menu2InputDelegate.initialize();
         
        }
    
       
        public function onSelect(menuItem) as Void {
            
            
             var selectedTheme = Application.getApp().setProperty("ThemeColor").toNumber();
             if(menuItem.getId() == 1){
            	selectedTheme = Theme_1;
                 Application.getApp().saveProperties();
               }   
                
            if(menuItem.getId() == 2){
                 selectedTheme = Theme_2;
                 Application.getApp().saveProperties();
               }   
                 
            if(menuItem.getId() == 3){
                selectedTheme = Theme_3;
                 Application.getApp().saveProperties();
               }
            if(menuItem.getId() == 4){
                 selectedTheme = Theme_4;
                 Application.getApp().saveProperties();
               }
            if(menuItem.getId() == 5){
               selectedTheme = Theme_5;
                 Application.getApp().saveProperties();
               }
                }
           
        
        function onBack() {
            WatchUi.popView(WatchUi.SLIDE_IMMEDIATE);
            return false;
        }
    }

  • What does your getSettingsView (it needs to be in your AppBase) look like?

    Here's one of mine:

        function getSettingsView() {
            return [new SLeanSettingsMenu(),new SLeanSettingsMenuDelegate()];
        } 

    instead of SLeanSettingsMenu, you should have SettingsMenu (based on your code) and

    instead of SLeanSettingsMenuDelegate, SettingsMenuDelegate