top-bar-device-menu-megamix for 1.3.1
[webos-internals:jeffrotulls-modifications.git] / top-bar / top-bar-device-menu-megamix.patch
1 Name: Device Menu Megamix
2 Version: 1.3.5-1
3 Author: Jason Robitaille
4 Description: Removes the date and battery level, adds brightness control, adds phone submenu with radio/data/roaming toggles, adds GPS toggle, removes the airplane mode toggle, and adds a flashlight led toggle, on the device menu  (MIT license)
5
6 --- .orig/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js
7 +++ /usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js
8 @@ -26,11 +26,6 @@
9                 
10                 //Add a touchable row class
11                 this.controller.get('palm-device-menu').addClassName('palm-touch-rows-'+Mojo.Environment.DeviceInfo.touchableRows);
12 -                       
13 -               var date = new Date();
14 -               this.controller.get('dm_date').innerHTML = Mojo.Format.formatDate(date,{date:'EEE '}) +  Mojo.Format.formatDate(date,{date:'long'});
15 -               var msg = $L("Battery: #{batlevel}");
16 -               this.controller.get('dm_battery').innerHTML = new Template(msg).evaluate({"batlevel": Mojo.Format.formatPercent(this.barAssistant.getBatteryLevel())});
17                                                 
18                 this.modesModel = {scrollbars: false, mode: "vertical"},
19                 this.controller.setupWidget('devicescroller', {}, this.modesModel);
20 @@ -37,6 +32,9 @@
21                 this.menuscroller = this.controller.get('devicescroller');
22                 
23                 this.drawerModel = {myOpenProperty:false};
24 +               this.controller.setupWidget('brightSlider', {minValue: 1, maxValue: 100}, this.brightModel = { value: 50});
25 +               this.controller.setupWidget('brightdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
26 +               this.controller.setupWidget('phonedetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
27                 this.controller.setupWidget('wifidetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
28                 this.controller.setupWidget('btdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
29                 this.wifidrawer = this.controller.get('wifidetails');
30 @@ -64,10 +62,6 @@
31                 //Spinner for Airplande Mode
32                 //this.controller.setupWidget('apSpinner', this.spinnerAttrs, this.apSpinnerModel);             
33                         
34 -               if(this.barAssistant.getAirplaneMode())                         
35 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn off Airplane Mode');
36 -               else
37 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn on Airplane Mode');
38                         
39                 var btstate = this.barAssistant.getCurrentBluetoothState();
40                 if(btstate === 'Off') {
41 @@ -113,7 +107,14 @@
42         },
43         
44         activate: function() {
45 -               this.controller.get('dm_airplanemode').addEventListener(Mojo.Event.tap, this.toggleAirplaneMode.bindAsEventListener(this));
46 +               this.controller.get('brightSlider').addEventListener(Mojo.Event.propertyChange, this.handleBrightSlider.bindAsEventListener(this));
47 +               this.controller.get('brightRow').addEventListener(Mojo.Event.tap, this.handleBrightTap.bindAsEventListener(this));
48 +               this.controller.get('phoneRow').addEventListener(Mojo.Event.tap, this.handlePhoneTap.bindAsEventListener(this));
49 +               this.controller.get('phone_radio').addEventListener(Mojo.Event.tap, this.togglePhone.bindAsEventListener(this));
50 +               this.controller.get('phone_data').addEventListener(Mojo.Event.tap, this.toggleData.bindAsEventListener(this));
51 +               this.controller.get('phone_roam').addEventListener(Mojo.Event.tap, this.toggleRoam.bindAsEventListener(this));
52 +               this.controller.get('dm_gps').addEventListener(Mojo.Event.tap, this.toggleGPS.bindAsEventListener(this));
53 +               this.controller.get('dm_flash').addEventListener(Mojo.Event.tap, this.toggleFlash.bindAsEventListener(this));
54                 this.controller.get('wifilist').addEventListener(Mojo.Event.listTap,this.handleWiFiTap.bindAsEventListener(this));
55                 this.controller.get('btlist').addEventListener(Mojo.Event.listTap,this.handleBTTap.bindAsEventListener(this));          
56                 this.controller.get('dm_wifi').addEventListener(Mojo.Event.tap, this.togglewifiList.bindAsEventListener(this));
57 @@ -130,6 +131,140 @@
58         cleanup: function() {
59                 Mojo.Log.error("Device Menu - Clean up called");                                
60         },      
61 +       
62 +       handleBrightTap: function(event) {
63 +               this.controller.get('brightdetails').mojo.setOpenState(!this.controller.get('brightdetails').mojo.getOpenState());
64 +       },
65 +
66 +       handleBrightSlider: function(event) {
67 +               this.controller.serviceRequest('palm://com.palm.display/control', {
68 +                       method: 'setProperty',
69 +                       parameters:{maximumBrightness:Math.round(event.value)}
70 +               });
71 +               this.controller.get('dm_brightness').innerText = "Brightness: " + Math.round(event.value) + "%";
72 +       },
73 +       
74 +       handlePhoneTap: function(event) {
75 +               this.controller.get('phonedetails').mojo.setOpenState(!this.controller.get('phonedetails').mojo.getOpenState());
76 +       },
77 +       
78 +       togglePhone: function(event) {
79 +               if(this.phoneState=="on") {
80 +                       this.phoneState = "off";
81 +               } else {
82 +                       this.phoneState = "on";
83 +               }
84 +               this.controller.serviceRequest('palm://com.palm.telephony', {
85 +                       method: 'powerSet',
86 +                       parameters: {
87 +                               state: this.phoneState
88 +                       }
89 +               });
90 +               this.setPhoneLabel();
91 +       },
92 +
93 +       setPhoneLabel: function() {
94 +               this.controller.get('phoneStatus').innerText = this.phoneState;
95 +       },
96 +       
97 +       toggleData: function(event) {
98 +               if(this.phoneState=="on") {
99 +                       if(this.dataDisabled=="on") {
100 +                               this.dataDisabled = "off";
101 +                       } else {
102 +                               this.dataDisabled = "on";
103 +                       }
104 +                       this.controller.serviceRequest('palm://com.palm.wan', {
105 +                               method: 'set',
106 +                               parameters: {
107 +                                       disablewan: this.dataDisabled
108 +                               }
109 +                       });
110 +                       this.setDataLabel();
111 +               } else {
112 +                       Mojo.Controller.errorDialog("Error: Phone radio needs to be on and "
113 +                                       + "connected for this function");
114 +               }
115 +       },
116 +
117 +       setDataLabel: function() {
118 +               if(this.dataDisabled=="off") {
119 +                       this.controller.get('dataStatus').innerText = "on";
120 +               } else {
121 +                       this.controller.get('dataStatus').innerText = "off";
122 +               }
123 +       },
124 +       
125 +       toggleRoam: function(event) {
126 +               if(this.phoneState=="on") {
127 +                       if(this.roamStatus=="roamonly") {
128 +                               this.roamStatus="any";
129 +                       } else {
130 +                               this.roamStatus="roamonly";
131 +                       }
132 +                       this.controller.serviceRequest('palm://com.palm.telephony', {
133 +                               method: 'roamModeSet',
134 +                               parameters: {
135 +                                       mode: this.roamStatus,
136 +                                       client: Mojo.appName
137 +                               }
138 +                       });
139 +                       this.setRoamLabel();
140 +               } else {
141 +                       Mojo.Controller.errorDialog("Error: Phone radio needs to be on and "
142 +                                       + "connected for this function");
143 +               }
144 +       },
145 +
146 +       setRoamLabel: function() {
147 +               if(this.roamStatus=="roamonly") {
148 +                       this.controller.get('roamStatus').innerText = "on";
149 +               } else {
150 +                       this.controller.get('roamStatus').innerText = "off";
151 +               }
152 +       },
153 +       
154 +       toggleGPS: function(event) {
155 +               this.gpsEnabled = !this.gpsEnabled;
156 +               this.controller.serviceRequest('palm://com.palm.location', {
157 +                       method: 'setUseGps',
158 +                       parameters: {
159 +                               useGps: this.gpsEnabled
160 +                       }
161 +               });
162 +               this.setGPSLabel();
163 +       },
164 +
165 +       setGPSLabel: function() {
166 +               if(this.gpsEnabled) {
167 +                       this.controller.get('gpsStatus').innerText = "on";
168 +               } else {
169 +                       this.controller.get('gpsStatus').innerText = "off";
170 +               }
171 +       },
172 +       
173 +       toggleFlash: function() {
174 +               if(this.flashVal==0) {
175 +                       this.flashVal = 100;
176 +               } else {
177 +                       this.flashVal = 0;
178 +               }
179 +               this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
180 +                       method: 'flashOn',
181 +                       parameters: {
182 +                               value: this.flashVal
183 +                       }
184 +               });
185 +               this.setFlashLabel();
186 +       },
187 +       
188 +       setFlashLabel: function() {
189 +               if(this.flashVal==0) {
190 +                       this.controller.get('flashStatus').innerText = "off";
191 +               } else {
192 +                       this.controller.get('flashStatus').innerText = "on";
193 +               }
194 +       },
195                         
196         wifiAPList: [],
197         btdeviceList: [],
198 @@ -932,6 +1067,8 @@
199                         this.controller.hideWidgetContainer(this.controller.get('wifidetails'));
200                         this.wifidrawer.mojo.setOpenState(false);
201                 }               
202 +               this.controller.get('brightdetails').mojo.setOpenState(false);
203 +               this.controller.get('phonedetails').mojo.setOpenState(false);
204                 //this.isVisible = false;
205                 if(this.isVisible){
206                         this.toggleDeviceMenu();
207 @@ -973,8 +1110,63 @@
208                 }
209                 else {
210                         this.isVisible = true;
211 -                       var date = new Date();          
212 -                       this.controller.get('dm_date').innerHTML = Mojo.Format.formatDate(date,{date:'EEE '})  +  Mojo.Format.formatDate(date,{date:'long'});
213 +                       this.controller.serviceRequest('palm://com.palm.display/control', {
214 +                               method: 'getProperty',
215 +                               parameters:{properties:['maximumBrightness']},
216 +                               onSuccess: function(response) {
217 +                                       if(response.maximumBrightness != undefined) {
218 +                                               this.brightModel.value = parseInt(response.maximumBrightness);
219 +                                               this.controller.modelChanged(this.brightModel);
220 +                                               this.controller.get('dm_brightness').innerText = "Brightness: " + response.maximumBrightness + "%";
221 +                                       } else {
222 +                                               this.controller.get('dm_brightness').innerText = "Brightness: ??%";
223 +                                       }
224 +                               }.bind(this)
225 +                       });
226 +                       this.controller.serviceRequest('palm://com.palm.telephony', {
227 +                               method: 'powerQuery',
228 +                               parameters: {},
229 +                               onSuccess: function(response) {
230 +                                       this.phoneState = response.extended.powerState;
231 +                                       this.setPhoneLabel();
232 +                               }.bind(this)
233 +                       });                     
234 +                       this.controller.serviceRequest('palm://com.palm.connectionmanager', {
235 +                               method: 'getstatus',
236 +                               parameters: {},
237 +                               onSuccess: function(response) {
238 +                                       if(response.wan.state === "disconnected") {
239 +                                               this.dataDisabled = "on";
240 +                                       } else if(response.wan.state === "connected") {
241 +                                               this.dataDisabled = "off";
242 +                                       }
243 +                                       this.setDataLabel();
244 +                               }.bind(this)
245 +                       });
246 +                       this.controller.serviceRequest('palm://com.palm.telephony', {
247 +                               method: 'roamModeQuery',
248 +                               parameters: {},
249 +                               onSuccess: function(response) {
250 +                                       this.roamStatus = response.extended.mode;
251 +                                       this.setRoamLabel();
252 +                               }.bind(this)
253 +                       });
254 +                       this.controller.serviceRequest('palm://com.palm.location', {
255 +                               method: 'getUseGps',
256 +                               parameters: {},
257 +                               onSuccess: function(response) {
258 +                                       this.gpsEnabled = response.useGps;
259 +                                       this.setGPSLabel();
260 +                               }.bind(this)
261 +                       });
262 +                       this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
263 +                               method: 'flashState',
264 +                               parameters: {},
265 +                               onSuccess: function(response) {
266 +                                       this.flashVal = response.value;
267 +                                       this.setFlashLabel();
268 +                               }.bind(this)
269 +                       });
270                         this.controller.stageController.activate();
271                         
272                         var animateDialog = function(){
273 @@ -1004,10 +1196,6 @@
274         },
275         
276         updateBatteryLevel: function(batlevel) {                
277 -               var msg = $L("Battery: #{batlevel}");
278 -               this.controller.get('dm_battery').innerHTML = new Template(msg).evaluate({
279 -                       "batlevel": Mojo.Format.formatPercent(batlevel)
280 -               });             
281         },
282         
283  });
284 --- .orig/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
285 +++ /usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
286 @@ -14,17 +14,40 @@
287                 <div id="devicescroller" class="palm-popup-content" x-mojo-element="Scroller">       
288                         <div class="palm-list">          
289                                 
290 -                               <div class="palm-row first"><div class="palm-row-wrapper">
291 -                                       <div id="dm_date" class="title dim"></div>
292 -                               </div></div>
293 -                               
294 -                               <div class="palm-section-divider">
295 -                               </div> 
296 -                               
297 -                               <div class="palm-row"><div class="palm-row-wrapper">
298 -                                       <div id="dm_battery" class="title dim"></div>
299 -                               </div></div> 
300 -                               
301 +
302 +                               <div class="palm-row first" id="brightRow" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
303 +                                       <div id="dm_brightness" class="title">&nbsp;
304 +                                       </div>
305 +                               </div></div>
306 +
307 +                               <div id="brightdetails" x-mojo-element="Drawer">
308 +                                       <div class="palm-row first"><div class="palm-row-wrapper">
309 +                                               <div x-mojo-element="Slider" id="brightSlider" style="padding-top: 30px; height: 50px;"></div>
310 +                                       </div></div>
311 +                               </div>
312 +
313 +                               <div class="palm-section-divider">
314 +                               </div> 
315 +
316 +                               <div class="palm-row first" id="phoneRow" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
317 +                                       <div id="dm_phone" class="title">Phone</div>
318 +                               </div></div>
319 +
320 +                               <div id="phonedetails" x-mojo-element="Drawer">
321 +                                       <div class="palm-row first" id="phone_radio" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
322 +                                               <div id="phoneStatus" class="label right">&nbsp;</div>
323 +                                               <div class="title">Phone Radio</div>
324 +                                       </div></div>
325 +                                       <div class="palm-row" id="phone_data" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
326 +                                               <div id="dataStatus" class="label right">&nbsp;</div>
327 +                                               <div class="title">Data Usage</div>
328 +                                       </div></div>
329 +                                       <div class="palm-row last" id="phone_roam" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
330 +                                               <div id="roamStatus" class="label right">&nbsp;</div>
331 +                                               <div class="title">Roam Only</div>
332 +                                       </div></div>
333 +                               </div>
334 +                               
335                                 <div class="palm-section-divider">
336                                 </div>               
337                                 
338 @@ -95,11 +118,18 @@
339                                 <div class="palm-section-divider"></div>
340                                 
341 -                               <div id="dm_airplanemode" class="palm-row last menu-end" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
342 -                                       <div id="dm_airplanemode_status" class="title truncating-text">
343 -                                        </div>
344 -                                        <!--<div id='apSpinner' class='label' x-mojo-element="Spinner"></div>-->
345 -                               </div></div>   
346 +                               <div class="palm-row" id="dm_gps" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
347 +                                       <div class="title truncating-text">
348 +                                               <div class="label right" id="gpsStatus">&nbsp;</div>
349 +                                               <span x-mojo-loc=''>GPS</span>
350 +                                       </div>
351 +                               </div></div>
352 +                               <div class="palm-row last menu-end" id="dm_flash"><div class="palm-row-wrapper">
353 +                                       <div class="title truncating-text">
354 +                                               <div class="label right" id="flashStatus">&nbsp;</div>
355 +                                               <span x-mojo-loc=''>Flashlight</span>
356 +                                       </div>
357 +                               </div></div>
358                                 
359                                 </div>       
360                         </div>
361                 </div>