Skip to content

Commit

Permalink
Save textless event if times changed or attendees have been added.
Browse files Browse the repository at this point in the history
Change-Id: I0195bf5b24e99c7466791dc9875baffaff91b4c5
  • Loading branch information
Michael Chan committed Dec 14, 2012
1 parent f6bc9bc commit f9fa0ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
9 changes: 5 additions & 4 deletions src/com/android/calendar/CalendarEventModel.java
Expand Up @@ -170,6 +170,7 @@ public String toString() {
* Comparison function for a sort ordered primarily descending by minutes,
* secondarily ascending by method type.
*/
@Override
public int compareTo(ReminderEntry re) {
if (re.mMinutes != mMinutes) {
return re.mMinutes - mMinutes;
Expand Down Expand Up @@ -359,16 +360,16 @@ public boolean isValid() {
return true;
}

private boolean isEmpty() {
if (mTitle != null && mTitle.length() > 0) {
public boolean isEmpty() {
if (mTitle != null && mTitle.trim().length() > 0) {
return false;
}

if (mLocation != null && mLocation.length() > 0) {
if (mLocation != null && mLocation.trim().length() > 0) {
return false;
}

if (mDescription != null && mDescription.length() > 0) {
if (mDescription != null && mDescription.trim().length() > 0) {
return false;
}

Expand Down
32 changes: 10 additions & 22 deletions src/com/android/calendar/event/EditEventFragment.java
Expand Up @@ -402,6 +402,8 @@ private void startQuery() {
if (DEBUG) {
Log.d(TAG, "startQuery: Editing a new event.");
}
mModel.mOriginalStart = mBegin;
mModel.mOriginalEnd = mEnd;
mModel.mStart = mBegin;
mModel.mEnd = mEnd;
mModel.mCalendarId = mCalendarId;
Expand Down Expand Up @@ -607,6 +609,7 @@ protected void displayEditWhichDialog() {
}
mModifyDialog = new AlertDialog.Builder(mContext).setTitle(R.string.edit_event_label)
.setItems(items, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
// Update this if we start allowing exceptions
Expand Down Expand Up @@ -643,10 +646,12 @@ public void onCancel(DialogInterface dialog) {
class Done implements EditEventHelper.EditDoneRunnable {
private int mCode = -1;

@Override
public void setDoneCode(int code) {
mCode = code;
}

@Override
public void run() {
// We only want this to get called once, either because the user
// pressed back/home or one of the buttons on screen
Expand Down Expand Up @@ -751,32 +756,15 @@ boolean isEmptyNewEvent() {
return false;
}

return isEmpty();
}

private boolean isEmpty() {
if (mModel.mTitle != null) {
String title = mModel.mTitle.trim();
if (title.length() > 0) {
return false;
}
}

if (mModel.mLocation != null) {
String location = mModel.mLocation.trim();
if (location.length() > 0) {
return false;
}
if (mModel.mOriginalStart != mModel.mStart || mModel.mOriginalEnd != mModel.mEnd) {
return false;
}

if (mModel.mDescription != null) {
String description = mModel.mDescription.trim();
if (description.length() > 0) {
return false;
}
if (!mModel.mAttendeesList.isEmpty()) {
return false;
}

return true;
return mModel.isEmpty();
}

@Override
Expand Down

0 comments on commit f9fa0ab

Please sign in to comment.