New system menus patches
[webos-internals:jeffrotulls-modifications.git] / advanced / advanced-system-menus-mode-menu.patch
1 --- .orig/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
2 +++ /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
3 @@ -3,6 +3,7 @@
4  var BarAssistant = Foundations.Class.create({
5         
6         setup: function() {
7 +               this.modeSwitcherConfig = {};
8                                                 
9                 this.showMSMWarning = false;
10                 this.isUSBConnected = false;
11 @@ -609,6 +610,9 @@
12         
13         this.getRoamingPreference();
14                 
15 +       //Subscribe to Mode Switcher configuration
16 +       this.initModeSwitcher();
17 +       
18         //Get the Airplane Mode initial values
19         this.isAirplaneModeEnabled();
20                                                 
21 @@ -717,7 +721,7 @@
22                                 this.carrierText = $L(payload.extended.networkName.escapeHTML());
23                                 this.currentCarrierText = payload.extended.networkName.escapeHTML();
24                         }
25 -                       Mojo.Dom.get('carrier').innerHTML = this.carrierText;           
26 +                       this.updateModeSwitcherStatus();
27                         if(payload.extended.registration == 'home') {                   
28                                 Mojo.Dom.get('roaming').hide();
29                         }                                                               
30 @@ -1136,7 +1140,7 @@
31                                         this.carrierText = $L(networkMsg.networkName.escapeHTML());
32                                         this.currentCarrierText = networkMsg.networkName.escapeHTML();
33                                 }
34 -                               Mojo.Dom.get('carrier').innerHTML = this.carrierText;
35 +                               this.updateModeSwitcherStatus();
36                                 this.simlocked = false;
37                                 
38                                 if(networkMsg.registration == 'home') {                                 
39 @@ -4569,6 +4573,95 @@
40         Mojo.Controller.getAppController().showBanner(bannerParams, {}, 'textassistbanner');
41  },
42  
43 +// Mode Switcher Support
44 +
45 +initModeSwitcher: function() {
46 +       this.defaultCarrierColor = Mojo.Dom.get('carrier').style.color;
47 +       
48 +       this.modesConfigRequest = new Mojo.Service.Request("palm://com.palm.systemservice/", {
49 +               method: 'getPreferences', 
50 +               parameters: {"subscribe":true,"keys":["modeSwitcher", "modesConfig", 
51 +                       "currentMode", "defaultMode", "modifierModes"]},
52 +               onSuccess: this.handleModeSwitcherUpdate.bind(this) }); 
53 +},
54 +
55 +handleModeSwitcherUpdate: function(payload) {
56 +       if(payload.modeSwitcher != undefined) {
57 +               this.modeSwitcherConfig.modeSwitcher = payload.modeSwitcher;
58 +               
59 +               this.updateModeSwitcherStatus();
60 +       }
61 +               
62 +       if(payload.modesConfig != undefined) {
63 +               this.modeSwitcherConfig.modesConfig = payload.modesConfig;
64 +       }
65 +
66 +       if(payload.currentMode != undefined) {
67 +               if(payload.currentMode != "none")
68 +                       this.modeSwitcherConfig.currentMode = payload.currentMode;
69 +               else
70 +                       this.modeSwitcherConfig.currentMode = null;
71 +
72 +               this.updateModeSwitcherStatus();
73 +       }
74 +
75 +       if(payload.defaultMode != undefined) {
76 +               if(payload.defaultMode != "none")
77 +                       this.modeSwitcherConfig.defaultMode = payload.defaultMode;
78 +               else
79 +                       this.modeSwitcherConfig.defaultMode = null;
80 +       }
81 +       
82 +       if(payload.modifierModes != undefined) {
83 +               this.modeSwitcherConfig.modifierModes = payload.modifierModes;
84 +
85 +               this.updateModeSwitcherStatus();
86 +       }
87 +
88 +       var stageController = Mojo.Controller.getAppController().getStageController("StatusMenu");      
89 +
90 +       if(stageController) {
91 +               stageController.delegateToSceneAssistant("updateMenuItems");
92 +       }
93 +},
94 +
95 +//Updated the status text if needed.
96 +updateModeSwitcherStatus: function() {
97 +       if(!this.modeSwitcherConfig.currentMode) {
98 +               $('carrier').innerHTML = this.carrierText;
99 +               $('carrier').style.color = this.defaultCarrierColor;
100 +
101 +               return;
102 +       }       
103 +       
104 +       if(this.modeSwitcherConfig.modeSwitcher.modeLocked == "yes")
105 +               $('carrier').style.color = "yellow";
106 +       else
107 +               $('carrier').style.color = this.defaultCarrierColor;
108 +                               
109 +       if((this.modeSwitcherConfig.modifierModes) && 
110 +               (this.modeSwitcherConfig.modifierModes.length > 0))
111 +       {
112 +               if(this.modeSwitcherConfig.currentMode.type == "default")
113 +                       var statusText = this.carrierText + " +";
114 +               else
115 +                       var statusText = this.modeSwitcherConfig.currentMode.name + " +";
116 +       }
117 +       else {
118 +               if(this.modeSwitcherConfig.currentMode.type == "default")
119 +                       var statusText = this.carrierText;
120 +               else
121 +                       var statusText = this.modeSwitcherConfig.currentMode.name;
122 +       }
123 +
124 +       $('carrier').innerHTML = statusText;
125 +},
126 +
127 +//Returns the MS config. Called by the Mode Menu.
128 +getModeSwitcherConfig: function() {    
129 +       return this.modeSwitcherConfig;
130 +},
131 +
132  //  Main Variables
133         timeAMPM: true,
134         serviceInitMethod:[],
135 --- .orig/usr/lib/luna/system/luna-systemui/sources.json
136 +++ /usr/lib/luna/system/luna-systemui/sources.json
137 @@ -6,6 +6,9 @@
138      "source": "app\/controllers\/bar-assistant.js"
139    },  
140    {
141 +    "source": "app\/controllers\/statusmenu-assistant.js"
142 +  },  
143 +  {
144      "source": "app\/controllers\/devicemenu-assistant.js"
145    },  
146    {