updates and additions
[webos-internals:modifications.git] / top-bar / top-bar-device-menu-alternate-mix.patch
1 diff --git a/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js b/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js
2 index 5beb152..896cfe5 100644
3 --- a/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js
4 +++ b/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js
5 @@ -32,12 +32,15 @@ var DevicemenuAssistant = Foundations.Class.create({
6                 this.controller.get('dm_date').innerHTML = Mojo.Format.formatDate(date,{date:'EEE '}) +  Mojo.Format.formatDate(date,{date:'long'});
7                 var msg = $L("Battery: #{batlevel}");
8                 this.controller.get('dm_battery').innerHTML = new Template(msg).evaluate({"batlevel": Mojo.Format.formatPercent(this.barAssistant.getBatteryLevel())});
9 +               this.controller.setupWidget('brightSlider', {minValue: 1, maxValue: 100}, this.brightModel = { value: 50});
10                                                 
11                 this.modesModel = {scrollbars: false, mode: "vertical"},
12                 this.controller.setupWidget('devicescroller', {}, this.modesModel);
13                 this.menuscroller = this.controller.get('devicescroller');
14                 
15                 this.drawerModel = {myOpenProperty:false};
16 +               this.controller.setupWidget('brightdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
17 +               this.controller.setupWidget('phonedetails', {modelProperty:'myOpenProperty'}, this.drawerModel);                
18                 this.controller.setupWidget('imedetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
19                 this.controller.setupWidget('wifidetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
20                 this.controller.setupWidget('btdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
21 @@ -129,7 +132,12 @@ var DevicemenuAssistant = Foundations.Class.create({
22                         this.controller.get('dm_wifi').hide();
23                         this.controller.hideWidgetContainer(this.controller.get('dm_wifi'));
24                 }
25 -
26 +               //setup battery temperature label
27 +               var battery = this.controller.get("dm_battery");
28 +               battery.id = "batteryRow";
29 +               battery.innerHTML = '<span id="dm_battery">' + battery.innerHTML + '</span>' +
30 +                               '<div class="label right" id="tempmsg" style="font-size:0.9em;">&nbsp;</div>';
31 +               
32                 //set up the the menu div
33                 this.scrim = this.controller.sceneElement.querySelector('div[x-mojo-scrim]');
34                 this.systemmenu = this.controller.sceneElement.querySelector('#palm-device-menu');
35 @@ -147,10 +155,24 @@ var DevicemenuAssistant = Foundations.Class.create({
36                                 setText: this.altCharSelected.bind(this)
37                         };
38                 }
39 +               this.controller.get("dm_vpn").style.display = "none";
40 +               var elem = this.controller.get("dm_vpn").previousSibling;
41 +               while(elem.innerHTML==null || elem.className.indexOf("palm-section-divider")<0)
42 +                       elem = elem.previousSibling;
43 +               elem.style.display = "none";
44 +               this.controller.get("vpndetails").style.display = "none";               
45         },
46         
47         activate: function() {
48                 this.controller.get('dm_airplanemode').addEventListener(Mojo.Event.tap, this.toggleAirplaneMode.bind(this));
49 +               this.controller.get('brightSlider').addEventListener(Mojo.Event.propertyChange, this.handleBrightSlider.bindAsEventListener(this));
50 +               this.controller.get('brightRow').addEventListener(Mojo.Event.tap, this.handleBrightTap.bindAsEventListener(this));
51 +               this.controller.get('phoneRow').addEventListener(Mojo.Event.tap, this.handlePhoneTap.bindAsEventListener(this));
52 +               this.controller.get('phone_radio').addEventListener(Mojo.Event.tap, this.togglePhone.bindAsEventListener(this));
53 +               this.controller.get('phone_data').addEventListener(Mojo.Event.tap, this.toggleData.bindAsEventListener(this));
54 +               this.controller.get('phone_roam').addEventListener(Mojo.Event.tap, this.toggleRoam.bindAsEventListener(this));
55 +               //this.controller.get('dm_gps').addEventListener(Mojo.Event.tap, this.toggleGPS.bindAsEventListener(this));
56 +               this.controller.get('dm_flash').addEventListener(Mojo.Event.tap, this.toggleFlash.bindAsEventListener(this));           
57                 this.controller.get('wifilist').addEventListener(Mojo.Event.listTap,this.handleWiFiTap.bind(this));
58                 this.controller.get('btlist').addEventListener(Mojo.Event.listTap,this.handleBTTap.bind(this));
59                 this.controller.get('vpnlist').addEventListener(Mojo.Event.listTap,this.handleVPNTap.bind(this));               
60 @@ -175,7 +197,143 @@ var DevicemenuAssistant = Foundations.Class.create({
61         cleanup: function() {
62                 Mojo.Log.error("Device Menu - Clean up called");
63         },      
64 -                       
65 +
66 +       handleBrightTap: function(event) {
67 +               this.controller.get('brightdetails').mojo.setOpenState(!this.controller.get('brightdetails').mojo.getOpenState());
68 +       },
69 +
70 +       handleBrightSlider: function(event) {
71 +               this.controller.serviceRequest('palm://com.palm.display/control', {
72 +                       method: 'setProperty',
73 +                       parameters:{maximumBrightness:Math.round(event.value)}
74 +               });
75 +               this.controller.get('dm_brightness').innerText = "Brightness: " + Math.round(event.value) + "%";
76 +       },
77 +       
78 +       handlePhoneTap: function(event) {
79 +               this.controller.get('phonedetails').mojo.setOpenState(!this.controller.get('phonedetails').mojo.getOpenState());
80 +       },
81 +       
82 +       togglePhone: function(event) {
83 +               if(this.phoneState=="on") {
84 +                       this.phoneState = "off";
85 +               } else {
86 +                       this.phoneState = "on";
87 +               }
88 +               this.controller.serviceRequest('palm://com.palm.telephony', {
89 +                       method: 'powerSet',
90 +                       parameters: {
91 +                               state: this.phoneState
92 +                       }
93 +               });
94 +               this.setPhoneLabel();
95 +       },
96 +
97 +       setPhoneLabel: function() {
98 +               this.controller.get('phoneStatus').innerText = this.phoneState;
99 +       },
100 +       
101 +       toggleData: function(event) {
102 +               if(this.phoneState=="on") {
103 +                       if(this.dataDisabled=="on") {
104 +                               this.dataDisabled = "off";
105 +                       } else {
106 +                               this.dataDisabled = "on";
107 +                       }
108 +                       this.controller.serviceRequest('palm://com.palm.wan', {
109 +                               method: 'set',
110 +                               parameters: {
111 +                                       disablewan: this.dataDisabled
112 +                               }
113 +                       });
114 +                       this.setDataLabel();
115 +               } else {
116 +                       Mojo.Controller.errorDialog("Error: Phone radio needs to be on and "
117 +                                       + "connected for this function");
118 +               }
119 +       },
120 +
121 +       setDataLabel: function() {
122 +               if(this.dataDisabled=="off") {
123 +                       this.controller.get('dataStatus').innerText = "on";
124 +               } else {
125 +                       this.controller.get('dataStatus').innerText = "off";
126 +               }
127 +       },
128 +       
129 +       toggleRoam: function(event) {
130 +               if(this.phoneState=="on") {
131 +                       if(this.roamStatus=="roamonly") {
132 +                               this.roamStatus="any";
133 +                       } else {
134 +                               this.roamStatus="roamonly";
135 +                       }
136 +                       this.controller.serviceRequest('palm://com.palm.telephony', {
137 +                               method: 'roamModeSet',
138 +                               parameters: {
139 +                                       mode: this.roamStatus,
140 +                                       client: Mojo.appName
141 +                               }
142 +                       });
143 +                       this.setRoamLabel();
144 +               } else {
145 +                       Mojo.Controller.errorDialog("Error: Phone radio needs to be on and "
146 +                                       + "connected for this function");
147 +               }
148 +       },
149 +
150 +       setRoamLabel: function() {
151 +               if(this.roamStatus=="roamonly") {
152 +                       this.controller.get('roamStatus').innerText = "on";
153 +               } else {
154 +                       this.controller.get('roamStatus').innerText = "off";
155 +               }
156 +       },
157 +       
158 +       /*toggleGPS: function(event) {
159 +               this.gpsEnabled = !this.gpsEnabled;
160 +               this.controller.serviceRequest('palm://com.palm.location', {
161 +                       method: 'setUseGps',
162 +                       parameters: {
163 +                               useGps: this.gpsEnabled
164 +                       }
165 +               });
166 +               this.setGPSLabel();
167 +       },
168 +
169 +       setGPSLabel: function() {
170 +               if(this.gpsEnabled) {
171 +                       this.controller.get('gpsStatus').innerText = "On";
172 +               } else {
173 +                       this.controller.get('gpsStatus').innerText = "Off";
174 +               }
175 +       },*/
176 +       
177 +       toggleFlash: function() {
178 +               if(this.flashVal==0) {
179 +                       this.flashVal = 100;
180 +               } else {
181 +                       this.flashVal = 0;
182 +               }
183 +               this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
184 +                       method: 'flashOn',
185 +                       parameters: {
186 +                               value: this.flashVal
187 +                       },
188 +                       onSuccess: function() {
189 +                               this.setFlashLabel();
190 +                       }.bind(this)
191 +               });
192 +       },
193 +       
194 +       setFlashLabel: function() {
195 +               if(this.flashVal==0) {
196 +                       this.controller.get('flashStatus').innerText = "Off";
197 +               } else {
198 +                       this.controller.get('flashStatus').innerText = "On";
199 +               }
200 +       },
201 +       
202         wifiAPList: [],
203         btdeviceList: [],
204         imeList: [{"DISPNAME":$L("PinYin"), "value":"pinyin", "showConnected":"none", "showSelected":"notselected"},{"DISPNAME":$L("Handwriting"), "value":"hwr", "showConnected":"none", "showSelected":"notselected"}],
205 @@ -1048,7 +1206,7 @@ var DevicemenuAssistant = Foundations.Class.create({
206         },
207         
208         showVPN:function(available) {
209 -               if(available) {
210 +               if(false) {
211                         this.controller.get('dm_vpn').show();
212                         this.controller.showWidgetContainer(this.controller.get('dm_vpn'));
213                 }
214 @@ -1236,6 +1394,8 @@ var DevicemenuAssistant = Foundations.Class.create({
215                         this.controller.hideWidgetContainer(this.controller.get('wifidetails'));
216                         this.wifidrawer.mojo.setOpenState(false);
217                 }
218 +               this.controller.get('brightdetails').mojo.setOpenState(false);  
219 +               this.controller.get('phonedetails').mojo.setOpenState(false);                   
220                 if(this.vpndrawer.mojo.getOpenState()) {
221                         this.controller.hideWidgetContainer(this.controller.get('vpndetails'));
222                         this.vpndrawer.mojo.setOpenState(false);
223 @@ -1437,11 +1597,96 @@ var DevicemenuAssistant = Foundations.Class.create({
224                         this.isVisible = true;
225                         var date = new Date();          
226                         this.controller.get('dm_date').innerHTML = Mojo.Format.formatDate(date,{date:'EEE '})  +  Mojo.Format.formatDate(date,{date:'long'});
227 -                       
228 +                       this.controller.serviceRequest('palm://com.palm.display/control', {
229 +                               method: 'getProperty',
230 +                               parameters:{properties:['maximumBrightness']},
231 +                               onSuccess: function(response) {
232 +                                       if(response.maximumBrightness != undefined) {
233 +                                               this.brightModel.value = parseInt(response.maximumBrightness);
234 +                                               this.controller.modelChanged(this.brightModel);
235 +                                               this.controller.get('dm_brightness').innerText = "Brightness: " + response.maximumBrightness + "%";
236 +                                       } else {
237 +                                               this.controller.get('dm_brightness').innerText = "Brightness: ??%";
238 +                                       }
239 +                               }.bind(this)
240 +                       });
241 +                       this.controller.serviceRequest('palm://com.palm.telephony', {
242 +                               method: 'powerQuery',
243 +                               parameters: {},
244 +                               onSuccess: function(response) {
245 +                                       this.phoneState = response.extended.powerState;
246 +                                       this.setPhoneLabel();
247 +                               }.bind(this)
248 +                       });                     
249 +                       this.controller.serviceRequest('palm://com.palm.connectionmanager', {
250 +                               method: 'getstatus',
251 +                               parameters: {},
252 +                               onSuccess: function(response) {
253 +                                       if(response.wan.state === "disconnected") {
254 +                                               this.dataDisabled = "on";
255 +                                       } else if(response.wan.state === "connected") {
256 +                                               this.dataDisabled = "off";
257 +                                       }
258 +                                       this.setDataLabel();
259 +                               }.bind(this)
260 +                       });
261 +                       this.controller.serviceRequest('palm://com.palm.telephony', {
262 +                               method: 'roamModeQuery',
263 +                               parameters: {},
264 +                               onSuccess: function(response) {
265 +                                       this.roamStatus = response.extended.mode;
266 +                                       this.setRoamLabel();
267 +                               }.bind(this)
268 +                       });
269 +                       /*this.controller.serviceRequest('palm://com.palm.location', {
270 +                               method: 'getUseGps',
271 +                               parameters: {},
272 +                               onSuccess: function(response) {
273 +                                       this.gpsEnabled = response.useGps;
274 +                                       this.setGPSLabel();
275 +                               }.bind(this)
276 +                       });*/
277 +                       this.flashVal = 0;
278 +                       this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
279 +                               method: 'flashState',
280 +                               parameters: {},
281 +                               onSuccess: function(response) {
282 +                                       this.flashVal = response.value;
283 +                                       this.setFlashLabel();
284 +                               }.bind(this),
285 +                               onFailure: function(err) {
286 +                                       this.controller.get('flashStatus').innerText = "Error";
287 +                               }.bind(this)
288 +                       });                                             
289                         if(this.turningOnBtRadio) {
290                                 this.btspinnerModel.spinning = true;
291                                 this.controller.modelChanged(this.btspinnerModel);
292                         }
293 +                       this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
294 +                               method: 'cpuTemperature',
295 +                               onSuccess: function(payload) {
296 +                                       if(payload.value) {
297 +                                               this.controller.get("tempmsg").innerHTML = payload.value + "&deg;C";
298 +                                       }
299 +                               }.bind(this),
300 +                               onFailure: function(err) {
301 +                                       this.controller.serviceRequest('palm://com.palm.bus/signal/', {
302 +                                               method: 'addmatch',
303 +                                               parameters: {
304 +                                                       "category":"/com/palm/power",
305 +                                                       "method":"batteryStatus"
306 +                                               },
307 +                                               onSuccess: function(payload2) {
308 +                                                       if(payload2.temperature_C) {
309 +                                                               this.controller.get("tempmsg").innerHTML = payload2.temperature_C + "&deg;C";
310 +                                                       }
311 +                                               }.bind(this)
312 +                                       });
313 +                                       this.controller.serviceRequest('palm://com.palm.power/com/palm/power/', {
314 +                                               method: 'batteryStatusQuery'
315 +                                       });
316 +                               }.bind(this)
317 +                       });                             
318                         this.activateStage();
319                         
320                         var animateDialog = function(){
321 diff --git a/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html b/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
322 index e81161a..d1b7f3b 100644
323 --- a/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
324 +++ b/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
325 @@ -15,16 +15,16 @@
326                         <div class="palm-list">          
327                                 
328                                 <div class="palm-row first"><div class="palm-row-wrapper">
329 -                                       <div id="dm_date" class="title dim"></div>
330 +                                       <div id="dm_date" class="title truncating-text"></div>
331                                 </div></div>
332 -                               
333 +
334                                 <div class="palm-section-divider">
335                                 </div> 
336                                 
337                                 <div class="palm-row"><div class="palm-row-wrapper">
338                                         <div id="dm_battery" class="title dim"></div>
339 -                               </div></div> 
340 -
341 +                               </div></div>
342 +                               
343                                 <div class="palm-section-divider"></div>
344                                 
345                                 <div class="palm-row" id="dm_ime" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
346 @@ -156,6 +156,50 @@
347                                         </div></div>
348                                         
349                                 </div>  
350 +
351 +                               <div class="palm-section-divider">
352 +                               </div>                  
353 +
354 +                               <div class="palm-row" id="phoneRow" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
355 +                                       <div id="dm_phone" class="title">Phone</div>
356 +                               </div></div>
357 +
358 +                               <div id="phonedetails" x-mojo-element="Drawer">
359 +                                       <div class="palm-row first" id="phone_radio" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
360 +                                               <div id="phoneStatus" class="label right">&nbsp;</div>
361 +                                               <div class="title">Phone Radio</div>
362 +                                       </div></div>
363 +                                       <div class="palm-row" id="phone_data" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
364 +                                               <div id="dataStatus" class="label right">&nbsp;</div>
365 +                                               <div class="title">Data Usage</div>
366 +                                       </div></div>
367 +                                       <div class="palm-row last" id="phone_roam" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
368 +                                               <div id="roamStatus" class="label right">&nbsp;</div>
369 +                                               <div class="title">Roam Only</div>
370 +                                       </div></div>
371 +                               </div>  
372 +
373 +                               <div class="palm-section-divider"></div>
374 +                               
375 +                               <div class="palm-row" id="brightRow" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
376 +                                       <div id="dm_brightness" class="title">&nbsp;
377 +                                       </div>
378 +                               </div></div>
379 +
380 +                               <div id="brightdetails" x-mojo-element="Drawer">
381 +                                       <div class="palm-row first"><div class="palm-row-wrapper">
382 +                                               <div x-mojo-element="Slider" id="brightSlider" style="padding-top: 30px; height: 50px;"></div>
383 +                                       </div></div>
384 +                               </div>
385 +
386 +                               <div class="palm-section-divider"></div>
387 +                               
388 +                               <div class="palm-row" id="dm_flash"><div class="palm-row-wrapper">
389 +                                       <div class="title truncating-text">
390 +                                               <div class="label right" id="flashStatus">&nbsp;</div>
391 +                                               <span x-mojo-loc=''>Flashlight</span>
392 +                                       </div>
393 +                               </div></div>
394                                 
395                                 <div class="palm-section-divider"></div>
396