Loading src/com/android/calendar/DeleteEventHelper.java +18 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import android.text.format.Time; import android.widget.ArrayAdapter; import android.widget.Button; import androidx.annotation.NonNull; import com.android.calendar.event.EditEventHelper; import com.android.calendar.persistence.CalendarRepository; import com.android.calendarcommon2.EventRecurrence; Loading Loading @@ -120,6 +122,7 @@ public class DeleteEventHelper { } } }; /** * This callback is used when an exception to an event is deleted */ Loading @@ -136,6 +139,7 @@ public class DeleteEventHelper { } } }; /** * This callback is used when a list item for a repeating event is selected */ Loading Loading @@ -163,7 +167,6 @@ public class DeleteEventHelper { } } }; public DeleteEventHelper(Context context, Activity parentActivity, boolean exitWhenDone) { if (exitWhenDone && parentActivity == null) { throw new IllegalArgumentException("parentActivity is required to exit when done"); Loading Loading @@ -339,6 +342,20 @@ public class DeleteEventHelper { } } public void delete(@NonNull CalendarEventModel model) { deleteStarted(); long id = model.mId; boolean isLocal = model.mSyncAccountType.equals(CalendarContract.ACCOUNT_TYPE_LOCAL); Uri deleteContentUri = isLocal ? CalendarRepository.asLocalCalendarSyncAdapter(mModel.mSyncAccountName, Events.CONTENT_URI) : Events.CONTENT_URI; Uri uri = ContentUris.withAppendedId(deleteContentUri, id); mService.startDelete(mService.getNextToken(), null, uri, null, null, Utils.UNDO_DELAY); if (mCallback != null) { mCallback.run(); } } private void deleteExceptionEvent() { long id = mModel.mId; // mCursor.getInt(mEventIndexId); Loading src/com/android/calendar/event/CreateEventDialogFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -195,7 +195,7 @@ public class CreateEventDialogFragment extends DialogFragment implements TextWat mModel.mCalendarId = mCalendarId; mModel.mOwnerAccount = mCalendarOwner; if (mEditEventHelper.saveEvent(mModel, null, 0)) { if (mEditEventHelper.saveEvent(mModel, null, 0, null)) { Toast.makeText(getActivity(), R.string.creating_event, Toast.LENGTH_SHORT).show(); } } Loading src/com/android/calendar/event/EditEventFragment.java +15 −16 Original line number Diff line number Diff line Loading @@ -748,12 +748,10 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor } // TOKEN_CALENDARS String[] selArgs = { Long.toString(mModel.mCalendarId) }; mHandler.startQuery(TOKEN_CALENDARS, null, Calendars.CONTENT_URI, EditEventHelper.CALENDARS_PROJECTION, EditEventHelper.CALENDARS_WHERE, selArgs /* selection args */, null /* sort order */); EditEventHelper.CALENDARS_PROJECTION, EditEventHelper.CALENDARS_WHERE_WRITEABLE_VISIBLE, null /* selection args */, null /* sort order */); // TOKEN_COLORS mHandler.startQuery(TOKEN_COLORS, null, Colors.CONTENT_URI, Loading Loading @@ -835,16 +833,17 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor break; case TOKEN_CALENDARS: try { if (mModel.mId == -1) { // Populate Calendar spinner only if no event id is set. MatrixCursor matrixCursor = Utils.matrixCursorFromCursor(cursor); if (DEBUG) { Log.d(TAG, "onQueryComplete: setting cursor with " + matrixCursor.getCount() + " calendars"); } long selectedCalendarId = mModel.mCalendarId == -1 ? mCalendarId : mModel.mCalendarId; mView.setCalendarsCursor(matrixCursor, isAdded() && isResumed(), mCalendarId); } else { selectedCalendarId); if (mModel.mId != -1) { // Populate model for an existing event EditEventHelper.setModelFromCalendarCursor(mModel, cursor); EditEventHelper.setModelFromCalendarCursor(mOriginalModel, cursor); Loading Loading @@ -921,7 +920,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor && mView.prepareForSave() && !isEmptyNewEvent() && mModel.normalizeReminders() && mHelper.saveEvent(mModel, mOriginalModel, mModification)) { && mHelper.saveEvent(mModel, mOriginalModel, mModification, mActivity)) { int stringResource; if (!mModel.mAttendeesList.isEmpty()) { if (mModel.mUri != null) { Loading src/com/android/calendar/event/EditEventHelper.java +8 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.calendar.event; import android.app.Activity; import android.content.ContentProviderOperation; import android.content.ContentUris; import android.content.ContentValues; Loading Loading @@ -267,10 +268,13 @@ public class EditEventHelper { * @param model The event model to save * @param originalModel A model of the original event if it exists * @param modifyWhich For recurring events which type of series modification to use * @param activity is used to handle moving any event to a different calendar * @return true if the event was successfully queued for saving */ public boolean saveEvent(CalendarEventModel model, CalendarEventModel originalModel, int modifyWhich) { public boolean saveEvent(CalendarEventModel model, CalendarEventModel originalModel, int modifyWhich, Activity activity) { boolean forceSaveReminders = false; if (DEBUG) { Loading Loading @@ -303,6 +307,8 @@ public class EditEventHelper { return false; } MoveEventHelper.handleMoveEvent(originalModel, model, activity); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int eventIdIndex = -1; Loading Loading @@ -803,9 +809,6 @@ public class EditEventHelper { return true; } if (model.mCalendarId != originalModel.mCalendarId) { return false; } if (model.mId != originalModel.mId) { return false; } Loading src/com/android/calendar/event/EditEventView.java +11 −27 Original line number Diff line number Diff line Loading @@ -629,9 +629,11 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa mEmailValidator.setRemoveInvalid(false); } // If this was a new event we need to fill in the Calendar information if (mModel.mUri == null) { mModel.mCalendarId = mCalendarsSpinner.getSelectedItemId(); long oldCalendarId = mModel.mCalendarId; long selectedCalendar = mCalendarsSpinner.getSelectedItemId(); // If calendar is changed, we need to fill in the Calendar information if (mModel.mUri == null || oldCalendarId != selectedCalendar) { mModel.mCalendarId = selectedCalendar; int calendarCursorPosition = mCalendarsSpinner.getSelectedItemPosition(); if (mCalendarsCursor.moveToPosition(calendarCursorPosition)) { String calendarOwner = mCalendarsCursor.getString( Loading Loading @@ -937,21 +939,6 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa mResponseGroup.setVisibility(View.GONE); } if (model.mUri != null) { // This is an existing event so hide the calendar spinner // since we can't change the calendar. View calendarGroup = mView.findViewById(R.id.calendar_selector_group); calendarGroup.setVisibility(View.VISIBLE); TextView tv = (TextView) mView.findViewById(R.id.calendar_textview); tv.setText(model.mCalendarDisplayName); tv = (TextView) mView.findViewById(R.id.calendar_textview_secondary); if (tv != null) { tv.setText(model.mOwnerAccount); } } else { View calendarGroup = mView.findViewById(R.id.calendar_group); calendarGroup.setVisibility(View.GONE); } if (model.isEventColorInitialized()) { updateHeadlineColor(model.getEventColor()); } Loading Loading @@ -1145,8 +1132,8 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa v.setEnabled(false); v.setBackgroundDrawable(null); } mCalendarSelectorGroup.setVisibility(View.GONE); mCalendarStaticGroup.setVisibility(View.VISIBLE); mCalendarSelectorGroup.setVisibility(View.VISIBLE); mCalendarStaticGroup.setVisibility(View.GONE); mRruleButton.setEnabled(false); if (EditEventHelper.canAddReminders(mModel)) { mRemindersGroup.setVisibility(View.VISIBLE); Loading Loading @@ -1174,13 +1161,10 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa mOriginalPadding[3]); } } if (mModel.mUri == null) { mCalendarSelectorGroup.setVisibility(View.VISIBLE); mCalendarStaticGroup.setVisibility(View.GONE); } else { mCalendarSelectorGroup.setVisibility(View.GONE); mCalendarStaticGroup.setVisibility(View.VISIBLE); } if (mModel.mOriginalSyncId == null) { mRruleButton.setEnabled(true); } else { Loading Loading
src/com/android/calendar/DeleteEventHelper.java +18 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import android.text.format.Time; import android.widget.ArrayAdapter; import android.widget.Button; import androidx.annotation.NonNull; import com.android.calendar.event.EditEventHelper; import com.android.calendar.persistence.CalendarRepository; import com.android.calendarcommon2.EventRecurrence; Loading Loading @@ -120,6 +122,7 @@ public class DeleteEventHelper { } } }; /** * This callback is used when an exception to an event is deleted */ Loading @@ -136,6 +139,7 @@ public class DeleteEventHelper { } } }; /** * This callback is used when a list item for a repeating event is selected */ Loading Loading @@ -163,7 +167,6 @@ public class DeleteEventHelper { } } }; public DeleteEventHelper(Context context, Activity parentActivity, boolean exitWhenDone) { if (exitWhenDone && parentActivity == null) { throw new IllegalArgumentException("parentActivity is required to exit when done"); Loading Loading @@ -339,6 +342,20 @@ public class DeleteEventHelper { } } public void delete(@NonNull CalendarEventModel model) { deleteStarted(); long id = model.mId; boolean isLocal = model.mSyncAccountType.equals(CalendarContract.ACCOUNT_TYPE_LOCAL); Uri deleteContentUri = isLocal ? CalendarRepository.asLocalCalendarSyncAdapter(mModel.mSyncAccountName, Events.CONTENT_URI) : Events.CONTENT_URI; Uri uri = ContentUris.withAppendedId(deleteContentUri, id); mService.startDelete(mService.getNextToken(), null, uri, null, null, Utils.UNDO_DELAY); if (mCallback != null) { mCallback.run(); } } private void deleteExceptionEvent() { long id = mModel.mId; // mCursor.getInt(mEventIndexId); Loading
src/com/android/calendar/event/CreateEventDialogFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -195,7 +195,7 @@ public class CreateEventDialogFragment extends DialogFragment implements TextWat mModel.mCalendarId = mCalendarId; mModel.mOwnerAccount = mCalendarOwner; if (mEditEventHelper.saveEvent(mModel, null, 0)) { if (mEditEventHelper.saveEvent(mModel, null, 0, null)) { Toast.makeText(getActivity(), R.string.creating_event, Toast.LENGTH_SHORT).show(); } } Loading
src/com/android/calendar/event/EditEventFragment.java +15 −16 Original line number Diff line number Diff line Loading @@ -748,12 +748,10 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor } // TOKEN_CALENDARS String[] selArgs = { Long.toString(mModel.mCalendarId) }; mHandler.startQuery(TOKEN_CALENDARS, null, Calendars.CONTENT_URI, EditEventHelper.CALENDARS_PROJECTION, EditEventHelper.CALENDARS_WHERE, selArgs /* selection args */, null /* sort order */); EditEventHelper.CALENDARS_PROJECTION, EditEventHelper.CALENDARS_WHERE_WRITEABLE_VISIBLE, null /* selection args */, null /* sort order */); // TOKEN_COLORS mHandler.startQuery(TOKEN_COLORS, null, Colors.CONTENT_URI, Loading Loading @@ -835,16 +833,17 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor break; case TOKEN_CALENDARS: try { if (mModel.mId == -1) { // Populate Calendar spinner only if no event id is set. MatrixCursor matrixCursor = Utils.matrixCursorFromCursor(cursor); if (DEBUG) { Log.d(TAG, "onQueryComplete: setting cursor with " + matrixCursor.getCount() + " calendars"); } long selectedCalendarId = mModel.mCalendarId == -1 ? mCalendarId : mModel.mCalendarId; mView.setCalendarsCursor(matrixCursor, isAdded() && isResumed(), mCalendarId); } else { selectedCalendarId); if (mModel.mId != -1) { // Populate model for an existing event EditEventHelper.setModelFromCalendarCursor(mModel, cursor); EditEventHelper.setModelFromCalendarCursor(mOriginalModel, cursor); Loading Loading @@ -921,7 +920,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor && mView.prepareForSave() && !isEmptyNewEvent() && mModel.normalizeReminders() && mHelper.saveEvent(mModel, mOriginalModel, mModification)) { && mHelper.saveEvent(mModel, mOriginalModel, mModification, mActivity)) { int stringResource; if (!mModel.mAttendeesList.isEmpty()) { if (mModel.mUri != null) { Loading
src/com/android/calendar/event/EditEventHelper.java +8 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.calendar.event; import android.app.Activity; import android.content.ContentProviderOperation; import android.content.ContentUris; import android.content.ContentValues; Loading Loading @@ -267,10 +268,13 @@ public class EditEventHelper { * @param model The event model to save * @param originalModel A model of the original event if it exists * @param modifyWhich For recurring events which type of series modification to use * @param activity is used to handle moving any event to a different calendar * @return true if the event was successfully queued for saving */ public boolean saveEvent(CalendarEventModel model, CalendarEventModel originalModel, int modifyWhich) { public boolean saveEvent(CalendarEventModel model, CalendarEventModel originalModel, int modifyWhich, Activity activity) { boolean forceSaveReminders = false; if (DEBUG) { Loading Loading @@ -303,6 +307,8 @@ public class EditEventHelper { return false; } MoveEventHelper.handleMoveEvent(originalModel, model, activity); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int eventIdIndex = -1; Loading Loading @@ -803,9 +809,6 @@ public class EditEventHelper { return true; } if (model.mCalendarId != originalModel.mCalendarId) { return false; } if (model.mId != originalModel.mId) { return false; } Loading
src/com/android/calendar/event/EditEventView.java +11 −27 Original line number Diff line number Diff line Loading @@ -629,9 +629,11 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa mEmailValidator.setRemoveInvalid(false); } // If this was a new event we need to fill in the Calendar information if (mModel.mUri == null) { mModel.mCalendarId = mCalendarsSpinner.getSelectedItemId(); long oldCalendarId = mModel.mCalendarId; long selectedCalendar = mCalendarsSpinner.getSelectedItemId(); // If calendar is changed, we need to fill in the Calendar information if (mModel.mUri == null || oldCalendarId != selectedCalendar) { mModel.mCalendarId = selectedCalendar; int calendarCursorPosition = mCalendarsSpinner.getSelectedItemPosition(); if (mCalendarsCursor.moveToPosition(calendarCursorPosition)) { String calendarOwner = mCalendarsCursor.getString( Loading Loading @@ -937,21 +939,6 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa mResponseGroup.setVisibility(View.GONE); } if (model.mUri != null) { // This is an existing event so hide the calendar spinner // since we can't change the calendar. View calendarGroup = mView.findViewById(R.id.calendar_selector_group); calendarGroup.setVisibility(View.VISIBLE); TextView tv = (TextView) mView.findViewById(R.id.calendar_textview); tv.setText(model.mCalendarDisplayName); tv = (TextView) mView.findViewById(R.id.calendar_textview_secondary); if (tv != null) { tv.setText(model.mOwnerAccount); } } else { View calendarGroup = mView.findViewById(R.id.calendar_group); calendarGroup.setVisibility(View.GONE); } if (model.isEventColorInitialized()) { updateHeadlineColor(model.getEventColor()); } Loading Loading @@ -1145,8 +1132,8 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa v.setEnabled(false); v.setBackgroundDrawable(null); } mCalendarSelectorGroup.setVisibility(View.GONE); mCalendarStaticGroup.setVisibility(View.VISIBLE); mCalendarSelectorGroup.setVisibility(View.VISIBLE); mCalendarStaticGroup.setVisibility(View.GONE); mRruleButton.setEnabled(false); if (EditEventHelper.canAddReminders(mModel)) { mRemindersGroup.setVisibility(View.VISIBLE); Loading Loading @@ -1174,13 +1161,10 @@ public class EditEventView implements View.OnClickListener, DialogInterface.OnCa mOriginalPadding[3]); } } if (mModel.mUri == null) { mCalendarSelectorGroup.setVisibility(View.VISIBLE); mCalendarStaticGroup.setVisibility(View.GONE); } else { mCalendarSelectorGroup.setVisibility(View.GONE); mCalendarStaticGroup.setVisibility(View.VISIBLE); } if (mModel.mOriginalSyncId == null) { mRruleButton.setEnabled(true); } else { Loading