Added verizon versions of system menu patches
[webos-internals:imagineer1981s-modifications.git] / advanced / advanced-system-menus-power-menu-vzw.patch
1 --- .orig/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
2 +++ /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
3 @@ -460,12 +460,12 @@
4                 }
5         }       
6         
7 -       if(!this.deviceLocked) {
8 +/*     if(!this.deviceLocked) {
9                 var appController = Mojo.Controller.getAppController();
10                 var stageController = appController.getStageController("PowerOffAlert");
11                 if(stageController)
12                         stageController.delegateToSceneAssistant("cancelTimer");
13 -       }
14 +       } */
15  },
16  
17  isDeviceLocked: function() {
18 @@ -2612,9 +2612,9 @@
19      if (payload["mode-avail"]) {
20                 this.isUSBConnected = true;
21                 if (!this.onActiveCall) {
22 -                       if (this.canUSBAlertDisplayed()) 
23 -                               this.showStorageModeAlert();
24 -                       else 
25 +//                     if (this.canUSBAlertDisplayed()) 
26 +//                             this.showStorageModeAlert();
27 +//                     else 
28                                 this.createUSBDashboard();
29                 }
30         }
31 @@ -2730,10 +2730,10 @@
32                                 Mojo.Log.info("SystemUI - USB Is connected(During Init)" + Object.toJSON(payload));
33                                 this.isUSBConnected = true;
34                                 if (!this.onActiveCall) {
35 -                                       if (this.updateAvailable) 
36 +//                                     if (this.updateAvailable) 
37                                                 this.createUSBDashboard();
38 -                                       else 
39 -                                               this.showStorageModeAlert();
40 +//                                     else 
41 +//                                             this.showStorageModeAlert();
42                                 }                                                       
43                         }
44                 }.bind(this),
45 @@ -2807,6 +2807,16 @@
46   * Register to receive power off notifications
47   */
48  powerOffInit: function() {
49 +       this.powerMenuCfg = {items: ["shutdownDevice", "restartDevice"], allowSleep: true};
50 +
51 +       var cookieContainer = new Mojo.Model.Cookie("powerMenu");
52 +               
53 +       var cookie = cookieContainer.get();
54 +
55 +       if(cookie) {
56 +               this.powerMenuCfg.items = cookie.menuItems;
57 +       }
58 +
59      this.powerOffNotificationSession = new Mojo.Service.Request('palm://com.palm.bus/signal/', {
60                 method: 'addmatch',
61                 parameters: {
62 @@ -2844,21 +2854,39 @@
63         
64         var appController = Mojo.Controller.getAppController();
65         var stageController = appController.getStageController("PowerOffAlert");
66 +       
67 +               if (stageController) {
68 +                       appController.closeStage("PowerOffAlert");
69 +
70 +                       var f = function(stageController){
71 +                     stageController.pushScene('poweroffalert',this, this.powerMenuCfg, true);
72 +                   }.bind(this);
73 +                   var params = {name: 'PowerOffAlertEdit', height: 240,lightweight:true};
74 +               
75 +                   appController.createStageWithCallback(params,f,'popupalert');
76 +               }
77 +               else {
78 +                       appController.closeStage("PowerOffAlertEdit");
79 +               
80          // if the window already exists, don't do anything
81          if (!stageController) {
82                 // Create a popuo alert
83                     var f = function(stageController){
84 -                     stageController.pushScene('poweroffalert',this);
85 +                     stageController.pushScene('poweroffalert',this, this.powerMenuCfg, false);
86                     }.bind(this);
87 -                   var params = {name: 'PowerOffAlert', height: 175,lightweight:true};                     
88 +                   
89 +                        var popupHeight = (this.powerMenuCfg.items.length + 1) * 55 + 10;
90 +                   
91 +                   var params = {name: 'PowerOffAlert', height: popupHeight,lightweight:true};
92                     appController.createStageWithCallback(params,f,'popupalert');
93          }
94 +       }
95         //Close the Storage Alert and create a USB dashboard.
96 -       var storageAlertStageController = appController.getStageController('StorageModeAlert');
97 +/*     var storageAlertStageController = appController.getStageController('StorageModeAlert');
98         if(storageAlertStageController) {
99                 storageAlertStageController.delegateToSceneAssistant("closeAndCreateDashboard");
100                 this.createUSBDashboard.bind(this).delay(0.5,false);
101 -       }
102 +       } */
103                         
104  },
105      
106 --- .orig/usr/lib/luna/system/luna-systemui/app/controllers/poweroffalert-assistant.js
107 +++ /usr/lib/luna/system/luna-systemui/app/controllers/poweroffalert-assistant.js
108 @@ -1,21 +1,43 @@
109  /* Copyright 2009 Palm, Inc.  All rights reserved. */
110  
111  var PoweroffalertAssistant = Foundations.Class.create({
112 -    initialize: function(barAssistant) {       
113 +    initialize: function(barAssistant, menuCfg, editMenu) {    
114                 this.barAssistant = barAssistant;       
115 +               this.menuCfg = menuCfg;
116 +               this.editMenu = editMenu;
117      },
118      
119      setup: function() {                
120 +       if(this.editMenu) {
121 +                       this.controller.get('powermenu').hide();
122 +                       this.controller.get('editmenu').show();
123 +
124 +                       for(var i = 0; i < this.menuCfg.items.length; i++)
125 +                               this.controller.get(this.menuCfg.items[i] + "State").update($L("SHOW"));
126 +               }
127 +               else {
128 +                       for(var i = 0; i < this.menuCfg.items.length; i++)
129 +                               this.controller.get(this.menuCfg.items[i] + "Button").show();
130 +               }
131 +               
132 +               var luna = this.luna.bindAsEventListener(this);
133 +               var sleep = this.sleep.bindAsEventListener(this);
134 +               var restart = this.restart.bindAsEventListener(this);
135                 var flightMode = this.flightMode.bindAsEventListener(this);
136 -               var powerOff = this.powerOff.bindAsEventListener(this);
137 +               var powerOff = this.shutdown.bindAsEventListener(this);
138                 var cancel = this.cancel.bindAsEventListener(this);
139                 var launchAirplaneModeHelp = this.launchAirplaneModeHelp.bindAsEventListener(this);
140                 this.flightMode = this.barAssistant.getAirplaneMode();
141                 if(this.flightMode)
142                         this.controller.get('flightmode').innerHTML = $L('Turn off Airplane Mode');
143 -               else
144 -                       this.controller.get('flightmode').innerHTML = "<div class='info-icon' id='airplaneInfo' x-mojo-touch-feedback='immediate'></div>" + $L('Airplane Mode');
145 +//             else
146 +//                     this.controller.get('flightmode').innerHTML = "<div class='info-icon' id='airplaneInfo' x-mojo-touch-feedback='immediate'></div>" + $L('Airplane Mode');
147 +               if(!this.menuCfg.allowSleep)
148 +                       this.controller.get('sleep').innerHTML = $L('Enable Device Sleep');
149                         
150 +               this.controller.get('luna').addEventListener(Mojo.Event.tap, luna);
151 +               this.controller.get('sleep').addEventListener(Mojo.Event.tap, sleep);
152 +               this.controller.get('restart').addEventListener(Mojo.Event.tap, restart);
153                 this.controller.get('poweroff').addEventListener(Mojo.Event.tap, powerOff);
154                 this.controller.get('flightmode').addEventListener(Mojo.Event.tap, flightMode);
155                 this.controller.get('cancel').addEventListener(Mojo.Event.tap, cancel);
156 @@ -26,6 +48,35 @@
157                         this.powerOffAlertCancel = this.cancel.bind(this);
158                         this.powerOffAlertTimer = this.controller.window.setTimeout(this.powerOffAlertCancel, 30000);
159                 }
160 +
161 +               this.controller.get('airplaneModeEdit').addEventListener(Mojo.Event.tap, this.editToggle.bind(this, "airplaneMode"));
162 +               this.controller.get('deviceSleepEdit').addEventListener(Mojo.Event.tap, this.editToggle.bind(this, "deviceSleep"));
163 +               this.controller.get('shutdownDeviceEdit').addEventListener(Mojo.Event.tap, this.editToggle.bind(this, "shutdownDevice"));
164 +               this.controller.get('restartDeviceEdit').addEventListener(Mojo.Event.tap, this.editToggle.bind(this, "restartDevice"));
165 +               this.controller.get('restartLunaEdit').addEventListener(Mojo.Event.tap, this.editToggle.bind(this, "restartLuna"));
166 +       },
167 +       
168 +       editToggle: function(item) {
169 +               var index = this.menuCfg.items.indexOf(item);
170 +               
171 +               if(index == -1) {
172 +                       this.controller.get(item + "State").update($L("SHOW"));
173 +                       
174 +                       this.menuCfg.items.push(item);
175 +               }
176 +               else {
177 +                       this.controller.get(item + "State").update($L("HIDE"));
178 +                       
179 +                       this.menuCfg.items.splice(index, 1);
180 +               }
181 +               
182 +               var cookieContainer = new Mojo.Model.Cookie("powerMenu");
183 +               
184 +               var cookie = {
185 +                       menuItems: this.menuCfg.items
186 +               }
187 +               
188 +               cookieContainer.put(cookie);
189         },
190         
191         cleanup: function() {
192 @@ -33,6 +84,49 @@
193              this.controller.window.clearTimeout(this.powerOffAlertTimer);
194          } catch(e) {}
195         },
196 +
197 +       luna: function() {
198 +               if(!this.lunaRestartTimer)
199 +                       this.lunaRestartTimer = this.controller.window.setTimeout(this.lunaRestart, 250);
200 +       },
201 +       
202 +       lunaRestart: function() {
203 +               var request = new Mojo.Service.Request('palm://org.webosinternals.ipkgservice/', {
204 +                       method: 'restartLuna'});
205 +       },
206 +               
207 +       sleep: function() {
208 +               if(this.menuCfg.allowSleep) {
209 +                       this.menuCfg.allowSleep = false;
210 +                       
211 +                       this.request = this.controller.serviceRequest("palm://com.palm.display/control", {
212 +                               method: "setProperty", parameters: {requestBlock: true, client: "powerMenu"}});
213 +
214 +                       this.request = this.controller.serviceRequest("palm://com.palm.power/com/palm/power", {
215 +                               method: "activityStart", parameters: {id: "com.palm.systemui", duration_ms: '86400000'}});
216 +               }
217 +               else {
218 +                       this.menuCfg.allowSleep = true;
219 +
220 +                       this.request = this.controller.serviceRequest("palm://com.palm.display/control", {
221 +                               method: "setProperty", parameters: {requestBlock: false, client: "powerMenu"}});
222 +
223 +                       this.request = this.controller.serviceRequest("palm://com.palm.power/com/palm/power", {
224 +                               method: "activityEnd", parameters: {id: "com.palm.systemui"}});
225 +               }       
226 +
227 +               this.controller.window.close();
228 +       },
229 +       
230 +       restart: function() {
231 +               this.barAssistant.machineReboot("Restart request by User");
232 +               this.controller.window.close();
233 +       },
234 +       
235 +       shutdown:function() {
236 +               this.barAssistant.machineOffNow("Shutdown request by User");
237 +               this.controller.window.close();
238 +       },
239         
240         powerOff:function() {   
241                 var appController = Mojo.Controller.getAppController();
242 --- .orig/usr/lib/luna/system/luna-systemui/app/views/poweroffalert/poweroffalert-scene.html
243 +++ /usr/lib/luna/system/luna-systemui/app/views/poweroffalert/poweroffalert-scene.html
244 @@ -1,5 +1,47 @@
245  <div class="system-notification power-off">
246 -               <div class="palm-notification-button affirmative" x-mojo-tap-highlight="immediate" id='flightmode' x-mojo-loc=''></div>
247 -               <div class="palm-notification-button negative" x-mojo-tap-highlight="immediate" id='poweroff' x-mojo-loc=''>Power</div>
248 -               <div class="palm-notification-button" x-mojo-tap-highlight="immediate" id='cancel' x-mojo-loc=''>Cancel</div>
249 -</div>
250 \ No newline at end of file
251 +       <div id="powermenu">
252 +               <div id="airplaneModeButton" style="display:none;">
253 +                       <div class="palm-notification-button affirmative" x-mojo-tap-highlight="immediate" id='flightmode' x-mojo-loc=''>Turn on Airplane Mode</div>
254 +               </div>
255 +               <div id="deviceSleepButton" style="display:none;">
256 +                       <div class="palm-notification-button affirmative" x-mojo-tap-highlight="immediate" id='sleep' x-mojo-loc=''>Disable Device Sleep</div>
257 +               </div>
258 +               <div id="shutdownDeviceButton" style="display:none;">
259 +                       <div class="palm-notification-button negative" x-mojo-tap-highlight="immediate" id='poweroff' x-mojo-loc=''>Shut Down Device</div>
260 +               </div>
261 +               <div id="restartDeviceButton" style="display:none;">
262 +                       <div class="palm-notification-button alternate" x-mojo-tap-highlight="immediate" id='restart' x-mojo-loc=''>Restart Device</div>
263 +               </div>
264 +               <div id="restartLunaButton" style="display:none;">
265 +                       <div class="palm-notification-button alternate" x-mojo-tap-highlight="immediate" id='luna' x-mojo-loc=''>Restart Luna</div>
266 +               </div>
267 +               <div id="cancelButton" style="display:block;">
268 +                       <div class="palm-notification-button" x-mojo-tap-highlight="immediate" id='cancel' x-mojo-loc=''>Cancel</div>
269 +               </div>
270 +       </div>
271 +       <div id="editmenu" style="display: none;">
272 +               <div style="font-size: 20px;text-align:center;padding:6px;">Menu Content Settings</div>
273 +               <div style="padding:5px;padding-left:15px;padding-right:15px;"><div style="background:gray;min-height:1px;"></div></div>
274 +               
275 +               <div id="airplaneModeEdit">
276 +                       <div id="airplaneModeState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
277 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Airplane Mode Toggle</div>
278 +               </div>
279 +               <div id="deviceSleepEdit">
280 +                       <div id="deviceSleepState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
281 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Device Sleep Toggle</div>
282 +               </div>
283 +               <div id="shutdownDeviceEdit">
284 +                       <div id="shutdownDeviceState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
285 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Shut Down Device Action</div>
286 +               </div>
287 +               <div id="restartDeviceEdit">
288 +                       <div id="restartDeviceState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
289 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Restart Device Action</div>
290 +               </div>
291 +               <div id="restartLunaEdit">
292 +                       <div id="restartLunaState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
293 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Restart Luna Action</div>
294 +               </div>
295 +       </div>
296 +</div>
297 --- .orig/usr/lib/luna/system/luna-systemui/resources/es/views/poweroffalert/poweroffalert-scene.html
298 +++ /usr/lib/luna/system/luna-systemui/resources/es/views/poweroffalert/poweroffalert-scene.html
299 @@ -1,5 +1,47 @@
300  <div class="system-notification power-off">
301 -               <div class="palm-notification-button affirmative" x-mojo-tap-highlight="immediate" id='flightmode'></div>
302 -               <div class="palm-notification-button negative" x-mojo-tap-highlight="immediate" id='poweroff'>Apagar/Reiniciar</div>
303 -               <div class="palm-notification-button" x-mojo-tap-highlight="immediate" id='cancel'>Cancelar</div>
304 +       <div id="powermenu">
305 +               <div id="airplaneModeButton" style="display:none;">
306 +                       <div class="palm-notification-button affirmative" x-mojo-tap-highlight="immediate" id='flightmode' x-mojo-loc=''>Turn on Airplane Mode</div>
307 +               </div>
308 +               <div id="deviceSleepButton" style="display:none;">
309 +                       <div class="palm-notification-button affirmative" x-mojo-tap-highlight="immediate" id='sleep' x-mojo-loc=''>Disable Device Sleep</div>
310 +               </div>
311 +               <div id="shutdownDeviceButton" style="display:none;">
312 +                       <div class="palm-notification-button negative" x-mojo-tap-highlight="immediate" id='poweroff' x-mojo-loc=''>Shut Down Device</div>
313 +               </div>
314 +               <div id="restartDeviceButton" style="display:none;">
315 +                       <div class="palm-notification-button alternate" x-mojo-tap-highlight="immediate" id='restart' x-mojo-loc=''>Restart Device</div>
316 +               </div>
317 +               <div id="restartLunaButton" style="display:none;">
318 +                       <div class="palm-notification-button alternate" x-mojo-tap-highlight="immediate" id='luna' x-mojo-loc=''>Restart Luna</div>
319 +               </div>
320 +               <div id="cancelButton" style="display:block;">
321 +                       <div class="palm-notification-button" x-mojo-tap-highlight="immediate" id='cancel' x-mojo-loc=''>Cancel</div>
322 +               </div>
323 +       </div>
324 +       <div id="editmenu" style="display: none;">
325 +               <div style="font-size: 20px;text-align:center;padding:6px;">Menu Content Settings</div>
326 +               <div style="padding:5px;padding-left:15px;padding-right:15px;"><div style="background:gray;min-height:1px;"></div></div>
327 +               
328 +               <div id="airplaneModeEdit">
329 +                       <div id="airplaneModeState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
330 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Airplane Mode Toggle</div>
331 +               </div>
332 +               <div id="deviceSleepEdit">
333 +                       <div id="deviceSleepState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
334 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Device Sleep Toggle</div>
335 +               </div>
336 +               <div id="shutdownDeviceEdit">
337 +                       <div id="shutdownDeviceState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
338 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Shut Down Device Action</div>
339 +               </div>
340 +               <div id="restartDeviceEdit">
341 +                       <div id="restartDeviceState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
342 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Restart Device Action</div>
343 +               </div>
344 +               <div id="restartLunaEdit">
345 +                       <div id="restartLunaState" style="font-size:12px;float:right;color:gray;padding:8px;padding-top:11px;padding-right:25px;">HIDE</div>
346 +                       <div style="font-size:16px;padding:8px;padding-left:25px;">Restart Luna Action</div>
347 +               </div>
348 +       </div>
349  </div>
350 --- .orig/usr/lib/luna/system/luna-systemui/resources/es/strings.json
351 +++ /usr/lib/luna/system/luna-systemui/resources/es/strings.json
352 @@ -30,6 +30,10 @@
353         "1#The update will start automatically in 1 second, and when your battery is sufficiently charged.|#The update will start automatically in #{counter} seconds, and when your battery is sufficiently charged.": "1#La actualización se iniciará automáticamente en 1 segundo, y cuando la batería esté cargada lo suficiente.|#La actualización se iniciará automáticamente en #{counter}segundos, y cuando la batería esté cargada lo suficiente.",
354         "1#The update will start in 1 minute.|#The update will start in #{counter} minutes.": "1#La actualización se iniciará en 1 minuto.|#La actualización se iniciará en #{counter} minutos.",
355         "1#The update will start in 1 second.|#The update will start in #{counter} seconds.": "1#La actualización se iniciará en 1 segundo.|#La actualización se iniciará en #{counter} segundos.",
356 +  "Enable Device Sleep": "",
357 +  "Disable Device Sleep": "",
358 +  "SHOW": "",
359 +  "HIDE": "",
360         "Added \"#{word}\" to dictionary": "Se añadió \"#{word}\" al diccionario",
361         "Adding ringtone failed. File may already exist.": "No se pudo añadir un tono. Puede que ya exista el archivo.",
362         "Airplane Mode": "Modo avión",