Patch Calendar Snooze Duration Selection

From WebOS Internals
Revision as of 03:53, 16 October 2009 by Lclarkjr (talk | contribs) (Fix snooze option to not show 15min as the comments suggests.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Introduction

The following assumes that you have experience applying modifications.

This modification will add a list selection for the snooze duration of an event reminder.

Note: If the phone is rebooted after snoozing the reminder will not be triggered.


Editing Process

Edit

/usr/palm/applications/com.palm.app.calendar/app/controllers/app-assistant.js

Find

doAlarm: function

Within this function scroll down to the following code

var height;

Below the line above height is assigned to two different values depending on wheher or not the reminder has attendees. Change the values as shown below.

if (reminder.attendees.length > 1 /*now we include the organizer in attendee list*/)
	height = 237;//183_orig;
else
	height = 183;//129_orig;


Edit

/usr/palm/applications/com.palm.app.calendar/app/controllers/reminder-assistant.js

Find

Class.create function

Within this function find the following line

this.DEFAULT_SNOOZE = 5;

Update it to be whatever default snooze reminder you desire, I am using 30 mins.

this.DEFAULT_SNOOZE = 30;

Find

activate:function

Just below this function add the following

//Until i figure out (or someone) how to get the scrolling of the list selection to work reduce this
//list to your favorite three
//Make sure you update the default snooze value to respectively
//The options set in these instructions will give you a 30 min default value and the options for 1hr,
//2hrs and 1day. 
//Note that the 30min option is added to the top so we can use it as a default but is left in the
//correct location commented out for when the scrolling is working.
snoozeOptions: [
	    {label:$L('30 Minutes'), value:'30'},
	    //{label:$L('5 Minutes'), value:'5'},
            //{label:$L('10 Minutes'), value:'10'},
            //{label:$L('15 Minutes'), value:'15'},
            //{label:$L('30 Minutes'), value:'30'},
            {label:$L('1 Hour'), value:'60'},
            {label:$L('2 Hours'), value:'120'},
            //{label:$L('4 Hours'), value:'240'},
            //{label:$L('8 Hours'), value:'480'},
            //{label:$L('10 Hours'), value:'600'},
            //{label:$L('12 Hours'), value:'720'},
            {label:$L('1 Day'), value:'1440'},
            //{label:$L('2 Days'), value:'2880'},
            //{label:$L('3 Days'), value:'4320'},
            //{label:$L('4 Days'), value:'5760'},
            //{label:$L('5 Days'), value:'7200'},
            //{label:$L('6 Days'), value:'8640'},
            //{label:$L('1 Week'), value:'10080'},
            //{label:$L('2 Weeks'), value:'20160'}
            ],

Find the

setup: function

at the top of this function add the following

this.controller.setupWidget('myscroller',
{
    mode:'vertical'
});

//setup the snooze duration selector list
this.selectorChoices = this.snoozeOptions;
this.selectorAttributes = { label: "Snooze Duration", labelPlacement: "left", choices: this.selectorChoices, modelProperty:'value' };

//Need to figure out how to remember previous selected snooze value.
//set the default duration to match the default snooze value
this.selectorModel = {value:'30'};
this.selectorModel.value = '30'; 
this.controller.setupWidget('snoozeSelector', this.selectorAttributes, this.selectorModel);

this.onSnoozeDurationChangedHandler = this.onSnoozeDurationChanged.bindAsEventListener(this);

Find

addListeners: function

Add the following lines to the end of this function

//add snoozeDuration event listners
this.controller.get('snoozeSelector').addEventListener(Mojo.Event.propertyChange, this.onSnoozeDurationChangedHandler);

Find

removeListeners: function

Add the following lines to the end of this function

//remove snoozeDuration event listners
var snoozeDuration = this.controller.get('snoozeSelector');
if (snoozeDuration) snoozeDuration.removeEventListener(Mojo.Event.propertyChange, this.onSnoozeDurationChangedHandler);

Find

onSnooze: function

After the above function add the following function

//handle the change event for the snooze duration.
//set the default snooze value to the selection value
//need to figure out how to save this value for reuse when the snooze duration expires so that we can set the selection to the same value prevously selected
onSnoozeDurationChanged: function(value) {
	this.DEFAULT_SNOOZE = this.selectorModel.value;
	this.closeAlert();               
},


Edit

/usr/palm/applications/com.palm.app.calendar/app/views/reminder/reminder-scene.html


Find

<div id="reminder-email" class="reminder-button-contact" style="display:none" x-mojo-loc="">Contact meeting attendees</div>

Add the following just above it

<div class="palm-dashboard-text-container">
	<div class="palm-row" x-mojo-tap-highlight="momentary">
		<div class="palm-row-wrapper">
			<div id="myscroller" class="snoozeScroller" x-mojo-element="Scroller">
				<div id="snoozeSelector" class="dashboard-event-snooze-duration" x-mojo-element="ListSelector"></div>
			</div>
		</div>
	</div>
</div>


Edit

/usr/palm/applications/com.palm.app.calendar/stylesheets/notification.css


At the top of the file just above

/* event popup notifications */

Add the following import

/*@import url(global.css);*/
/*Note the version needs to be updated to match the latest mojo framework on your device.*/
@import url(/usr/palm/frameworks/mojo/submissions/200.18/stylesheets/global.css);

This is necessary since the mojo framework does not load all the default css for stages. The documentation states that this will change in the future but for now the developer must copy the necesary css to thier local project.

Also note that this import statement references a specific version of the framework. You will need to check to see what your version is and update the "/200.18/" to match it. Note that you may have multipe versions listed in /usr/palm/frameworks/mojo/submissions choose the most recent version (highest number combination).

At the bottom of the file add the following

//added to support snooze duration
.dashboard-event-snooze-duration {
	width: 320px;
	margin-left: -15px;
}

.dashboard-event-snooze-duration .label{
	font-size: 12px;
}

.dashboard-event-snooze-duration .title{
	font-size: 16px;
}

.dashboard-event-snooze-duration .palm-popup-content .title {
	font-size: 8px;
}

.snoozeScroller {
   	margin-left: auto;
   	margin-right: auto;
   	width: 320px;
   	height: 335px;
   	border-style: none;
   	border-width: 0;
}