Small fix for my patch
[webos-internals:modifications.git] / advanced / advanced-system-menus-mode-menu-vzw.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,11 @@
4  var BarAssistant = Foundations.Class.create({
5         
6         setup: function() {
7 +               this.modeSwitcherStatus = {
8 +                       activated: false,
9 +                       modeLocked: false,
10 +                       activeModes: [],
11 +                       customModes: []};
12                                                 
13                 this.showMSMWarning = false;
14                 this.isUSBConnected = false;
15 @@ -617,6 +622,9 @@
16         
17         this.getRoamingPreference();
18                 
19 +       //Subscribe to Mode Switcher configuration
20 +       this.initModeSwitcher();
21 +       
22         //Get the Airplane Mode initial values
23         this.isAirplaneModeEnabled();
24                                                 
25 @@ -725,7 +733,7 @@
26                                 this.carrierText = $L(payload.extended.networkName.escapeHTML());
27                                 this.currentCarrierText = payload.extended.networkName.escapeHTML();
28                         }
29 -                       Mojo.Dom.get('carrier').innerHTML = this.carrierText;           
30 +                       this.updateModeSwitcherStatus();
31                         if(payload.extended.registration == 'home') {                   
32                                 Mojo.Dom.get('roaming').hide();
33                         }                                                               
34 @@ -1165,7 +1173,7 @@
35                                         this.carrierText = $L(networkMsg.networkName.escapeHTML());
36                                         this.currentCarrierText = networkMsg.networkName.escapeHTML();
37                                 }
38 -                               Mojo.Dom.get('carrier').innerHTML = this.carrierText;
39 +                               this.updateModeSwitcherStatus();
40                                 this.simlocked = false;
41                                 
42                                 if(networkMsg.registration == 'home') {                                 
43 @@ -4709,6 +4717,70 @@
44         Mojo.Controller.getAppController().showBanner(bannerParams, {}, 'apprestoredbanner');
45  },
46  
47 +// Mode Switcher Support
48 +
49 +initModeSwitcher: function() {
50 +       this.defaultCarrierColor = Mojo.Dom.get('carrier').style.color;
51 +       
52 +       this.modesConfigRequest = new Mojo.Service.Request("palm://org.webosinternals.modeswitcher.srv", {
53 +               method: 'status', parameters: {"subscribe": true},
54 +               onSuccess: this.handleModeSwitcherUpdate.bind(this) }); 
55 +},
56 +
57 +handleModeSwitcherUpdate: function(payload) {
58 +       if(payload.activated != undefined)
59 +               this.modeSwitcherStatus.activated = payload.activated;
60 +
61 +       if(payload.modeLocked != undefined)
62 +               this.modeSwitcherStatus.modeLocked = payload.modeLocked;
63 +               
64 +       if(payload.activeModes != undefined)
65 +               this.modeSwitcherStatus.activeModes = payload.activeModes;
66 +
67 +       if(payload.customModes != undefined)
68 +               this.modeSwitcherStatus.customModes = payload.customModes;
69 +
70 +       this.updateModeSwitcherStatus();
71 +
72 +       var stageController = Mojo.Controller.getAppController().getStageController("StatusMenu");      
73 +
74 +       if(stageController) {
75 +               stageController.delegateToSceneAssistant("updateMenuItems");
76 +       }
77 +},
78 +
79 +//Updated the status text if needed.
80 +updateModeSwitcherStatus: function() {
81 +       this.gpsGetRadioStatus();
82 +       
83 +       if(this.modeSwitcherStatus.activeModes.length == 0) {
84 +               $('carrier').innerHTML = this.carrierText;
85 +               $('carrier').style.color = this.defaultCarrierColor;
86 +
87 +               return;
88 +       }       
89 +       
90 +       if(this.modeSwitcherStatus.modeLocked)
91 +               $('carrier').style.color = "yellow";
92 +       else
93 +               $('carrier').style.color = this.defaultCarrierColor;
94 +
95 +       if((this.modeSwitcherStatus.activeModes[0].name == "Default Mode") && (this.carrierText != ""))
96 +               var statusText = this.carrierText;
97 +       else
98 +               var statusText = this.modeSwitcherStatus.activeModes[0].name;
99 +
100 +       if(this.modeSwitcherStatus.activeModes.length > 1)
101 +               statusText = statusText + " +";
102 +
103 +       $('carrier').innerHTML = statusText;
104 +},
105 +
106 +//Returns the MS config. Called by the Mode Menu.
107 +getModeSwitcherStatus: function() {    
108 +       return this.modeSwitcherStatus;
109 +},
110 +
111  //  Main Variables
112         timeAMPM: true,
113         serviceInitMethod:[],
114 --- .orig/usr/lib/luna/system/luna-systemui/sources.json
115 +++ /usr/lib/luna/system/luna-systemui/sources.json
116 @@ -6,6 +6,9 @@
117      "source": "app\/controllers\/bar-assistant.js"
118    },  
119    {
120 +    "source": "app\/controllers\/statusmenu-assistant.js"
121 +  },  
122 +  {
123      "source": "app\/controllers\/devicemenu-assistant.js"
124    },  
125    {