28 Updates for Patches
[webos-internals:imagineer1981s-modifications.git] / top-bar / top-bar-device-menu-remix-with-flashlight.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 335a73c..146fc8e 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,16 +32,16 @@ var DevicemenuAssistant = Class.create({
6                 //Add a touchable row class
7                 this.controller.get('palm-device-menu').addClassName('palm-touch-rows-'+Mojo.Environment.DeviceInfo.touchableRows);
8                         
9 -               var date = new Date();
10 -               this.controller.get('dm_date').innerHTML = Mojo.Format.formatDate(date,{date:'EEE '}) +  Mojo.Format.formatDate(date,{date:'long'});
11                 var msg = $L("Battery: #{batlevel}");
12                 this.controller.get('dm_battery').innerHTML = new Template(msg).evaluate({"batlevel": Mojo.Format.formatPercent(this.barAssistant.getBatteryLevel())});
13 +               this.controller.setupWidget('brightSlider', {minValue: 1, maxValue: 100}, this.brightModel = { value: 50});
14                                                 
15                 this.modesModel = {scrollbars: false, mode: "vertical"},
16                 this.controller.setupWidget('devicescroller', {}, this.modesModel);
17                 this.menuscroller = this.controller.get('devicescroller');
18                 
19                 this.drawerModel = {myOpenProperty:false};
20 +               this.controller.setupWidget('brightdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
21                 this.controller.setupWidget('wifidetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
22                 this.controller.setupWidget('btdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
23                 this.wifidrawer = this.controller.get('wifidetails');
24 @@ -72,10 +72,6 @@ var DevicemenuAssistant = Class.create({
25                 //Spinner for Airplande Mode
26                 //this.controller.setupWidget('apSpinner', this.spinnerAttrs, this.apSpinnerModel);             
27                         
28 -               if(this.barAssistant.getAirplaneMode())                         
29 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn off Airplane Mode');
30 -               else
31 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn on Airplane Mode');
32                         
33                 var btstate = this.barAssistant.getCurrentBluetoothState();
34                 if(btstate === 'Off') {
35 @@ -121,7 +117,10 @@ var DevicemenuAssistant = Class.create({
36         },
37         
38         activate: function() {
39 -               this.controller.get('dm_airplanemode').addEventListener(Mojo.Event.tap, this.toggleAirplaneMode.bindAsEventListener(this));
40 +               this.controller.get('brightSlider').addEventListener(Mojo.Event.propertyChange, this.handleBrightSlider.bindAsEventListener(this));
41 +               this.controller.get('brightRow').addEventListener(Mojo.Event.tap, this.handleBrightTap.bindAsEventListener(this));
42 +               this.controller.get('dm_gps').addEventListener(Mojo.Event.tap, this.toggleGPS.bindAsEventListener(this));
43 +               this.controller.get('dm_flash').addEventListener(Mojo.Event.tap, this.toggleFlash.bindAsEventListener(this));
44                 this.controller.get('wifilist').addEventListener(Mojo.Event.listTap,this.handleWiFiTap.bindAsEventListener(this));
45                 this.controller.get('btlist').addEventListener(Mojo.Event.listTap,this.handleBTTap.bindAsEventListener(this));          
46                 this.controller.get('dm_wifi').addEventListener(Mojo.Event.tap, this.togglewifiList.bindAsEventListener(this));
47 @@ -139,6 +138,62 @@ var DevicemenuAssistant = Class.create({
48                 Mojo.Log.error("Device Menu - Clean up called");                                
49         },      
50                         
51 +       handleBrightTap: function(event) {
52 +               this.controller.get('brightdetails').mojo.setOpenState(!this.controller.get('brightdetails').mojo.getOpenState());
53 +       },
54 +
55 +       handleBrightSlider: function(event) {
56 +               this.controller.serviceRequest('palm://com.palm.display/control', {
57 +                       method: 'setProperty',
58 +                       parameters:{maximumBrightness:Math.round(event.value)}
59 +               });
60 +               this.controller.get('dm_brightness').innerText = "Brightness: " + Math.round(event.value) + "%";
61 +       },
62 +       
63 +       toggleGPS: function(event) {
64 +               this.gpsEnabled = !this.gpsEnabled;
65 +               this.controller.serviceRequest('palm://com.palm.location', {
66 +                       method: 'setUseGps',
67 +                       parameters: {
68 +                               useGps: this.gpsEnabled
69 +                       }
70 +               });
71 +               this.setGPSLabel();
72 +       },
73 +
74 +       setGPSLabel: function() {
75 +               if(this.gpsEnabled) {
76 +                       this.controller.get('gpsStatus').innerText = "On";
77 +               } else {
78 +                       this.controller.get('gpsStatus').innerText = "Off";
79 +               }
80 +       },
81 +       
82 +       toggleFlash: function() {
83 +               if(this.flashVal==0) {
84 +                       this.flashVal = 100;
85 +               } else {
86 +                       this.flashVal = 0;
87 +               }
88 +               this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
89 +                       method: 'flashOn',
90 +                       parameters: {
91 +                               value: this.flashVal
92 +                       },
93 +                       onSuccess: function() {
94 +                               this.setFlashLabel();
95 +                       }.bind(this)
96 +               });
97 +       },
98 +       
99 +       setFlashLabel: function() {
100 +               if(this.flashVal==0) {
101 +                       this.controller.get('flashStatus').innerText = "Off";
102 +               } else {
103 +                       this.controller.get('flashStatus').innerText = "On";
104 +               }
105 +       },
106 +                       
107         wifiAPList: [],
108         btdeviceList: [],
109                 
110 @@ -177,12 +232,6 @@ var DevicemenuAssistant = Class.create({
111                 //this.apSpinnerModel.spinning = false;
112                 //this.controller.modelChanged(this.apSpinnerModel);
113                 
114 -               if(this.barAssistant.getAirplaneMode()) {
115 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn off Airplane Mode');                 
116 -               }                       
117 -               else {                  
118 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn on Airplane Mode');
119 -               }
120                 this.apModeInProgress = false;
121         },
122         
123 @@ -1028,6 +1077,7 @@ var DevicemenuAssistant = Class.create({
124                         this.controller.hideWidgetContainer(this.controller.get('wifidetails'));
125                         this.wifidrawer.mojo.setOpenState(false);
126                 }               
127 +               this.controller.get('brightdetails').mojo.setOpenState(false);
128                 //this.isVisible = false;
129                 if(this.isVisible){
130                         this.toggleDeviceMenu();
131 @@ -1071,8 +1121,39 @@ var DevicemenuAssistant = Class.create({
132                 }
133                 else {
134                         this.isVisible = true;
135 -                       var date = new Date();          
136 -                       this.controller.get('dm_date').innerHTML = Mojo.Format.formatDate(date,{date:'EEE '})  +  Mojo.Format.formatDate(date,{date:'long'});
137 +                       this.controller.serviceRequest('palm://com.palm.display/control', {
138 +                               method: 'getProperty',
139 +                               parameters:{properties:['maximumBrightness']},
140 +                               onSuccess: function(response) {
141 +                                       if(response.maximumBrightness != undefined) {
142 +                                               this.brightModel.value = parseInt(response.maximumBrightness);
143 +                                               this.controller.modelChanged(this.brightModel);
144 +                                               this.controller.get('dm_brightness').innerText = "Brightness: " + response.maximumBrightness + "%";
145 +                                       } else {
146 +                                               this.controller.get('dm_brightness').innerText = "Brightness: ??%";
147 +                                       }
148 +                               }.bind(this)
149 +                       });
150 +                       this.controller.serviceRequest('palm://com.palm.location', {
151 +                               method: 'getUseGps',
152 +                               parameters: {},
153 +                               onSuccess: function(response) {
154 +                                       this.gpsEnabled = response.useGps;
155 +                                       this.setGPSLabel();
156 +                               }.bind(this)
157 +                       });
158 +                       this.flashVal = 0;
159 +                       this.controller.serviceRequest('palm://ca.canucksoftware.systoolsmgr', {
160 +                               method: 'flashState',
161 +                               parameters: {},
162 +                               onSuccess: function(response) {
163 +                                       this.flashVal = response.value;
164 +                                       this.setFlashLabel();
165 +                               }.bind(this),
166 +                               onFailure: function(err) {
167 +                                       this.controller.get('flashStatus').innerText = "Error";
168 +                               }.bind(this)
169 +                       });
170                         
171                         if(this.turningOnBtRadio) {
172                                 this.btspinnerModel.spinning = true;
173 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
174 index d153a8d..bb0049b 100644
175 --- a/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
176 +++ b/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
177 @@ -14,17 +14,25 @@
178                 <div id="devicescroller" class="palm-popup-content" x-mojo-element="Scroller">       
179                         <div class="palm-list">          
180                                 
181 -                               <div class="palm-row first"><div class="palm-row-wrapper">
182 -                                       <div id="dm_date" class="title dim"></div>
183 +                               <div class="palm-row"><div class="palm-row-wrapper">
184 +                                       <div id="dm_battery" class="title">&nbsp;
185 +                                       </div>
186                                 </div></div>
187                                 
188                                 <div class="palm-section-divider">
189                                 </div> 
190                                 
191 -                               <div class="palm-row"><div class="palm-row-wrapper">
192 -                                       <div id="dm_battery" class="title dim"></div>
193 +                               <div class="palm-row" id="brightRow" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
194 +                                       <div id="dm_brightness" class="title">&nbsp;
195 +                                       </div>
196                                 </div></div> 
197                                 
198 +                               <div id="brightdetails" x-mojo-element="Drawer">
199 +                                       <div class="palm-row first"><div class="palm-row-wrapper">
200 +                                               <div x-mojo-element="Slider" id="brightSlider" style="padding-top: 30px; height: 50px;"></div>
201 +                                       </div></div>
202 +                               </div>
203 +                               
204                                 <div class="palm-section-divider">
205                                 </div>               
206                                 
207 @@ -97,10 +105,17 @@
208                                 
209                                 <div class="palm-section-divider"></div>
210                                 
211 -                               <div id="dm_airplanemode" class="palm-row last menu-end" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
212 -                                       <div id="dm_airplanemode_status" class="title truncating-text">
213 +                               <div class="palm-row" id="dm_gps" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
214 +                                       <div class="title truncating-text">
215 +                                               <div class="label right" id="gpsStatus">&nbsp;</div>
216 +                                               <span x-mojo-loc=''>GPS</span>
217 +                                       </div>
218 +                               </div></div>
219 +                               <div class="palm-row last menu-end" id="dm_flash"><div class="palm-row-wrapper">
220 +                                       <div class="title truncating-text">
221 +                                               <div class="label right" id="flashStatus">&nbsp;</div>
222 +                                               <span x-mojo-loc=''>Flashlight</span>
223                                          </div>
224 -                                        <!--<div id='apSpinner' class='label' x-mojo-element="Spinner"></div>-->
225                                 </div></div>   
226                                 
227                                 </div>