Fix for AST-180 - updating title, notes, or due date of an Astrid task updates calendar event

pull/14/head
Tim Su 16 years ago
parent 252beae2ef
commit e3634794ee

@ -177,7 +177,28 @@ public class GCalControlSet implements TaskEditControlSet {
exceptionService.displayAndReportError(activity,
activity.getString(R.string.gcal_TEA_error), e);
}
} else if(calendarUri != null) {
try {
ContentValues updateValues = new ContentValues();
// check if we need to update the item
ContentValues setValues = task.getSetValues();
if(setValues.containsKey(Task.TITLE.name))
updateValues.put("title", task.getValue(Task.TITLE));
if(setValues.containsKey(Task.NOTES.name))
updateValues.put("description", task.getValue(Task.NOTES));
if(setValues.containsKey(Task.DUE_DATE.name))
createStartAndEndDate(task, updateValues);
ContentResolver cr = activity.getContentResolver();
if(cr.update(calendarUri, updateValues, null, null) > 0)
return activity.getString(R.string.gcal_TEA_calendar_updated);
} catch (Exception e) {
exceptionService.reportError("unable-to-update-calendar: " + //$NON-NLS-1$
task.getValue(Task.CALENDAR_URI), e);
}
}
return null;
}

@ -21,6 +21,9 @@
<!-- Toast when unable to open calendar event -->
<string name="gcal_TEA_calendar_error">Error opening event!</string>
<!-- Toast when calendar event updated because task changed -->
<string name="gcal_TEA_calendar_updated">Calendar event also updated!</string>
<!-- ======================================================== Calendars == -->
<!-- Calendar event name when task is completed (%s => task title) -->

@ -377,14 +377,18 @@ public final class TaskEditActivity extends TabActivity {
/** Save task model from values in UI components */
private void save() {
for(TaskEditControlSet controlSet : controls)
controlSet.writeToModel(model);
StringBuilder toast = new StringBuilder();
for(TaskEditControlSet controlSet : controls) {
String toastText = controlSet.writeToModel(model);
if(toastText != null)
toast.append('\n').append(toastText);
}
if(title.getText().length() > 0)
model.setValue(Task.DELETION_DATE, 0L);
if(taskService.save(model) && title.getText().length() > 0)
showSaveToast();
showSaveToast(toast.toString());
}
@Override
@ -445,22 +449,26 @@ public final class TaskEditActivity extends TabActivity {
* Displays a Toast reporting that the selected task has been saved and, if
* it has a due date, that is due in 'x' amount of time, to 1 time-unit of
* precision
* @param additionalMessage
*/
private void showSaveToast() {
private void showSaveToast(String additionalMessage) {
int stringResource;
long due = model.getValue(Task.DUE_DATE);
String toastMessage;
if (due != 0) {
stringResource = R.string.TEA_onTaskSave_due;
CharSequence formattedDate =
DateUtils.getRelativeTimeSpanString(due);
Toast.makeText(this,
getResources().getString(stringResource, formattedDate),
Toast.LENGTH_SHORT).show();
toastMessage = getString(stringResource, formattedDate);
} else {
Toast.makeText(this, R.string.TEA_onTaskSave_notDue,
Toast.LENGTH_SHORT).show();
toastMessage = getString(R.string.TEA_onTaskSave_notDue);
}
int length = additionalMessage.length() == 0 ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG;
Toast.makeText(this,
toastMessage + additionalMessage,
length).show();
}
protected void discardButtonClick() {

Loading…
Cancel
Save