16 Updated patches.
[webos-internals:shivaramv-modifications.git] / calendar / calendar-snooze-duration-selection.patch
1 diff --git a/usr/palm/applications/com.palm.app.calendar/app/controllers/app-assistant.js b/usr/palm/applications/com.palm.app.calendar/app/controllers/app-assistant.js
2 index 5375929..132cd1b 100644
3 --- a/usr/palm/applications/com.palm.app.calendar/app/controllers/app-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.calendar/app/controllers/app-assistant.js
5 @@ -5,6 +5,7 @@ var AppAssistant = Class.create({
6         
7         initialize: function(appController) {
8                 Mojo.Log.info("AppAssistant initialize");
9 +               
10                 this.appController = appController;
11                 this.openReminderAlert = null;
12                 
13 @@ -78,7 +79,9 @@ var AppAssistant = Class.create({
14                 // gives us a flag to let us now if this being called at boot.
15                 this.handlelaunchCount++;
16                 if (this.handlelaunchCount <= 1)
17 +               {
18                         return; 
19 +               }
20                         
21                 //if this failed during initialization, try again       
22                 if (!this.calendarsManager.accounts) {                  
23 @@ -110,8 +113,8 @@ var AppAssistant = Class.create({
24                 }
25                 else if (launchParams.alarmsnooze){
26                         Mojo.Log.info("$$$$$$$$ AppAssistant handleLaunch : alarmsnooze");
27 -                       this.doAlarm(true,launchParams.dontAlert,launchParams.alarmsnooze);
28                         
29 +                       this.doAlarm(true,launchParams.dontAlert,launchParams.alarmsnooze);
30                 } 
31                 else if (launchParams.alarmclose){
32                         Mojo.Log.info("$$$$$$$$ AppAssistant handleLaunch : alarmclose");
33 @@ -348,6 +351,7 @@ var AppAssistant = Class.create({
34         
35         // *** ALARMS ***
36         doAlarm: function(isSnoozedReminder,dontAlert,eventId, attendees, isAllDay, subject, location, emailAccountId) {        
37 +       
38                 Mojo.Log.info("$$$$$$$$ AppAssistant doAlarm :start,"+dontAlert);
39         
40                 //first check if is a snoozed reminder and if it exists in reminder manager
41 @@ -399,9 +403,9 @@ var AppAssistant = Class.create({
42                 var reminder = getReminderManager().getReminder(eventId);
43                 reminder.userClosed = false;
44                 if (reminder.attendees.length > 1 /*now we include the organizer in attendee list*/)
45 -                       height = 203;
46 +                       height = 280; //203 orig; 74 + a couple to get more choices
47                 else
48 -                       height = 149;
49 +                       height = 226; //149 orig;
50                 
51                 var needThrobbing =(hasNewContent || !isSnoozedReminder) ? true:false;
52                 Mojo.Log.info("$$$$$$$$ AppAssistant doAlarm:createStageWithCallback for stage: "+this.createAlarmStageName(eventId)+", stage height is: "+height);
53 @@ -863,8 +867,16 @@ function notifyTimeFormatObservers() {
54  }
55  
56  function getTimeFormat() {
57 +       //if getAppAssistant is not valid yet return the default setting of this.timeFormat.
58 +       if(getAppAssistant() != undefined)
59 +       {
60         return getAppAssistant().timeFormat;
61  }
62 +       else
63 +       {
64 +               return this.timeFormat;
65 +       }
66 +}
67  // **System  Time Change
68  function observeTimeChange(sceneName, controller){
69         getAppAssistant().timeChangeObservers.set(sceneName,controller);
70 diff --git a/usr/palm/applications/com.palm.app.calendar/app/controllers/dashboard-assistant.js b/usr/palm/applications/com.palm.app.calendar/app/controllers/dashboard-assistant.js
71 index a667ac9..b87f7b0 100644
72 --- a/usr/palm/applications/com.palm.app.calendar/app/controllers/dashboard-assistant.js
73 +++ b/usr/palm/applications/com.palm.app.calendar/app/controllers/dashboard-assistant.js
74 @@ -24,7 +24,10 @@ var DashboardAssistant = Class.create({
75         cleanup: function() {
76                 Mojo.Log.info("$$$$$$$$ Dashboard-assistant cleanup: start ");
77                 this.reminders.stopObservingReminders('dashboard');
78 -               this.reminders.removeAllReminders();
79 +//Do not remove the scheduled reminders
80 +//This is so that if the dashboard event is swiped away the reminder is not removed
81 +//to support reminders that are far in the future but may not want the icon in the dashboard.
82 +//             this.reminders.removeAllReminders();
83                 Mojo.Log.info("$$$$$$$$ Dashboard-assistant cleanup: end ");
84         },
85         
86 diff --git a/usr/palm/applications/com.palm.app.calendar/app/controllers/prefs-assistant.js b/usr/palm/applications/com.palm.app.calendar/app/controllers/prefs-assistant.js
87 index cebe803..b818111 100644
88 --- a/usr/palm/applications/com.palm.app.calendar/app/controllers/prefs-assistant.js
89 +++ b/usr/palm/applications/com.palm.app.calendar/app/controllers/prefs-assistant.js
90 @@ -76,6 +76,7 @@ var PrefsAssistant = Class.create({
91                 this.dirty=true;
92                 
93         },
94 +       
95         updateEasAccountLoginDisplayNames: function() {
96                 //Mojo.Log.info("updateEasAccountLoginDisplayNames %s", Object.toJSON(this.acctsModel));
97                 this.acctsModel.items.each(function(acct){
98 @@ -168,7 +169,7 @@ var PrefsAssistant = Class.create({
99                 this.controller.get('pv_default_cal').update(html);
100         },
101         
102 -       renderDefaultEventAlarm: function(timedAlarmStr, allDayAlarmStr) {
103 +       renderDefaultEventAlarm: function(timedAlarmStr, allDayAlarmStr, snoozeDurationStr) {
104                 //Mojo.Log.info('prefs-assistant: renderDefaultEventAlarm');
105                 var obj = {};
106                 
107 @@ -177,6 +178,9 @@ var PrefsAssistant = Class.create({
108                 
109                 // All Day Alarm
110                 this.controller.get('pv_default_allday_evt_alarm_value').update(allDayAlarmStr);
111 +               
112 +               // Snooze Duration
113 +               this.controller.get('pv_default_snooze_duration_value').update(snoozeDurationStr);
114         },
115         
116         getCurrentAlarmString: function() {
117 @@ -189,18 +193,29 @@ var PrefsAssistant = Class.create({
118         
119         getCurrentAllDayAlarmString: function() {
120                 var index = 0;
121 -               for (index = 0; index < this.alarms.size(); index++) {
122 +               for (index = 0; index < this.allDayAlarms.size(); index++) {
123                         if (this.allDayAlarms[index].command == this.prefs.defaultAllDayEventReminder)
124                                 return this.allDayAlarms[index].label;
125                 }
126         },
127         
128 +       getCurrentSnoozeDurationString: function() {
129 +               var index = 0;
130 +               for (index = 0; index < this.snoozeDurations.size(); index++) {
131 +                       if (this.snoozeDurations[index].command == this.prefs.defaultSnoozeDuration)
132 +                               return this.snoozeDurations[index].label;
133 +               }
134 +       },
135 +       
136 +//This should be one function that takes an array for the values needed and the array that is to be updated and the defaultPref
137 +//returns the default str value        
138         formatAlarmStringsCallback: function(response) {
139                 //Mojo.Log.info('prefs-assistant: formatAlarmStringsCallback');
140 +               
141                 var index = 0;
142                 var currentTimedAlarmStr = "";
143                 var currentAllDayAlarmStr = "";
144 -               
145 +               var currentSnoozeDurationStr = "";
146                 
147                 for (index = 0; index < this.alarms.size() + this.allDayAlarms.size() - 1; index++) {
148                         alarmStr = response[index];
149 @@ -229,7 +244,9 @@ var PrefsAssistant = Class.create({
150                         }
151                 };
152                 
153 -               this.renderDefaultEventAlarm(currentTimedAlarmStr, currentAllDayAlarmStr);
154 +               currentSnoozeDurationStr = this.getCurrentSnoozeDurationString();
155 +               
156 +               this.renderDefaultEventAlarm(currentTimedAlarmStr, currentAllDayAlarmStr, currentSnoozeDurationStr);
157         },
158         
159         buildAlarmsMenu: function() {
160 @@ -377,6 +394,23 @@ var PrefsAssistant = Class.create({
161         setup: function() {
162                 // Retrieve the prefs from the service
163                 this.prefs = getPrefs();
164 +
165 +               //get default snooze duration from cookie
166 +               this.cookie = new Mojo.Model.Cookie("com.palm.app.calendar.defaultsnoozeduration");
167 +
168 +               if (this.cookie) 
169 +               {
170 +                       var cookie = this.cookie.get();
171 +
172 +                       if (cookie) 
173 +                       {                       
174 +                               if(cookie.defaultSnoozeDuration)
175 +                               {
176 +                                       this.prefs.defaultSnoozeDuration = cookie.defaultSnoozeDuration;
177 +                               }
178 +                       }
179 +               }
180 +
181                 this.requests = [];
182                 this.syncSources = [];
183                 this.dirty = false;
184 @@ -420,7 +454,6 @@ var PrefsAssistant = Class.create({
185                 ]
186         };
187         
188 -               
189                 this.notificationSoundModel = {
190                 value:this.convertSoundDBToPopupVal(this.prefs.alarmSoundOn)
191         };
192 @@ -433,7 +466,6 @@ var PrefsAssistant = Class.create({
193                 else 
194                         this.controller.get('currentringtone').update(this.prefs.ringtoneName);
195                 
196 -       
197                 this.renderNewEventDuration();
198         
199                 this.buildAlarmsMenu();
200 @@ -443,7 +475,6 @@ var PrefsAssistant = Class.create({
201                 this.getCalendarAccountsRequest = getAccountsService().getAllAccountsForCalendarService(
202                 this.getCalendarAccountsCallback.bind(this), this.controller);
203                 
204 -               
205                 this.appMenuModel= {
206                         visible:true, 
207                         label:$L('Calendar'), 
208 @@ -452,8 +483,6 @@ var PrefsAssistant = Class.create({
209                                         {label:$L('Help'), command:Mojo.Menu.helpCmd, disabled:false}]
210                 }
211                 this.controller.setupWidget(Mojo.Menu.appMenu, {omitDefaultItems:true}, this.appMenuModel);
212 -
213 -                               
214         },
215  
216         setCalendarPrefsCallback: function(response) {
217 @@ -473,6 +502,12 @@ var PrefsAssistant = Class.create({
218                 
219                 if (this.dirty)
220                         this.savePrefs();
221 +                       
222 +               //save default snooze duration to cookie        
223 +               if (this.cookie)
224 +               {
225 +                       this.cookie.put({defaultSnoozeDuration: this.prefs.defaultSnoozeDuration});
226 +               }
227         },
228         
229         syncAllCallback: function(response) {
230 @@ -504,6 +539,9 @@ var PrefsAssistant = Class.create({
231                 this.controller.get('pv_default_evt_alarm').observe('mojo-tap', this.defaultEventAlarmClickHandler);
232                 this.defaultAllDayEventAlarmClickHandler = this.handleDefaultAllDayEventAlarmClick.bindAsEventListener(this);
233                 this.controller.get('pv_default_allday_evt_alarm').observe('mojo-tap', this.defaultAllDayEventAlarmClickHandler);
234 +               this.defaultSnoozeDurationClickHandler = this.handleDefaultSnoozeDurationClick.bindAsEventListener(this);
235 +               this.controller.get('pv_default_snooze_duration').observe('mojo-tap', this.defaultSnoozeDurationClickHandler);
236 +               
237                                 
238                 this.newEventDurationClickHandler = this.handleNewEventDurationClick.bindAsEventListener(this);
239                 this.controller.get('pv_new_event_duration').observe('mojo-tap', this.newEventDurationClickHandler);    
240 @@ -546,6 +584,9 @@ var PrefsAssistant = Class.create({
241                 this.controller.get('pv_default_allday_evt_alarm').stopObserving('mojo-tap', this.defaultAllDayEventAlarmClickHandler);
242                 this.defaultAllDayEventAlarmClickHandler = undefined;
243                 
244 +               this.controller.get('pv_default_snooze_duration').stopObserving('mojo-tap', this.defaultSnoozeDurationClickHandler);    
245 +               this.defaultSnoozeDurationClickHandler = undefined;
246 +                       
247                 this.controller.get('pv_new_event_duration').stopObserving('mojo-tap', this.newEventDurationClickHandler);
248                 
249                 this.controller.get('pv_accounts_list').stopObserving(Mojo.Event.listTap, this.acctsListSelectionHandler);
250 @@ -708,7 +749,7 @@ var PrefsAssistant = Class.create({
251                 //Mojo.Log.info('prefs-assistant: defaultEventAlarmChoose');
252                 if (value != undefined && value != this.prefs.defaultEventReminder) {
253                         this.prefs.defaultEventReminder = value;
254 -                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString());
255 +                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString(), this.getCurrentSnoozeDurationString());
256                         this.dirty = true;
257                 }
258         },
259 @@ -728,7 +769,7 @@ var PrefsAssistant = Class.create({
260                 //Mojo.Log.info('prefs-assistant: defaultAllDayEventAlarmChoose');
261                 if (value != undefined && value != this.prefs.defaultAllDayEventReminder) {
262                         this.prefs.defaultAllDayEventReminder = value;
263 -                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString());
264 +                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString(), this.getCurrentSnoozeDurationString());
265                         this.dirty = true;
266                 }
267         },
268 @@ -744,6 +785,27 @@ var PrefsAssistant = Class.create({
269                         });
270         },
271         
272 +       defaultSnoozeDurationChoose: function(value) {
273 +               //Mojo.Log.info('prefs-assistant: defaultSnoozeDurationChoose');
274 +               
275 +               if (value != undefined && value != this.prefs.defaultSnoozeDuration) {
276 +                       this.prefs.defaultSnoozeDuration = value;
277 +                       this.renderDefaultEventAlarm(this.getCurrentAlarmString(), this.getCurrentAllDayAlarmString(), this.getCurrentSnoozeDurationString());
278 +                       this.dirty = true;
279 +               }
280 +       },
281 +       
282 +       handleDefaultSnoozeDurationClick: function(event) {
283 +               //Mojo.Log.info('prefs-assistant: handleDefaultSnoozeDurationClick');
284 +
285 +               Event.stop(event);
286 +               this.controller.popupSubmenu({
287 +                               onChoose: this.defaultSnoozeDurationChoose.bind(this),
288 +                               toggleCmd: this.prefs.defaultSnoozeDuration,
289 +                               items: this.snoozeDurations
290 +                       });
291 +       },
292 +       
293         // *** WIDGET ATTRS & MODELS
294  
295         
296 @@ -757,6 +819,32 @@ var PrefsAssistant = Class.create({
297                 items: [],
298         },
299         
300 +       snoozeDurations: [
301 +               {label:$L('30 Minutes before start'), command:'-30'},
302 +               {label:$L('15 Minutes before start'), command:'-15'},
303 +               {label:$L('10 Minutes before start'), command:'-10'},
304 +               {label:$L('5 Minutes before start'), command:'-5'},
305 +               {label:$L('At start time'), command:'0'},
306 +               {label:$L('5 Minutes'), command:'5'},
307 +               {label:$L('10 Minutes'), command:'10'},
308 +               {label:$L('15 Minutes'), command:'15'},
309 +               {label:$L('30 Minutes'), command:'30'},
310 +               {label:$L('1 Hour'), command:'60'},
311 +               {label:$L('2 Hours'), command:'120'},
312 +               {label:$L('4 Hours'), command:'240'},
313 +               {label:$L('8 Hours'), command:'480'},
314 +               {label:$L('10 Hours'), command:'600'},
315 +               {label:$L('12 Hours'), command:'720'},
316 +               {label:$L('1 Day'), command:'1440'},
317 +               {label:$L('2 Days'), command:'2880'},
318 +               {label:$L('3 Days'), command:'4320'},
319 +               {label:$L('4 Days'), command:'5760'},
320 +               {label:$L('5 Days'), command:'7200'},
321 +               {label:$L('6 Days'), command:'8640'},
322 +               {label:$L('1 Week'), command:'10080'},
323 +               {label:$L('2 Weeks'), command:'20160'}          
324 +       ],
325 +       
326         alarms: [
327                 {label: '', command: 'none'},                   // Do NOT Localize
328                 {label: '', command: '-PT5M'},          //Do Not localize
329 diff --git a/usr/palm/applications/com.palm.app.calendar/app/controllers/reminder-assistant.js b/usr/palm/applications/com.palm.app.calendar/app/controllers/reminder-assistant.js
330 index d190fd1..e237477 100644
331 --- a/usr/palm/applications/com.palm.app.calendar/app/controllers/reminder-assistant.js
332 +++ b/usr/palm/applications/com.palm.app.calendar/app/controllers/reminder-assistant.js
333 @@ -2,9 +2,35 @@
334  
335  
336  var ReminderAssistant = Class.create({
337 +
338 +       snoozeDurationOptions: [
339 +               {label:$L('30 Minutes before start'), value:'-30'},
340 +               {label:$L('15 Minutes before start'), value:'-15'},
341 +               {label:$L('10 Minutes before start'), value:'-10'},
342 +               {label:$L('5 Minutes before start'), value:'-5'},
343 +               {label:$L('At start time'), value:'0'},
344 +               {label:$L('5 Minutes'), value:'5'},
345 +               {label:$L('10 Minutes'), value:'10'},
346 +               {label:$L('15 Minutes'), value:'15'},
347 +               {label:$L('30 Minutes'), value:'30'},
348 +               {label:$L('1 Hour'), value:'60'},
349 +               {label:$L('2 Hours'), value:'120'},
350 +               {label:$L('4 Hours'), value:'240'},
351 +               {label:$L('8 Hours'), value:'480'},
352 +               {label:$L('10 Hours'), value:'600'},
353 +               {label:$L('12 Hours'), value:'720'},
354 +               {label:$L('1 Day'), value:'1440'},
355 +               {label:$L('2 Days'), value:'2880'},
356 +               {label:$L('3 Days'), value:'4320'},
357 +               {label:$L('4 Days'), value:'5760'},
358 +               {label:$L('5 Days'), value:'7200'},
359 +               {label:$L('6 Days'), value:'8640'},
360 +               {label:$L('1 Week'), value:'10080'},
361 +               {label:$L('2 Weeks'), value:'20160'}
362 +       ],
363 +
364         initialize: function(eventId,needThrobbing) {
365                 Mojo.Log.info("$$$$$$$$ Reminder-assistant initialize: start: "+eventId);
366 -               this.DEFAULT_SNOOZE = 5;
367                 this.reminders = getReminderManager();
368                 getAppAssistant().openReminderAlert = this;
369                 this.requests = [];
370 @@ -14,6 +40,55 @@ var ReminderAssistant = Class.create({
371                 this.doThrob =needThrobbing;
372                 this.autoSnoozed = false;
373                 
374 +               //get default snooze duration from cookie
375 +               this.cookie = new Mojo.Model.Cookie("com.palm.app.calendar.defaultsnoozeduration");
376 +
377 +               if (this.cookie) 
378 +               {
379 +                       var cookie = this.cookie.get();
380 +
381 +                       if (cookie) 
382 +                       {                       
383 +                               if(cookie.defaultSnoozeDuration)
384 +                               {
385 +                                       this.DEFAULT_SNOOZE = parseInt(cookie.defaultSnoozeDuration);
386 +                               }
387 +                               else
388 +                               {
389 +                                       this.DEFAULT_SNOOZE = -15;
390 +                               }
391 +                       }
392 +               }
393 +
394 +               //logic to not pic a default snooze that has already past
395 +
396 +               //set the snoozeOptions to the master set otherwise as we remove items we also remove them
397 +               //for any additonal reminders.
398 +               this.snoozeOptions = this.snoozeDurationOptions.slice(0);
399 +
400 +               this.reminder = this.reminders.getReminder(this.eventId);
401 +               
402 +               var curDate = new Date();
403 +               var defSnooze = this.snoozeOptions[0].value;
404 +               
405 +               var testDate = new Date(this.reminder.time).addMinutes(defSnooze);
406 +               
407 +               while(testDate <= curDate && defSnooze <= 0)
408 +               {
409 +                       //remove the invalid option
410 +                       var tmp = this.snoozeOptions.shift();
411 +       
412 +                       defSnooze = parseInt(this.snoozeOptions[0].value);
413 +
414 +                       testDate = new Date(this.reminder.time).addMinutes(defSnooze);
415 +               }
416 +
417 +               //if the DEFAULT_SNOOZE < defSnooze then it is no longer a valid snooze option so use the next valide value
418 +               if( this.DEFAULT_SNOOZE < defSnooze )
419 +               {
420 +                       this.DEFAULT_SNOOZE = defSnooze;
421 +               }
422 +
423                 Mojo.Log.info("$$$$$$$$ Reminder-assistant initialize:end");
424         },
425  
426 @@ -27,6 +102,19 @@ var ReminderAssistant = Class.create({
427         },
428         
429         setup: function() {
430 +               
431 +               //setup the snooze duration selector list
432 +               this.selectorChoices = this.snoozeOptions;
433 +               this.selectorAttributes = { label: "Snooze Duration", labelPlacement: "left", choices: this.selectorChoices, modelProperty:'value' };
434 +
435 +               //Need to figure out how to remember previous selected snooze value.
436 +               //set the default duration to match the default snooze value
437 +               this.selectorModel = {value:'' + this.DEFAULT_SNOOZE};
438 +               this.selectorModel.value = '' + this.DEFAULT_SNOOZE;
439 +               this.controller.setupWidget('snoozeSelector', this.selectorAttributes, this.selectorModel);
440 +
441 +               this.onSnoozeDurationChangedHandler = this.onSnoozeDurationChanged.bindAsEventListener(this);
442 +
443                 Mojo.Log.info("$$$$$$$$ Reminder-assistant setup:start");
444                 this.service = getCalendarService();
445  
446 @@ -43,6 +131,10 @@ var ReminderAssistant = Class.create({
447      
448         cleanup: function() {
449                 Mojo.Log.info("$$$$$$$$ Reminder-assistant cleanup:start:");
450 +
451 +               //store the reminders in a cookie so they survive reboot                
452 +               this.reminders.saveReminders();
453 +
454                 this.reminders.stopObservingReminders('alert');
455                 
456                 getAppAssistant().openReminderAlert = null;
457 @@ -52,11 +144,11 @@ var ReminderAssistant = Class.create({
458                                 Mojo.Log.info("$$$$$$$$ Reminder-assistant cleanup: snoozing reminder " + this.reminder.id);
459                                 this.snooze(this.DEFAULT_SNOOZE);
460                         }
461 +                       
462                         if (this.dismissed || this.snoozed) {                           
463                                 Mojo.Log.info("$$$$$$$$ Reminder-assistant cleanup : removing autoclosetask");
464                                 //only remove the auto close task if it is acted upon
465                                 this.removeAutoCloseTask();
466 -                               
467                         }
468                 }
469                 Mojo.Log.info("$$$$$$$$ Reminder-assistant cleanup:end:");
470 @@ -150,6 +242,9 @@ var ReminderAssistant = Class.create({
471                 
472                 this.controller.get('reminder-dismiss').addEventListener(Mojo.Event.tap, this.onDismissHandler);
473                 this.controller.get('reminder-snooze').addEventListener(Mojo.Event.tap, this.onSnoozeHandler);
474 +
475 +               //add snoozeDuration event listners
476 +               this.controller.get('snoozeSelector').addEventListener(Mojo.Event.propertyChange, this.onSnoozeDurationChangedHandler);
477         },
478  
479         removeListeners: function() {
480 @@ -167,6 +262,10 @@ var ReminderAssistant = Class.create({
481                 if (email) email.removeEventListener(Mojo.Event.tap, this.onEmailHandler);
482                 var snooze = this.controller.get('reminder-snooze');
483                 if (snooze) snooze.removeEventListener(Mojo.Event.tap, this.onSnoozeHandler);
484 +
485 +               //remove snoozeDuration event listners
486 +               var snoozeDuration = this.controller.get('snoozeSelector');
487 +               if (snoozeDuration) snoozeDuration.removeEventListener(Mojo.Event.propertyChange, this.onSnoozeDurationChangedHandler);
488         },
489         
490         
491 @@ -307,6 +406,23 @@ var ReminderAssistant = Class.create({
492                 Mojo.Log.info("$$$$$$$$ Reminder-assistant onSnooze: end: " + this.reminder.id);
493         },
494         
495 +       /* handle the change event for the snooze duration.
496 +        * set the default snooze value to the selection value
497 +        * need to figure out how to save this value for reuse when the snooze duration
498 +        * expires so that we can set the selection to the same value prevously selected
499 +        */
500 +       onSnoozeDurationChanged: function(value) {
501 +               Mojo.Log.info("$$$$$$$$ Reminder-assistant onSnoozeDurationChanged: start: " + this.reminder.id);
502 +               this.DEFAULT_SNOOZE = this.selectorModel.value;
503 +               this.snoozed =true;
504 +               this.closeAlert();
505 +               this.autoSnoozed = false;
506 +               this.reminder.userClosed = true;
507 +               this.reminder.scheduleStartTime = true;
508 +               this.reissueAutoSnoozedAlerts();
509 +               Mojo.Log.info("$$$$$$$$ Reminder-assistant onSnoozeDurationChanged: end: " + this.reminder.id);
510 +       },
511 +
512         removeReminder: function() {
513                 Mojo.Log.info("$$$$$$$$ Reminder-assistant removeReminder: start: " + this.reminder.id);
514                 this.reminders.removeReminder(this.reminder.id);
515 @@ -342,9 +458,19 @@ var ReminderAssistant = Class.create({
516                         return;
517                 }       
518                 
519 -               var snooze = new Date().addMinutes(minutes);
520 -               Mojo.Log.info("$$$$$$$$ Reminder-assistant snooze: updateTask: calendar-snooze-" + this.reminder.id + "   date = " + snooze.toUTCString());
521 +               var snooze;
522                 
523 +               if( minutes > 0 )
524 +               {
525 +                       snooze = new Date().addMinutes(minutes);
526 +               }
527 +               else
528 +               {
529 +                       snooze = new Date(this.reminder.time).addMinutes(minutes);
530 +               }
531 +               
532 +               Mojo.Log.info("$$$$$$$$ Reminder-assistant snooze: updateTask: calendar-snooze-" + this.reminder.id + "   date = " + snooze.toUTCString());
533 +/*             
534                 this.controller.serviceRequest('palm://com.palm.taskScheduler', {
535                                                             method: 'updateTask',
536                                                             parameters: {uri: 'palm://com.palm.applicationManager/open',
537 @@ -355,7 +481,34 @@ var ReminderAssistant = Class.create({
538                                                                                                          prereq: ['MSM_OFF'],
539                                                                                                          misfirePolicy: {executeNow: true}}
540                                                                 });
541 +*/
542 +
543 +               //use a powered/timeout alarm so that the reminder survives a reboot
544 +               var alarmLaunchParams = '{"id":"com.palm.app.calendar","params":{"alarmsnooze":"' + this.reminder.id + '"}}';
545  
546 +               var newParams = alarmLaunchParams.evalJSON();
547 +               newParams.params.id = this.reminder.id;
548 +
549 +               var newParamsJSON = Object.toJSON(newParams);
550 +
551 +               var at = this.dateFormatForScheduler(snooze);
552 +
553 +        this.controller.serviceRequest("luna://com.palm.power/timeout/", {
554 +                       method: "set",
555 +                       parameters: {
556 +                               "wakeup": true,
557 +                               "key": 'calendar-snooze-' + this.reminder.id,
558 +                               "uri": "luna://com.palm.applicationManager/launch",
559 +                               "params": newParamsJSON,
560 +                               "at": at
561 +                       },
562 +                       onSuccess: function(payload) {
563 +                               Mojo.Log.info("****************** Reminder-assistant snooze succeeded. ");
564 +                       }.bind(this),
565 +                       onFailure: function() {
566 +                               Mojo.Log.error("****************** Reminder-assistant snooze failed: " );
567 +                       }.bind(this)
568 +               });
569  
570                 var templateModel = {};
571                 var templateStr = $L("Snoozed for #{num} minutes");
572 @@ -402,7 +555,18 @@ var ReminderAssistant = Class.create({
573                                                                 });
574         },
575         
576 +       //taken from com.palm.app.clock/app/models/alarm.js
577 +       // returns date in format suitable for scheduler service
578 +       dateFormatForScheduler: function(d) {
579 +               function twoChars(x) { return ((x>9)?"":"0")+x; }
580 +               
581 +               return twoChars(d.getUTCMonth()+1) + "/" + twoChars(d.getUTCDate()) + "/" + twoChars(d.getUTCFullYear()) 
582 +                                       + " " + twoChars(d.getUTCHours()) + ":" + twoChars(d.getUTCMinutes()) + ":00" 
583 +       },
584 +       
585         scheduleAutoCloseTask: function() {
586 +//disable autoclose, we want to know what we missed.
587 +return;        
588                 Mojo.Log.info("$$$$$$$$ Reminder-assistant scheduleAutoCloseTask: start " + this.reminder.id);
589                 var minCloseTime = new Date(this.reminder.time).addMinutes(15);
590                 var closeTime = new Date(this.reminder.time + this.reminder.duration);
591 diff --git a/usr/palm/applications/com.palm.app.calendar/app/models/calendar-luna-service.js b/usr/palm/applications/com.palm.app.calendar/app/models/calendar-luna-service.js
592 index 13176a6..af80564 100644
593 --- a/usr/palm/applications/com.palm.app.calendar/app/models/calendar-luna-service.js
594 +++ b/usr/palm/applications/com.palm.app.calendar/app/models/calendar-luna-service.js
595 @@ -77,8 +77,7 @@ var CalendarMojoService = Class.create( {
596                                         defaultAllDayEventReminder: prefs.defaultAllDayEventReminder,
597                                         userChangedstartOfWeek:prefs.userChangedstartOfWeek,
598                                         ringtonePath:prefs.ringtonePath,
599 -                                       ringtoneName:prefs.ringtoneName,
600 -
601 +                                       ringtoneName:prefs.ringtoneName
602                                 },
603                                 onSuccess: callback
604                         });
605 diff --git a/usr/palm/applications/com.palm.app.calendar/app/models/reminder-manager.js b/usr/palm/applications/com.palm.app.calendar/app/models/reminder-manager.js
606 index c2619fe..a0eaebf 100644
607 --- a/usr/palm/applications/com.palm.app.calendar/app/models/reminder-manager.js
608 +++ b/usr/palm/applications/com.palm.app.calendar/app/models/reminder-manager.js
609 @@ -8,6 +8,27 @@ var ReminderManager = Class.create ({
610                 this.observers = new Hash();
611                 this.reminders = [];
612                 
613 +               //////////////////////////
614 +               //Reload reminders
615 +               this.cookie = new Mojo.Model.Cookie("com.palm.app.calendar.reminders");
616 +
617 +               if (this.cookie) 
618 +               {
619 +                       var cookie = this.cookie.get();
620 +                       
621 +                       if (cookie) 
622 +                       {                       
623 +                               if(cookie.reminders)
624 +                               {
625 +                                       this.reminders = cookie.reminders;
626 +                               }
627 +                       }
628 +               }
629 +
630 +               //update the event remider data
631 +               this.getAllReminderEventData();
632 +               //////////////
633 +
634                 this.eventChangeRequest = new Mojo.Service.Request('palm://com.palm.calendar', {
635                                                             method: 'getEventChange',
636                                                             parameters: {subscribe: true},
637 @@ -23,9 +44,7 @@ var ReminderManager = Class.create ({
638                 Mojo.Log.info("$$$$$$$$ Reminder-manager cleanup: end ");
639         },
640         
641 -       getEventChangeCallback: function(response) {
642 -               Mojo.Log.info("$$$$$$$$ Reminder-manager getEventChangeCallback:start ");
643 -               if (response.changed) {
644 +       getAllReminderEventData: function() {
645                         // Get the event for each reminder since it may have changed
646                     window.setTimeout(function() {
647                                 this.requests = [];
648 @@ -39,6 +58,12 @@ var ReminderManager = Class.create ({
649                                         }));
650                                 }
651                     }.bind(this), 0.01);
652 +       }, 
653 +       
654 +       getEventChangeCallback: function(response) {
655 +               Mojo.Log.info("$$$$$$$$ Reminder-manager getEventChangeCallback:start ");
656 +               if (response.changed) {
657 +                       this.getAllReminderEventData();
658                 }
659                 Mojo.Log.info("$$$$$$$$ Reminder-manager getEventChangeCallback:end ");
660         },
661 @@ -254,6 +279,15 @@ var ReminderManager = Class.create ({
662                                 sceneController.remindersUpdated();
663                 });
664                 Mojo.Log.info("$$$$$$$$ Reminder-manager notifyObservers: end");
665 +       },
666 +       
667 +       saveReminders: function() {
668 +               //store the current reminders
669 +               //so that we can persist them across reboot
670 +               if (this.cookie)
671 +               {
672 +                       this.cookie.put({reminders: this.reminders});
673 +               }
674         }
675         
676  });
677 diff --git a/usr/palm/applications/com.palm.app.calendar/app/views/prefs/prefs-scene.html b/usr/palm/applications/com.palm.app.calendar/app/views/prefs/prefs-scene.html
678 index 3f1e673..6e73470 100644
679 --- a/usr/palm/applications/com.palm.app.calendar/app/views/prefs/prefs-scene.html
680 +++ b/usr/palm/applications/com.palm.app.calendar/app/views/prefs/prefs-scene.html
681 @@ -52,12 +52,19 @@
682                                 </div>
683                         </div>
684         
685 -                       <div id="pv_default_allday_evt_alarm" class="palm-row last">
686 +                       <div id="pv_default_allday_evt_alarm" class="palm-row">
687                                 <div class="palm-row-wrapper">
688                                         <div class="label" x-mojo-loc="">All day</div>
689                                         <div id="pv_default_allday_evt_alarm_value" class="title"></div>
690                                 </div>
691                         </div>
692 +                       
693 +                       <div id="pv_default_snooze_duration" class="palm-row first">
694 +                               <div class="palm-row-wrapper">
695 +                                               <div class="label" x-mojo-loc="">Snooze</div>
696 +                                               <div id="pv_default_snooze_duration_value" class="title"></div>
697 +                               </div>
698 +                       </div>
699                 </div>
700  </div>
701  <div id='pv_alarmsound_div' class='palm-group'>
702 diff --git a/usr/palm/applications/com.palm.app.calendar/app/views/reminder/reminder-scene.html b/usr/palm/applications/com.palm.app.calendar/app/views/reminder/reminder-scene.html
703 index c3ca688..1d89d4b 100644
704 --- a/usr/palm/applications/com.palm.app.calendar/app/views/reminder/reminder-scene.html
705 +++ b/usr/palm/applications/com.palm.app.calendar/app/views/reminder/reminder-scene.html
706 @@ -1,3 +1,9 @@
707 +<style type="text/css">
708 +       .palm-popup-content {
709 +               color: black;
710 +       }
711 +</style>
712 +
713  <div class="palm-scene notification-panel reminder">
714         <div class="dashboard-notification-module single" x-mojo-touch-feedback="immediate"  x-palm-popup-content="">
715                 <div class="palm-dashboard-icon-container">
716 @@ -9,6 +15,13 @@
717                         <div id="reminder-event"  class="palm-dashboard-text-wrapper"></div>
718                 </div>
719         </div>
720 +       <div class="palm-dashboard-text-container" style="width:auto;max-width:none">
721 +               <div class="palm-row" x-mojo-tap-highlight="momentary">
722 +                       <div class="palm-row-wrapper">
723 +                               <div id="snoozeSelector" class="dashboard-event-snooze-duration" x-mojo-element="ListSelector"></div>
724 +                       </div>
725 +               </div>
726 +       </div>
727         <div id="reminder-email" style="display:none"><div x-mojo-loc="" class="button-wrapper">Contact meeting attendees</div></div>
728         <div id="reminder-dismiss"><div x-mojo-loc="" class="button-wrapper">Dismiss</div></div>
729         <div id="reminder-snooze"><div x-mojo-loc="" class="button-wrapper">Snooze</div></div>
730 diff --git a/usr/palm/applications/com.palm.app.calendar/stylesheets/notification.css b/usr/palm/applications/com.palm.app.calendar/stylesheets/notification.css
731 index 4a84218..1ad150a 100644
732 --- a/usr/palm/applications/com.palm.app.calendar/stylesheets/notification.css
733 +++ b/usr/palm/applications/com.palm.app.calendar/stylesheets/notification.css
734 @@ -2,6 +2,10 @@
735   * Copyright 2008 Palm Inc. Confidential until public release.
736   */
737  
738 +/*@import url(global.css);*/
739 +/*Note the version needs to be updated to match the latest mojo framework on your device.*/
740 +@import url(/usr/palm/frameworks/mojo/submissions/338/stylesheets/global.css);
741 +
742  .notification-panel    {
743      background: #000;
744      color: #fff;