summaryrefslogtreecommitdiffstats
path: root/src/com/android/calendar
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2011-07-21 15:08:39 -0700
committerRoboErik <epastern@google.com>2011-07-21 15:08:39 -0700
commit28dab653f55caccbed32f700274f5274abaee089 (patch)
treedd64af7a5a79d879d73365acacdd836444d05e6c /src/com/android/calendar
parentaf2ed19a0b3ae26ec91ffddd66f1923e2447a2e1 (diff)
downloadandroid_packages_apps_Calendar-28dab653f55caccbed32f700274f5274abaee089.tar.gz
android_packages_apps_Calendar-28dab653f55caccbed32f700274f5274abaee089.tar.bz2
android_packages_apps_Calendar-28dab653f55caccbed32f700274f5274abaee089.zip
b/5063456 Fix event changes checks to be less agressive
Change-Id: I09571289e45a753875b3e8117027c1a95f33520b
Diffstat (limited to 'src/com/android/calendar')
-rw-r--r--src/com/android/calendar/CalendarEventModel.java133
-rw-r--r--src/com/android/calendar/DeleteEventHelper.java2
-rw-r--r--src/com/android/calendar/event/EditEventFragment.java38
-rw-r--r--src/com/android/calendar/event/EditEventHelper.java10
-rw-r--r--src/com/android/calendar/event/EditEventView.java4
5 files changed, 125 insertions, 62 deletions
diff --git a/src/com/android/calendar/CalendarEventModel.java b/src/com/android/calendar/CalendarEventModel.java
index c65c993a..2a3eee51 100644
--- a/src/com/android/calendar/CalendarEventModel.java
+++ b/src/com/android/calendar/CalendarEventModel.java
@@ -240,7 +240,8 @@ public class CalendarEventModel implements Serializable {
public boolean mHasAttendeeData = true;
public int mSelfAttendeeStatus = -1;
public int mOwnerAttendeeId = -1;
- public String mOriginalEvent = null;
+ public String mOriginalSyncId = null;
+ public long mOriginalId = -1;
public Long mOriginalTime = null;
public Boolean mOriginalAllDay = null;
public boolean mGuestsCanModify = false;
@@ -395,7 +396,8 @@ public class CalendarEventModel implements Serializable {
mHasAttendeeData = true;
mSelfAttendeeStatus = -1;
mOwnerAttendeeId = -1;
- mOriginalEvent = null;
+ mOriginalId = -1;
+ mOriginalSyncId = null;
mOriginalTime = null;
mOriginalAllDay = null;
@@ -471,7 +473,8 @@ public class CalendarEventModel implements Serializable {
result = prime * result + ((mOrganizer == null) ? 0 : mOrganizer.hashCode());
result = prime * result + ((mOriginalAllDay == null) ? 0 : mOriginalAllDay.hashCode());
result = prime * result + (int) (mOriginalEnd ^ (mOriginalEnd >>> 32));
- result = prime * result + ((mOriginalEvent == null) ? 0 : mOriginalEvent.hashCode());
+ result = prime * result + ((mOriginalSyncId == null) ? 0 : mOriginalSyncId.hashCode());
+ result = prime * result + (int) (mOriginalId ^ (mOriginalEnd >>> 32));
result = prime * result + (int) (mOriginalStart ^ (mOriginalStart >>> 32));
result = prime * result + ((mOriginalTime == null) ? 0 : mOriginalTime.hashCode());
result = prime * result + ((mOwnerAccount == null) ? 0 : mOwnerAccount.hashCode());
@@ -510,6 +513,38 @@ public class CalendarEventModel implements Serializable {
return false;
}
+ if (mLocation == null) {
+ if (other.mLocation != null) {
+ return false;
+ }
+ } else if (!mLocation.equals(other.mLocation)) {
+ return false;
+ }
+
+ if (mTitle == null) {
+ if (other.mTitle != null) {
+ return false;
+ }
+ } else if (!mTitle.equals(other.mTitle)) {
+ return false;
+ }
+
+ if (mDescription == null) {
+ if (other.mDescription != null) {
+ return false;
+ }
+ } else if (!mDescription.equals(other.mDescription)) {
+ return false;
+ }
+
+ if (mDuration == null) {
+ if (other.mDuration != null) {
+ return false;
+ }
+ } else if (!mDuration.equals(other.mDuration)) {
+ return false;
+ }
+
if (mEnd != other.mEnd) {
return false;
}
@@ -527,11 +562,15 @@ public class CalendarEventModel implements Serializable {
return false;
}
- if (mOriginalEvent == null) {
- if (other.mOriginalEvent != null) {
+ if (mOriginalId != other.mOriginalId) {
+ return false;
+ }
+
+ if (mOriginalSyncId == null) {
+ if (other.mOriginalSyncId != null) {
return false;
}
- } else if (!mOriginalEvent.equals(other.mOriginalEvent)) {
+ } else if (!mOriginalSyncId.equals(other.mOriginalSyncId)) {
return false;
}
@@ -562,6 +601,39 @@ public class CalendarEventModel implements Serializable {
if (!checkOriginalModelFields(originalModel)) {
return false;
}
+
+ if (TextUtils.isEmpty(mLocation)) {
+ if (!TextUtils.isEmpty(originalModel.mLocation)) {
+ return false;
+ }
+ } else if (!mLocation.equals(originalModel.mLocation)) {
+ return false;
+ }
+
+ if (TextUtils.isEmpty(mTitle)) {
+ if (!TextUtils.isEmpty(originalModel.mTitle)) {
+ return false;
+ }
+ } else if (!mTitle.equals(originalModel.mTitle)) {
+ return false;
+ }
+
+ if (TextUtils.isEmpty(mDescription)) {
+ if (!TextUtils.isEmpty(originalModel.mDescription)) {
+ return false;
+ }
+ } else if (!mDescription.equals(originalModel.mDescription)) {
+ return false;
+ }
+
+ if (TextUtils.isEmpty(mDuration)) {
+ if (!TextUtils.isEmpty(originalModel.mDuration)) {
+ return false;
+ }
+ } else if (!mDuration.equals(originalModel.mDuration)) {
+ return false;
+ }
+
if (mEnd != mOriginalEnd) {
return false;
}
@@ -569,9 +641,20 @@ public class CalendarEventModel implements Serializable {
return false;
}
- if (mRrule == null) {
- if (originalModel.mRrule != null) {
- if (mOriginalEvent == null || !mOriginalEvent.equals(originalModel.mSyncId)) {
+ // If this changed the original id and it's not just an exception to the
+ // original event
+ if (mOriginalId != originalModel.mOriginalId && mOriginalId != originalModel.mId) {
+ return false;
+ }
+
+ if (TextUtils.isEmpty(mRrule)) {
+ // if the rrule is no longer empty check if this is an exception
+ if (!TextUtils.isEmpty(originalModel.mRrule)) {
+ boolean syncIdNotReferenced = mOriginalSyncId == null
+ || !mOriginalSyncId.equals(originalModel.mSyncId);
+ boolean localIdNotReferenced = mOriginalId == -1
+ || !(mOriginalId == originalModel.mId);
+ if (syncIdNotReferenced && localIdNotReferenced) {
return false;
}
}
@@ -607,22 +690,6 @@ public class CalendarEventModel implements Serializable {
return false;
}
- if (mDescription == null) {
- if (originalModel.mDescription != null) {
- return false;
- }
- } else if (!mDescription.equals(originalModel.mDescription)) {
- return false;
- }
-
- if (mDuration == null) {
- if (originalModel.mDuration != null) {
- return false;
- }
- } else if (!mDuration.equals(originalModel.mDuration)) {
- return false;
- }
-
if (mGuestsCanInviteOthers != originalModel.mGuestsCanInviteOthers) {
return false;
}
@@ -654,14 +721,6 @@ public class CalendarEventModel implements Serializable {
return false;
}
- if (mLocation == null) {
- if (originalModel.mLocation != null) {
- return false;
- }
- } else if (!mLocation.equals(originalModel.mLocation)) {
- return false;
- }
-
if (mOrganizer == null) {
if (originalModel.mOrganizer != null) {
return false;
@@ -748,14 +807,6 @@ public class CalendarEventModel implements Serializable {
return false;
}
- if (mTitle == null) {
- if (originalModel.mTitle != null) {
- return false;
- }
- } else if (!mTitle.equals(originalModel.mTitle)) {
- return false;
- }
-
if (mAvailability != originalModel.mAvailability) {
return false;
}
diff --git a/src/com/android/calendar/DeleteEventHelper.java b/src/com/android/calendar/DeleteEventHelper.java
index b5b609f9..364974b8 100644
--- a/src/com/android/calendar/DeleteEventHelper.java
+++ b/src/com/android/calendar/DeleteEventHelper.java
@@ -250,7 +250,7 @@ public class DeleteEventHelper {
// user if they want to delete all of the repeating events or
// just some of them.
String rRule = model.mRrule;
- String originalEvent = model.mOriginalEvent;
+ String originalEvent = model.mOriginalSyncId;
if (TextUtils.isEmpty(rRule)) {
AlertDialog dialog = new AlertDialog.Builder(mContext).setTitle(R.string.delete_title)
.setMessage(R.string.delete_this_event_title)
diff --git a/src/com/android/calendar/event/EditEventFragment.java b/src/com/android/calendar/event/EditEventFragment.java
index d66aeec5..20b45439 100644
--- a/src/com/android/calendar/event/EditEventFragment.java
+++ b/src/com/android/calendar/event/EditEventFragment.java
@@ -596,22 +596,29 @@ public class EditEventFragment extends Fragment implements EventHandler {
mModifyDialog.dismiss();
mModifyDialog = null;
}
- mModifyDialog = new AlertDialog.Builder(mContext)
- .setTitle(R.string.edit_event_label).setItems(items, new OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- if (which == 0) {
- mModification = notSynced ? Utils.MODIFY_ALL : Utils.MODIFY_SELECTED;
- mModel.mOriginalEvent = notSynced ? null : mModel.mSyncId;
- } else if (which == 1) {
- mModification = notSynced ? Utils.MODIFY_ALL_FOLLOWING : Utils.MODIFY_ALL;
- } else if (which == 2) {
- mModification = Utils.MODIFY_ALL_FOLLOWING;
- }
+ mModifyDialog = new AlertDialog.Builder(mContext).setTitle(R.string.edit_event_label)
+ .setItems(items, new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ if (which == 0) {
+ // Update this if we start allowing exceptions
+ // to unsynced events in the app
+ mModification = notSynced ? Utils.MODIFY_ALL
+ : Utils.MODIFY_SELECTED;
+ if (mModification == Utils.MODIFY_SELECTED) {
+ mModel.mOriginalSyncId = notSynced ? null : mModel.mSyncId;
+ mModel.mOriginalId = mModel.mId;
+ }
+ } else if (which == 1) {
+ mModification = notSynced ? Utils.MODIFY_ALL_FOLLOWING
+ : Utils.MODIFY_ALL;
+ } else if (which == 2) {
+ mModification = Utils.MODIFY_ALL_FOLLOWING;
+ }
- mView.setModification(mModification);
- updateActionBar();
- }
- }).show();
+ mView.setModification(mModification);
+ updateActionBar();
+ }
+ }).show();
}
}
@@ -637,7 +644,6 @@ public class EditEventFragment extends Fragment implements EventHandler {
|| EditEventHelper.canModifyEvent(mModel))
&& !isEmptyNewEvent()
&& mModel.normalizeReminders()
- && !mModel.isUnchanged(mOriginalModel)
&& mHelper.saveEvent(mModel, mOriginalModel, mModification)) {
int stringResource;
if (!mModel.mAttendeesList.isEmpty()) {
diff --git a/src/com/android/calendar/event/EditEventHelper.java b/src/com/android/calendar/event/EditEventHelper.java
index 055e417a..e6d993d6 100644
--- a/src/com/android/calendar/event/EditEventHelper.java
+++ b/src/com/android/calendar/event/EditEventHelper.java
@@ -83,6 +83,7 @@ public class EditEventHelper {
Events.ORIGINAL_SYNC_ID, // 17
Events.ORGANIZER, // 18
Events.GUESTS_CAN_MODIFY, // 19
+ Events.ORIGINAL_ID, // 20
};
protected static final int EVENT_INDEX_ID = 0;
protected static final int EVENT_INDEX_TITLE = 1;
@@ -101,9 +102,10 @@ public class EditEventHelper {
protected static final int EVENT_INDEX_ACCESS_LEVEL = 14;
protected static final int EVENT_INDEX_OWNER_ACCOUNT = 15;
protected static final int EVENT_INDEX_HAS_ATTENDEE_DATA = 16;
- protected static final int EVENT_INDEX_ORIGINAL_EVENT = 17;
+ protected static final int EVENT_INDEX_ORIGINAL_SYNC_ID = 17;
protected static final int EVENT_INDEX_ORGANIZER = 18;
protected static final int EVENT_INDEX_GUESTS_CAN_MODIFY = 19;
+ protected static final int EVENT_INDEX_ORIGINAL_ID = 20;
public static final String[] REMINDERS_PROJECTION = new String[] {
Reminders._ID, // 0
@@ -284,6 +286,9 @@ public class EditEventHelper {
+ "event.");
return false;
}
+ if (originalModel != null && model.isUnchanged(originalModel)) {
+ return false;
+ }
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
int eventIdIndex = -1;
@@ -1050,7 +1055,8 @@ public class EditEventHelper {
int accessLevel = cursor.getInt(EVENT_INDEX_ACCESS_LEVEL);
model.mOwnerAccount = cursor.getString(EVENT_INDEX_OWNER_ACCOUNT);
model.mHasAttendeeData = cursor.getInt(EVENT_INDEX_HAS_ATTENDEE_DATA) != 0;
- model.mOriginalEvent = cursor.getString(EVENT_INDEX_ORIGINAL_EVENT);
+ model.mOriginalSyncId = cursor.getString(EVENT_INDEX_ORIGINAL_SYNC_ID);
+ model.mOriginalId = cursor.getLong(EVENT_INDEX_ORIGINAL_ID);
model.mOrganizer = cursor.getString(EVENT_INDEX_ORGANIZER);
model.mIsOrganizer = model.mOwnerAccount.equalsIgnoreCase(model.mOrganizer);
model.mGuestsCanModify = cursor.getInt(EVENT_INDEX_GUESTS_CAN_MODIFY) != 0;
diff --git a/src/com/android/calendar/event/EditEventView.java b/src/com/android/calendar/event/EditEventView.java
index bc02d323..d8b73938 100644
--- a/src/com/android/calendar/event/EditEventView.java
+++ b/src/com/android/calendar/event/EditEventView.java
@@ -509,7 +509,7 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa
mRepeatsSpinner.setSelection(position);
// Don't allow the user to make exceptions recurring events.
- if (mModel.mOriginalEvent != null) {
+ if (mModel.mOriginalSyncId != null) {
mRepeatsSpinner.setEnabled(false);
}
}
@@ -1368,7 +1368,7 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa
mCalendarStaticGroup.setVisibility(View.VISIBLE);
}
mRepeatsSpinner.setBackgroundDrawable((Drawable) mRepeatsSpinner.getTag());
- if (mModel.mOriginalEvent == null) {
+ if (mModel.mOriginalSyncId == null) {
mRepeatsSpinner.setEnabled(true);
} else {
mRepeatsSpinner.setEnabled(false);