updates and additions
[webos-internals:modifications.git] / top-bar / top-bar-device-menu-remix.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 08f7f75..21f7a7c 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 @@ -28,16 +28,16 @@ var DevicemenuAssistant = Foundations.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('imedetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
22                 this.controller.setupWidget('wifidetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
23                 this.controller.setupWidget('btdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
24 @@ -91,10 +91,6 @@ var DevicemenuAssistant = Foundations.Class.create({
25                 //Spinner for BT
26                 this.controller.setupWidget('btSpinner', this.spinnerAttrs, this.btspinnerModel);
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 @@ -147,10 +143,18 @@ 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('dm_gps').addEventListener(Mojo.Event.tap, this.toggleGPS.bindAsEventListener(this));
52                 this.controller.get('wifilist').addEventListener(Mojo.Event.listTap,this.handleWiFiTap.bind(this));
53                 this.controller.get('btlist').addEventListener(Mojo.Event.listTap,this.handleBTTap.bind(this));
54                 this.controller.get('vpnlist').addEventListener(Mojo.Event.listTap,this.handleVPNTap.bind(this));               
55 @@ -175,6 +179,37 @@ var DevicemenuAssistant = Foundations.Class.create({
56         cleanup: function() {
57                 Mojo.Log.error("Device Menu - Clean up called");
58         },      
59 +       
60 +       handleBrightTap: function(event) {
61 +               this.controller.get('brightdetails').mojo.setOpenState(!this.controller.get('brightdetails').mojo.getOpenState());
62 +       },
63 +
64 +       handleBrightSlider: function(event) {
65 +               this.controller.serviceRequest('palm://com.palm.display/control', {
66 +                       method: 'setProperty',
67 +                       parameters:{maximumBrightness:Math.round(event.value)}
68 +               });
69 +               this.controller.get('dm_brightness').innerText = "Brightness: " + Math.round(event.value) + "%";
70 +       },
71 +       
72 +       toggleGPS: function(event) {
73 +               this.gpsEnabled = !this.gpsEnabled;
74 +               this.controller.serviceRequest('palm://com.palm.location', {
75 +                       method: 'setUseGps',
76 +                       parameters: {
77 +                               useGps: this.gpsEnabled
78 +                       }
79 +               });
80 +               this.setGPSLabel();
81 +       },
82 +
83 +       setGPSLabel: function() {
84 +               if(this.gpsEnabled) {
85 +                       this.controller.get('gpsStatus').innerText = "On";
86 +               } else {
87 +                       this.controller.get('gpsStatus').innerText = "Off";
88 +               }
89 +       },
90                         
91         wifiAPList: [],
92         btdeviceList: [],
93 @@ -200,12 +235,12 @@ var DevicemenuAssistant = Foundations.Class.create({
94                 if(this.barAssistant.getAirplaneMode()) {
95                         Mojo.Log.info("SystemUI - Turning off Airplane Mode - Device Menu");
96                         this.barAssistant.setAirplaneMode(false);
97 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turning off Airplane Mode');                      
98 +                       //this.controller.get('dm_airplanemode_status').innerHTML = $L('Turning off Airplane Mode');                    
99                 }                       
100                 else {
101                         Mojo.Log.info("SystemUI - Turning on Airplane Mode - Device Menu");
102                         this.barAssistant.setAirplaneMode(true);
103 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turning on Airplane Mode');
104 +                       //this.controller.get('dm_airplanemode_status').innerHTML = $L('Turning on Airplane Mode');
105                 }
106                 this.apModeInProgress = true;
107                 this.toggleDeviceMenu.delay(0.2);               
108 @@ -216,21 +251,15 @@ var DevicemenuAssistant = Foundations.Class.create({
109                 //this.apSpinnerModel.spinning = false;
110                 //this.controller.modelChanged(this.apSpinnerModel);
111                 
112 -               if(this.barAssistant.getAirplaneMode()) {
113 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn off Airplane Mode');                 
114 -               }                       
115 -               else {                  
116 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn on Airplane Mode');
117 -               }
118                 this.apModeInProgress = false;
119         },
120         
121         updateAirplaneModeProgress: function() {
122                 if(this.barAssistant.getAirplaneMode()) {
123 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turning on Airplane Mode');
124 +                       //this.controller.get('dm_airplanemode_status').innerHTML = $L('Turning on Airplane Mode');
125                 }                       
126                 else {
127 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turning off Airplane Mode');
128 +                       //this.controller.get('dm_airplanemode_status').innerHTML = $L('Turning off Airplane Mode');
129                 }
130                 this.apModeInProgress = true;
131         },
132 @@ -1062,7 +1091,7 @@ var DevicemenuAssistant = Foundations.Class.create({
133         },
134         
135         showVPN:function(available) {
136 -               if(available) {
137 +               if(false) {
138                         this.controller.get('dm_vpn').show();
139                         this.controller.showWidgetContainer(this.controller.get('dm_vpn'));
140                 }
141 @@ -1262,6 +1291,7 @@ var DevicemenuAssistant = Foundations.Class.create({
142                         this.controller.hideWidgetContainer(this.controller.get('wifidetails'));
143                         this.wifidrawer.mojo.setOpenState(false);
144                 }
145 +               this.controller.get('brightdetails').mojo.setOpenState(false);
146                 if(this.vpndrawer.mojo.getOpenState()) {
147                         this.controller.hideWidgetContainer(this.controller.get('vpndetails'));
148                         this.vpndrawer.mojo.setOpenState(false);
149 @@ -1461,8 +1491,27 @@ var DevicemenuAssistant = Foundations.Class.create({
150                 }
151                 else {
152                         this.isVisible = true;
153 -                       var date = new Date();          
154 -                       this.controller.get('dm_date').innerHTML = Mojo.Format.formatDate(date,{date:'EEE '})  +  Mojo.Format.formatDate(date,{date:'long'});
155 +                       this.controller.serviceRequest('palm://com.palm.display/control', {
156 +                               method: 'getProperty',
157 +                               parameters:{properties:['maximumBrightness']},
158 +                               onSuccess: function(response) {
159 +                                       if(response.maximumBrightness != undefined) {
160 +                                               this.brightModel.value = parseInt(response.maximumBrightness);
161 +                                               this.controller.modelChanged(this.brightModel);
162 +                                               this.controller.get('dm_brightness').innerText = "Brightness: " + response.maximumBrightness + "%";
163 +                                       } else {
164 +                                               this.controller.get('dm_brightness').innerText = "Brightness: ??%";
165 +                                       }
166 +                               }.bind(this)
167 +                       });
168 +                       this.controller.serviceRequest('palm://com.palm.location', {
169 +                               method: 'getUseGps',
170 +                               parameters: {},
171 +                               onSuccess: function(response) {
172 +                                       this.gpsEnabled = response.useGps;
173 +                                       this.setGPSLabel();
174 +                               }.bind(this)
175 +                       });
176                         
177                         if(this.turningOnBtRadio) {
178                                 this.btspinnerModel.spinning = true;
179 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
180 index 0e43a60..e84620d 100644
181 --- a/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
182 +++ b/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
183 @@ -14,16 +14,18 @@
184                 <div id="devicescroller" class="palm-popup-content" x-mojo-element="Scroller">       
185                         <div class="palm-list">          
186                                 
187 -                               <div class="palm-row first"><div class="palm-row-wrapper">
188 -                                       <div id="dm_date" class="title dim"></div>
189 -                               </div></div>
190 -                               
191 -                               <div class="palm-section-divider">
192 -                               </div> 
193 -                               
194 -                               <div class="palm-row"><div class="palm-row-wrapper">
195 -                                       <div id="dm_battery" class="title dim"></div>
196 -                               </div></div> 
197 +                                       <div class="palm-row first"><div class="palm-row-wrapper">
198 +                                               <div id="dm_battery" class="title"></div>
199 +                                       </div></div>
200 +                                       <div class="palm-section-divider"></div>
201 +                                       <div class="palm-row" id="brightRow" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
202 +                                               <div id="dm_brightness" class="title"></div>
203 +                                       </div></div>
204 +                                       <div id="brightdetails" x-mojo-element="Drawer">
205 +                                               <div class="palm-row first"><div class="palm-row-wrapper">
206 +                                                       <div x-mojo-element="Slider" id="brightSlider" style="padding-top: 30px; height: 50px;"></div>
207 +                                               </div></div>
208 +                                       </div>
209  
210                                 <div class="palm-section-divider"></div>
211                                 
212 @@ -159,9 +161,11 @@
213                                 </div>  
214                                 
215                                 <div class="palm-section-divider"></div>
216 -                               
217 -                               <div id="dm_airplanemode" class="palm-row last menu-end" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
218 -                                       <div id="dm_airplanemode_status" class="title truncating-text">
219 +
220 +                                <div class="palm-row last menu-end" id="dm_gps" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
221 +                                        <div class="title truncating-text">
222 +                                                <div class="label right" id="gpsStatus">&nbsp;</div>
223 +                                                <span x-mojo-loc=''>GPS</span>
224                                          </div>
225                                 </div></div>   
226