Outstanding patches from Jason
[webos-internals:modifications.git] / top-bar / top-bar-device-menu-remix.patch
1 Name: Device Menu Remix
2 Version: 1.3.5-1
3 Author: Jason Robitaille
4 Description: Removes the date, undims the battery level, adds brightness controll, adds GPS toggle, and removes the airplane mode 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 @@ -27,8 +27,6 @@
9                 //Add a touchable row class
10                 this.controller.get('palm-device-menu').addClassName('palm-touch-rows-'+Mojo.Environment.DeviceInfo.touchableRows);
11                         
12 -               var date = new Date();
13 -               this.controller.get('dm_date').innerHTML = Mojo.Format.formatDate(date,{date:'EEE '}) +  Mojo.Format.formatDate(date,{date:'long'});
14                 var msg = $L("Battery: #{batlevel}");
15                 this.controller.get('dm_battery').innerHTML = new Template(msg).evaluate({"batlevel": Mojo.Format.formatPercent(this.barAssistant.getBatteryLevel())});
16                                                 
17 @@ -32,6 +30,8 @@
18                 var msg = $L("Battery: #{batlevel}");
19                 this.controller.get('dm_battery').innerHTML = new Template(msg).evaluate({"batlevel": Mojo.Format.formatPercent(this.barAssistant.getBatteryLevel())});
20                                                 
21 +               this.controller.setupWidget('brightSlider', {minValue: 0, maxValue: 100}, this.brightModel = { value: 50});
22 +
23                 this.modesModel = {scrollbars: false, mode: "vertical"},
24                 this.controller.setupWidget('devicescroller', {}, this.modesModel);
25                 this.menuscroller = this.controller.get('devicescroller');
26 @@ -37,6 +37,7 @@
27                 this.menuscroller = this.controller.get('devicescroller');
28                 
29                 this.drawerModel = {myOpenProperty:false};
30 +               this.controller.setupWidget('brightdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
31                 this.controller.setupWidget('wifidetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
32                 this.controller.setupWidget('btdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
33                 this.wifidrawer = this.controller.get('wifidetails');
34 @@ -64,10 +65,10 @@
35                 //Spinner for Airplande Mode
36                 //this.controller.setupWidget('apSpinner', this.spinnerAttrs, this.apSpinnerModel);             
37                         
38 -               if(this.barAssistant.getAirplaneMode())                         
39 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn off Airplane Mode');
40 -               else
41 -                       this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn on Airplane Mode');
42 +               //if(this.barAssistant.getAirplaneMode())                       
43 +               //      this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn off Airplane Mode');
44 +               //else
45 +               //      this.controller.get('dm_airplanemode_status').innerHTML = $L('Turn on Airplane Mode');
46                         
47                 var btstate = this.barAssistant.getCurrentBluetoothState();
48                 if(btstate === 'Off') {
49 @@ -113,7 +114,9 @@
50         },
51         
52         activate: function() {
53 -               this.controller.get('dm_airplanemode').addEventListener(Mojo.Event.tap, this.toggleAirplaneMode.bindAsEventListener(this));
54 +               this.controller.get('brightSlider').addEventListener(Mojo.Event.propertyChange, this.handleBrightSlider.bindAsEventListener(this));
55 +               this.controller.get('brightRow').addEventListener(Mojo.Event.tap, this.handleBrightTap.bindAsEventListener(this));
56 +               this.controller.get('dm_gps').addEventListener(Mojo.Event.tap, this.toggleGPS.bindAsEventListener(this));
57                 this.controller.get('wifilist').addEventListener(Mojo.Event.listTap,this.handleWiFiTap.bindAsEventListener(this));
58                 this.controller.get('btlist').addEventListener(Mojo.Event.listTap,this.handleBTTap.bindAsEventListener(this));          
59                 this.controller.get('dm_wifi').addEventListener(Mojo.Event.tap, this.togglewifiList.bindAsEventListener(this));
60 @@ -130,6 +133,37 @@
61         cleanup: function() {
62                 Mojo.Log.error("Device Menu - Clean up called");                                
63         },      
64 +       
65 +       handleBrightTap: function(event) {
66 +               this.controller.get('brightdetails').mojo.setOpenState(!this.controller.get('brightdetails').mojo.getOpenState());
67 +       },
68 +
69 +       handleBrightSlider: function(event) {
70 +               this.controller.serviceRequest('palm://com.palm.display/control', {
71 +                       method: 'setProperty',
72 +                       parameters:{maximumBrightness:Math.round(event.value)}
73 +               });
74 +               this.controller.get('dm_brightness').innerText = "Brightness: " + Math.round(event.value) + "%";
75 +       },
76 +       
77 +       toggleGPS: function(event) {
78 +               this.gpsEnabled = !this.gpsEnabled;
79 +               this.controller.serviceRequest('palm://com.palm.location', {
80 +                       method: 'setUseGps',
81 +                       parameters: {
82 +                               useGps: this.gpsEnabled
83 +                       }
84 +               });
85 +               this.setGPSLabel();
86 +       },
87 +
88 +       setGPSLabel: function() {
89 +               if(this.gpsEnabled) {
90 +                       this.controller.get('gpsStatus').innerText = "On";
91 +               } else {
92 +                       this.controller.get('gpsStatus').innerText = "Off";
93 +               }
94 +       },
95                         
96         wifiAPList: [],
97         btdeviceList: [],
98 @@ -932,6 +966,7 @@
99                         this.controller.hideWidgetContainer(this.controller.get('wifidetails'));
100                         this.wifidrawer.mojo.setOpenState(false);
101                 }               
102 +               this.controller.get('brightdetails').mojo.setOpenState(false);
103                 //this.isVisible = false;
104                 if(this.isVisible){
105                         this.toggleDeviceMenu();
106 @@ -973,8 +1008,28 @@
107                 }
108                 else {
109                         this.isVisible = true;
110 -                       var date = new Date();          
111 -                       this.controller.get('dm_date').innerHTML = Mojo.Format.formatDate(date,{date:'EEE '})  +  Mojo.Format.formatDate(date,{date:'long'});
112 +                       this.controller.serviceRequest('palm://com.palm.display/control', {
113 +                               method: 'getProperty',
114 +                               parameters:{properties:['maximumBrightness']},
115 +                               onSuccess: function(response) {
116 +                                       if(response.maximumBrightness != undefined) {
117 +                                               this.brightModel.value = parseInt(response.maximumBrightness);
118 +                                               this.controller.modelChanged(this.brightModel);
119 +                                               this.controller.get('dm_brightness').innerText = "Brightness: " + response.maximumBrightness + "%";
120 +                                       } else {
121 +                                               this.controller.get('dm_brightness').innerText = "Brightness: ??%";
122 +                                       }
123 +                               }.bind(this)
124 +                       });
125 +                       this.controller.serviceRequest('palm://com.palm.location', {
126 +                               method: 'getUseGps',
127 +                               parameters: {},
128 +                               onSuccess: function(response) {
129 +                                       this.gpsEnabled = response.useGps;
130 +                                       this.setGPSLabel();
131 +                               }.bind(this)
132 +                       });
133 +                       
134                         this.controller.stageController.activate();
135                         
136                         var animateDialog = function(){
137 --- .orig/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
138 +++ /usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
139 @@ -14,17 +14,23 @@
140                 <div id="devicescroller" class="palm-popup-content" x-mojo-element="Scroller">       
141                         <div class="palm-list">          
142                                 
143 -                               <div class="palm-row first"><div class="palm-row-wrapper">
144 -                                       <div id="dm_date" class="title dim"></div>
145 -                               </div></div>
146 -                               
147 -                               <div class="palm-section-divider">
148 -                               </div> 
149 -                               
150                                 <div class="palm-row"><div class="palm-row-wrapper">
151 -                                       <div id="dm_battery" class="title dim"></div>
152 +                                       <div id="dm_battery" class="title"></div>
153                                 </div></div> 
154                                 
155 +                                                               <div class="palm-section-divider">
156 +                               </div>
157 +
158 +                               <div class="palm-row" id="brightRow" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
159 +                                       <div id="dm_brightness" class="title"></div>
160 +                               </div></div>
161 +
162 +                               <div id="brightdetails" x-mojo-element="Drawer">
163 +                                       <div class="palm-row first"><div class="palm-row-wrapper">
164 +                                               <div x-mojo-element="Slider" id="brightSlider" style="padding-top: 30px; height: 50px;"></div>
165 +                                       </div></div>
166 +                               </div>
167 +                               
168                                 <div class="palm-section-divider">
169                                 </div>               
170                                 
171 @@ -95,11 +101,12 @@
172                                 <div class="palm-section-divider"></div>
173                                 
174 -                               <div id="dm_airplanemode" class="palm-row last menu-end" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
175 -                                       <div id="dm_airplanemode_status" class="title truncating-text">
176 -                                        </div>
177 -                                        <!--<div id='apSpinner' class='label' x-mojo-element="Spinner"></div>-->
178 -                               </div></div>   
179 +                               <div class="palm-row last menu-end" id="dm_gps" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
180 +                                       <div class="title truncating-text">
181 +                                               <div class="label right" id="gpsStatus">&nbsp;</div>
182 +                                               <span x-mojo-loc=''>GPS</span>
183 +                                       </div>
184 +                               </div></div>
185                                 
186                                 </div>       
187                         </div>
188                 </div>