28 Updates for Patches
[webos-internals:modifications.git] / top-bar / top-bar-flashlight-in-device-menu.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 2a42b1a..efbfca6 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 @@ -122,6 +122,7 @@ var DevicemenuAssistant = Class.create({
6                 this.controller.get('bt_radio').addEventListener(Mojo.Event.tap, this.toggleBTRadio.bindAsEventListener(this));
7                 this.controller.get('bt_pref').addEventListener(Mojo.Event.tap,this.handleBluetoothLaunch.bindAsEventListener(this));
8                 this.controller.get('wifi_pref').addEventListener(Mojo.Event.tap,this.handleWiFiLaunch.bindAsEventListener(this));
9 +               this.controller.get('dm_flash').addEventListener(Mojo.Event.tap, this.toggleFlash.bindAsEventListener(this));
10                 this.controller.get('scrim').addEventListener(Mojo.Event.tap, this.toggleDeviceMenu.bindAsEventListener(this));
11                 //Close the App because this is a first launch.
12                 this.toggleDeviceMenu();                                                
13 @@ -178,6 +179,31 @@ var DevicemenuAssistant = Class.create({
14                 this.apModeInProgress = false;
15         },
16         
17 +       toggleFlash: function() {
18 +               if(this.flashVal==0) {
19 +                       this.flashVal = 100;
20 +               } else {
21 +                       this.flashVal = 0;
22 +               }
23 +               this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
24 +                       method: 'flashOn',
25 +                       parameters: {
26 +                               value: this.flashVal
27 +                       },
28 +                       onSuccess: function() {
29 +                               this.setFlashLabel();
30 +                       }.bind(this)
31 +               });
32 +       },
33 +       
34 +       setFlashLabel: function() {
35 +               if(this.flashVal==0) {
36 +                       this.controller.get('flashStatus').innerText = "Off";
37 +               } else {
38 +                       this.controller.get('flashStatus').innerText = "On";
39 +               }
40 +       },
41 +       
42         toggleBTRadio: function(event) {
43                 if(RadioState.get('bluetooth')) {
44                         BtService.radiooff(null,null);                  
45 @@ -987,6 +1013,19 @@ var DevicemenuAssistant = Class.create({
46                                 );
47                         }
48              
49 +                       this.flashVal = 0;
50 +                       this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
51 +                               method: 'flashState',
52 +                               parameters: {},
53 +                               onSuccess: function(response) {
54 +                                       this.flashVal = response.value;
55 +                                       this.setFlashLabel();
56 +                               }.bind(this),
57 +                               onFailure: function(err) {
58 +                                       this.controller.get('flashStatus').innerText = "Error";
59 +                               }.bind(this)
60 +                       });
61 +
62                         //animate the scrim onto the scene and then the submenu
63                         Mojo.Animation.animateStyle(this.scrim, 'opacity', 'bezier', {
64                                                 from: 0,
65 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
66 index 933094e..9cfb512 100644
67 --- a/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
68 +++ b/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
69 @@ -94,6 +94,15 @@
70                                 
71                                 <div class="palm-section-divider"></div>
72                                 
73 +                               <div class="palm-row" id="dm_flash"><div class="palm-row-wrapper">
74 +                                       <div class="title truncating-text">
75 +                                               <div class="label right" id="flashStatus">&nbsp;</div>
76 +                                               <span x-mojo-loc=''>Flashlight</span>
77 +                                       </div>
78 +                               </div></div>
79 +
80 +                               <div class="palm-section-divider"></div>
81 +                               
82                                 <div id="dm_airplanemode" class="palm-row last menu-end" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
83                                         <div id="dm_airplanemode_status" class="title truncating-text">
84                                          </div>