Loading app/src/main/java/com/android/calendar/DeleteEventHelper.java +18 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.text.TextUtils; 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 app/src/main/java/com/android/calendar/event/CreateEventDialogFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -205,7 +205,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 app/src/main/java/com/android/calendar/event/EditEventFragment.java +16 −17 Original line number Diff line number Diff line Loading @@ -753,12 +753,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 @@ -770,7 +768,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor mModel.mCalendarAccountName, mModel.mCalendarAccountType ); selArgs = new String[]{ String[] selArgs = new String[]{ Long.toString(eventId) }; mHandler.startQuery(TOKEN_EXTENDED, null, extendedPropUri, Loading Loading @@ -852,16 +850,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, activity); EditEventHelper.setModelFromCalendarCursor(mOriginalModel, cursor, activity); Loading Loading @@ -960,7 +959,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor && mView.prepareForSave() && !isEmptyNewEvent() && mModel.normalizeReminders() && mHelper.saveEvent(mModel, mOriginalModel, mModification)) { && mHelper.saveEvent(mModel, mOriginalModel, mModification, requireActivity())) { int stringResource; if (!mModel.mAttendeesList.isEmpty()) { if (mModel.mUri != null) { Loading app/src/main/java/com/android/calendar/event/EditEventHelper.java +8 −6 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 @@ -23,7 +24,6 @@ import android.content.Context; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.provider.CalendarContract; import android.provider.CalendarContract.Attendees; import android.provider.CalendarContract.Calendars; import android.provider.CalendarContract.Colors; Loading Loading @@ -281,10 +281,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 @@ -317,6 +320,8 @@ public class EditEventHelper { return false; } MoveEventHelper.handleMoveEvent(originalModel, model, activity); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int eventIdIndex = -1; Loading Loading @@ -841,9 +846,6 @@ public class EditEventHelper { return true; } if (model.mCalendarId != originalModel.mCalendarId) { return false; } if (model.mId != originalModel.mId) { return false; } Loading app/src/main/java/com/android/calendar/event/EditEventView.java +11 −28 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.calendar.event; import android.app.Activity; import android.app.AlertDialog; import android.app.DatePickerDialog; import android.app.ProgressDialog; Loading Loading @@ -640,9 +639,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 (oldCalendarId != selectedCalendar) { mModel.mCalendarId = selectedCalendar; int calendarCursorPosition = mCalendarsSpinner.getSelectedItemPosition(); if (mCalendarsCursor.moveToPosition(calendarCursorPosition)) { String calendarOwner = mCalendarsCursor.getString( Loading Loading @@ -1000,21 +1001,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 @@ -1208,8 +1194,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 @@ -1240,13 +1226,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
app/src/main/java/com/android/calendar/DeleteEventHelper.java +18 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,8 @@ import android.text.TextUtils; 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
app/src/main/java/com/android/calendar/event/CreateEventDialogFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -205,7 +205,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
app/src/main/java/com/android/calendar/event/EditEventFragment.java +16 −17 Original line number Diff line number Diff line Loading @@ -753,12 +753,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 @@ -770,7 +768,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor mModel.mCalendarAccountName, mModel.mCalendarAccountType ); selArgs = new String[]{ String[] selArgs = new String[]{ Long.toString(eventId) }; mHandler.startQuery(TOKEN_EXTENDED, null, extendedPropUri, Loading Loading @@ -852,16 +850,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, activity); EditEventHelper.setModelFromCalendarCursor(mOriginalModel, cursor, activity); Loading Loading @@ -960,7 +959,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor && mView.prepareForSave() && !isEmptyNewEvent() && mModel.normalizeReminders() && mHelper.saveEvent(mModel, mOriginalModel, mModification)) { && mHelper.saveEvent(mModel, mOriginalModel, mModification, requireActivity())) { int stringResource; if (!mModel.mAttendeesList.isEmpty()) { if (mModel.mUri != null) { Loading
app/src/main/java/com/android/calendar/event/EditEventHelper.java +8 −6 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 @@ -23,7 +24,6 @@ import android.content.Context; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.provider.CalendarContract; import android.provider.CalendarContract.Attendees; import android.provider.CalendarContract.Calendars; import android.provider.CalendarContract.Colors; Loading Loading @@ -281,10 +281,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 @@ -317,6 +320,8 @@ public class EditEventHelper { return false; } MoveEventHelper.handleMoveEvent(originalModel, model, activity); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int eventIdIndex = -1; Loading Loading @@ -841,9 +846,6 @@ public class EditEventHelper { return true; } if (model.mCalendarId != originalModel.mCalendarId) { return false; } if (model.mId != originalModel.mId) { return false; } Loading
app/src/main/java/com/android/calendar/event/EditEventView.java +11 −28 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.calendar.event; import android.app.Activity; import android.app.AlertDialog; import android.app.DatePickerDialog; import android.app.ProgressDialog; Loading Loading @@ -640,9 +639,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 (oldCalendarId != selectedCalendar) { mModel.mCalendarId = selectedCalendar; int calendarCursorPosition = mCalendarsSpinner.getSelectedItemPosition(); if (mCalendarsCursor.moveToPosition(calendarCursorPosition)) { String calendarOwner = mCalendarsCursor.getString( Loading Loading @@ -1000,21 +1001,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 @@ -1208,8 +1194,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 @@ -1240,13 +1226,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