diff options
author | Erik <roboerik@android.com> | 2010-04-23 14:35:12 -0700 |
---|---|---|
committer | Erik <roboerik@android.com> | 2010-04-23 14:59:26 -0700 |
commit | a9dd45e7a7f422c3c7d74f10d1e65880c181d43b (patch) | |
tree | db689d308386dfd9777611499e7d5b42f80be8da | |
parent | 3c4cb80f5535addcab03999ce4c029e123da8612 (diff) | |
download | Calendar-a9dd45e7a7f422c3c7d74f10d1e65880c181d43b.tar.gz |
b/2622128 Exception events now get updated to be 'canceled' when deleted
Added some checking to the delete helper to make exception events have their status
changed instead of just being removed. This will cause them to hide the instance
of an exception that they represent. Previously that instance was being replaced
by the original recurrence after the event was removed.
Change-Id: If80e1ccb31af901f4d01d09d18e4850d4b763a57
-rw-r--r-- | src/com/android/calendar/DeleteEventHelper.java | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/com/android/calendar/DeleteEventHelper.java b/src/com/android/calendar/DeleteEventHelper.java index 2a86a772..ca80c904 100644 --- a/src/com/android/calendar/DeleteEventHelper.java +++ b/src/com/android/calendar/DeleteEventHelper.java @@ -84,10 +84,12 @@ public class DeleteEventHelper { Events.DTSTART, Events._SYNC_ID, Events.EVENT_TIMEZONE, + Events.ORIGINAL_EVENT, }; private int mEventIndexId; private int mEventIndexRrule; + private int mEventIndexOriginalEvent; private String mSyncId; public DeleteEventHelper(Activity parent, boolean exitWhenDone) { @@ -116,6 +118,16 @@ public class DeleteEventHelper { }; /** + * This callback is used when an exception to an event is deleted + */ + private DialogInterface.OnClickListener mDeleteExceptionDialogListener = + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int button) { + deleteExceptionEvent(); + } + }; + + /** * This callback is used when a list item for a repeating event is selected */ private DialogInterface.OnClickListener mDeleteListListener = @@ -202,6 +214,7 @@ public class DeleteEventHelper { mCursor = cursor; mEventIndexId = mCursor.getColumnIndexOrThrow(Events._ID); mEventIndexRrule = mCursor.getColumnIndexOrThrow(Events.RRULE); + mEventIndexOriginalEvent = mCursor.getColumnIndexOrThrow(Events.ORIGINAL_EVENT); int eventIndexSyncId = mCursor.getColumnIndexOrThrow(Events._SYNC_ID); mSyncId = mCursor.getString(eventIndexSyncId); @@ -209,15 +222,27 @@ public class DeleteEventHelper { // user if they want to delete all of the repeating events or // just some of them. String rRule = mCursor.getString(mEventIndexRrule); + String originalEvent = mCursor.getString(this.mEventIndexOriginalEvent); if (rRule == null) { - // This is a normal event. Pop up a confirmation dialog. - new AlertDialog.Builder(mParent) + AlertDialog dialog = new AlertDialog.Builder(mParent) .setTitle(R.string.delete_title) .setMessage(R.string.delete_this_event_title) .setIcon(android.R.drawable.ic_dialog_alert) - .setPositiveButton(android.R.string.ok, mDeleteNormalDialogListener) .setNegativeButton(android.R.string.cancel, null) - .show(); + .create(); + + if (originalEvent == null) { + // This is a normal event. Pop up a confirmation dialog. + dialog.setButton(DialogInterface.BUTTON_POSITIVE, + mParent.getText(android.R.string.ok), + mDeleteNormalDialogListener); + } else { + // This is an exception event. Pop up a confirmation dialog. + dialog.setButton(DialogInterface.BUTTON_POSITIVE, + mParent.getText(android.R.string.ok), + mDeleteExceptionDialogListener); + } + dialog.show(); } else { // This is a repeating event. Pop up a dialog asking which events // to delete. @@ -243,6 +268,17 @@ public class DeleteEventHelper { } } + private void deleteExceptionEvent() { + long id = mCursor.getInt(mEventIndexId); + + // update a recurrence exception by setting its status to "canceled" + ContentValues values = new ContentValues(); + values.put(Events.STATUS, Events.STATUS_CANCELED); + + Uri uri = ContentUris.withAppendedId(Calendar.Events.CONTENT_URI, id); + mContentResolver.update(uri, values, null, null); + } + private void deleteRepeatingEvent(int which) { int indexDtstart = mCursor.getColumnIndexOrThrow(Events.DTSTART); int indexAllDay = mCursor.getColumnIndexOrThrow(Events.ALL_DAY); |