Loading app/build.gradle +2 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,8 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.google.android.material:material:1.8.0' implementation 'com.google.code.gson:gson:2.10.1' testImplementation 'junit:junit:4.13.2' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3' Loading app/src/main/AndroidManifest.xml +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="foundation.e.calendar" android:installLocation="auto"> <uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" /> Loading app/src/main/java/com/android/calendar/DeleteEventHelper.java +23 −2 Original line number Diff line number Diff line Loading @@ -266,7 +266,28 @@ public class DeleteEventHelper { // just some of them. String rRule = model.mRrule; String originalEvent = model.mOriginalSyncId; if (TextUtils.isEmpty(rRule)) { deleteStarted(); long id = mModel.mId; // mCursor.getInt(mEventIndexId); // If this event is part of a local calendar, really remove it from the database // // "There are two versions of delete: as an app and as a sync adapter. // An app delete will set the deleted column on an event and remove all instances of that event. // A sync adapter delete will remove the event from the database and all associated data." // from https://developer.android.com/reference/android/provider/CalendarContract.Events boolean isLocal = mModel.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(); } // if (mExitWhenDone) { // mParent.finish(); // } if (TextUtils.isEmpty(rRule) && which != -7) { AlertDialog dialog = new AlertDialog.Builder(mContext) .setMessage(R.string.delete_this_event_title) .setIconAttribute(android.R.attr.alertDialogIcon) Loading @@ -286,7 +307,7 @@ public class DeleteEventHelper { dialog.setOnDismissListener(mDismissListener); dialog.show(); mAlertDialog = dialog; } else { } else if ( which != -7) { // This is a repeating event. Pop up a dialog asking which events // to delete. Resources res = mContext.getResources(); Loading app/src/main/java/com/android/calendar/EventInfoFragment.java +17 −5 Original line number Diff line number Diff line Loading @@ -344,15 +344,15 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange private int mCurrentQuery = 0; private View mView; private Uri mUri; private long mEventId; public static long mEventId; private Cursor mEventCursor; private Cursor mAttendeesCursor; private Cursor mCalendarsCursor; private Cursor mRemindersCursor; private Cursor mExtendedCursor; private String mEventUrl; private long mStartMillis; private long mEndMillis; public static long mStartMillis; public static long mEndMillis; private boolean mAllDay; private boolean mHasAttendeeData; private String mEventOrganizerEmail; Loading Loading @@ -510,6 +510,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange this(context, ContentUris.withAppendedId(Events.CONTENT_URI, eventId), startMillis, endMillis, attendeeResponse, isDialog, windowStyle, reminders); mEventId = eventId; Log.d("Event", "===> event id: " + mEventId); } public static int getResponseFromButtonId(int buttonId) { Loading Loading @@ -791,6 +792,9 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange } mReminders = Utils.readRemindersFromBundle(savedInstanceState); CalendarEventModel event = new CalendarEventModel(requireContext()); } if (mWindowStyle == DIALOG_WINDOW_STYLE) { Loading Loading @@ -919,8 +923,15 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange View.OnClickListener addReminderOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { addReminder(); mUserModifiedReminders = true; // addReminder(); // mUserModifiedReminders = true; mDeleteHelper = new DeleteEventHelper(mActivity, mActivity, true /* exitWhenDone */); mDeleteHelper.setDeleteNotificationListener(EventInfoFragment.this); mDeleteHelper.setOnDismissListener(createDeleteOnDismissListener()); mDeleteDialogVisible = true; mDeleteHelper.delete(mStartMillis, mEndMillis, mEventId, -1, onDeleteRunnable); } }; reminderAddButton.setOnClickListener(addReminderOnClickListener); Loading Loading @@ -2586,4 +2597,5 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange } } } } app/src/main/java/com/android/calendar/event/EditEventFragment.java +28 −0 Original line number Diff line number Diff line Loading @@ -16,8 +16,12 @@ package com.android.calendar.event; import static com.android.calendar.EventInfoFragment.mEndMillis; import static com.android.calendar.EventInfoFragment.mEventId; import static com.android.calendar.EventInfoFragment.mStartMillis; import static com.android.calendar.event.EditEventHelper.EXTENDED_INDEX_NAME; import static com.android.calendar.event.EditEventHelper.EXTENDED_INDEX_VALUE; import static com.android.calendar.event.EditEventView.deleted; import android.Manifest; import android.app.Activity; Loading Loading @@ -76,10 +80,13 @@ import com.android.calendar.Utils; import com.android.calendarcommon2.Time; import com.android.colorpicker.ColorPickerSwatch.OnColorSelectedListener; import com.android.colorpicker.HsvColorComparator; import com.google.gson.Gson; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.logging.Level; import java.util.logging.Logger; import ws.xsoh.etar.R; Loading Loading @@ -311,6 +318,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor mHelper = new EditEventHelper(activity, null); mHandler = new QueryHandler(activity.getContentResolver()); mModel = new CalendarEventModel(activity, mIntent); Log.d("Edit event", "Event model: " + new Gson().toJson(mModel)); mInputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); Loading Loading @@ -418,6 +426,19 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor */ private boolean onActionBarItemSelected(int itemId) { if (itemId == R.id.action_done) { if (mModel.mUri != null) { DeleteEventHelper mDeleteHelper = new DeleteEventHelper(mActivity, mActivity, true /* exitWhenDone */); mDeleteHelper.setDeleteNotificationListener(null); mDeleteHelper.delete(mStartMillis, mEndMillis, mEventId, -7, null); deleted = true; } try { Thread.sleep(300); } catch (InterruptedException e) { throw new RuntimeException(e); } if (EditEventHelper.canModifyEvent(mModel) || EditEventHelper.canRespond(mModel)) { if (mView != null && mView.prepareForSave()) { if (mModification == Utils.MODIFY_UNINITIALIZED) { Loading Loading @@ -954,6 +975,12 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor mModification = Utils.MODIFY_ALL; } if (deleted) { mHelper.saveEvent(mModel, mOriginalModel, mModification); Toast.makeText(mActivity, "Event updated", Toast.LENGTH_SHORT).show(); return; } if ((mCode & Utils.DONE_SAVE) != 0 && mModel != null && (EditEventHelper.canRespond(mModel) || EditEventHelper.canModifyEvent(mModel)) Loading @@ -961,6 +988,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor && !isEmptyNewEvent() && mModel.normalizeReminders() && mHelper.saveEvent(mModel, mOriginalModel, mModification)) { Logger.getAnonymousLogger().log(Level.INFO, "Event after save: " + new Gson().toJson(mModel)); int stringResource; if (!mModel.mAttendeesList.isEmpty()) { if (mModel.mUri != null) { Loading Loading
app/build.gradle +2 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,8 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.google.android.material:material:1.8.0' implementation 'com.google.code.gson:gson:2.10.1' testImplementation 'junit:junit:4.13.2' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3' Loading
app/src/main/AndroidManifest.xml +0 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="foundation.e.calendar" android:installLocation="auto"> <uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" /> Loading
app/src/main/java/com/android/calendar/DeleteEventHelper.java +23 −2 Original line number Diff line number Diff line Loading @@ -266,7 +266,28 @@ public class DeleteEventHelper { // just some of them. String rRule = model.mRrule; String originalEvent = model.mOriginalSyncId; if (TextUtils.isEmpty(rRule)) { deleteStarted(); long id = mModel.mId; // mCursor.getInt(mEventIndexId); // If this event is part of a local calendar, really remove it from the database // // "There are two versions of delete: as an app and as a sync adapter. // An app delete will set the deleted column on an event and remove all instances of that event. // A sync adapter delete will remove the event from the database and all associated data." // from https://developer.android.com/reference/android/provider/CalendarContract.Events boolean isLocal = mModel.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(); } // if (mExitWhenDone) { // mParent.finish(); // } if (TextUtils.isEmpty(rRule) && which != -7) { AlertDialog dialog = new AlertDialog.Builder(mContext) .setMessage(R.string.delete_this_event_title) .setIconAttribute(android.R.attr.alertDialogIcon) Loading @@ -286,7 +307,7 @@ public class DeleteEventHelper { dialog.setOnDismissListener(mDismissListener); dialog.show(); mAlertDialog = dialog; } else { } else if ( which != -7) { // This is a repeating event. Pop up a dialog asking which events // to delete. Resources res = mContext.getResources(); Loading
app/src/main/java/com/android/calendar/EventInfoFragment.java +17 −5 Original line number Diff line number Diff line Loading @@ -344,15 +344,15 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange private int mCurrentQuery = 0; private View mView; private Uri mUri; private long mEventId; public static long mEventId; private Cursor mEventCursor; private Cursor mAttendeesCursor; private Cursor mCalendarsCursor; private Cursor mRemindersCursor; private Cursor mExtendedCursor; private String mEventUrl; private long mStartMillis; private long mEndMillis; public static long mStartMillis; public static long mEndMillis; private boolean mAllDay; private boolean mHasAttendeeData; private String mEventOrganizerEmail; Loading Loading @@ -510,6 +510,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange this(context, ContentUris.withAppendedId(Events.CONTENT_URI, eventId), startMillis, endMillis, attendeeResponse, isDialog, windowStyle, reminders); mEventId = eventId; Log.d("Event", "===> event id: " + mEventId); } public static int getResponseFromButtonId(int buttonId) { Loading Loading @@ -791,6 +792,9 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange } mReminders = Utils.readRemindersFromBundle(savedInstanceState); CalendarEventModel event = new CalendarEventModel(requireContext()); } if (mWindowStyle == DIALOG_WINDOW_STYLE) { Loading Loading @@ -919,8 +923,15 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange View.OnClickListener addReminderOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { addReminder(); mUserModifiedReminders = true; // addReminder(); // mUserModifiedReminders = true; mDeleteHelper = new DeleteEventHelper(mActivity, mActivity, true /* exitWhenDone */); mDeleteHelper.setDeleteNotificationListener(EventInfoFragment.this); mDeleteHelper.setOnDismissListener(createDeleteOnDismissListener()); mDeleteDialogVisible = true; mDeleteHelper.delete(mStartMillis, mEndMillis, mEventId, -1, onDeleteRunnable); } }; reminderAddButton.setOnClickListener(addReminderOnClickListener); Loading Loading @@ -2586,4 +2597,5 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange } } } }
app/src/main/java/com/android/calendar/event/EditEventFragment.java +28 −0 Original line number Diff line number Diff line Loading @@ -16,8 +16,12 @@ package com.android.calendar.event; import static com.android.calendar.EventInfoFragment.mEndMillis; import static com.android.calendar.EventInfoFragment.mEventId; import static com.android.calendar.EventInfoFragment.mStartMillis; import static com.android.calendar.event.EditEventHelper.EXTENDED_INDEX_NAME; import static com.android.calendar.event.EditEventHelper.EXTENDED_INDEX_VALUE; import static com.android.calendar.event.EditEventView.deleted; import android.Manifest; import android.app.Activity; Loading Loading @@ -76,10 +80,13 @@ import com.android.calendar.Utils; import com.android.calendarcommon2.Time; import com.android.colorpicker.ColorPickerSwatch.OnColorSelectedListener; import com.android.colorpicker.HsvColorComparator; import com.google.gson.Gson; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.logging.Level; import java.util.logging.Logger; import ws.xsoh.etar.R; Loading Loading @@ -311,6 +318,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor mHelper = new EditEventHelper(activity, null); mHandler = new QueryHandler(activity.getContentResolver()); mModel = new CalendarEventModel(activity, mIntent); Log.d("Edit event", "Event model: " + new Gson().toJson(mModel)); mInputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); Loading Loading @@ -418,6 +426,19 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor */ private boolean onActionBarItemSelected(int itemId) { if (itemId == R.id.action_done) { if (mModel.mUri != null) { DeleteEventHelper mDeleteHelper = new DeleteEventHelper(mActivity, mActivity, true /* exitWhenDone */); mDeleteHelper.setDeleteNotificationListener(null); mDeleteHelper.delete(mStartMillis, mEndMillis, mEventId, -7, null); deleted = true; } try { Thread.sleep(300); } catch (InterruptedException e) { throw new RuntimeException(e); } if (EditEventHelper.canModifyEvent(mModel) || EditEventHelper.canRespond(mModel)) { if (mView != null && mView.prepareForSave()) { if (mModification == Utils.MODIFY_UNINITIALIZED) { Loading Loading @@ -954,6 +975,12 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor mModification = Utils.MODIFY_ALL; } if (deleted) { mHelper.saveEvent(mModel, mOriginalModel, mModification); Toast.makeText(mActivity, "Event updated", Toast.LENGTH_SHORT).show(); return; } if ((mCode & Utils.DONE_SAVE) != 0 && mModel != null && (EditEventHelper.canRespond(mModel) || EditEventHelper.canModifyEvent(mModel)) Loading @@ -961,6 +988,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor && !isEmptyNewEvent() && mModel.normalizeReminders() && mHelper.saveEvent(mModel, mOriginalModel, mModification)) { Logger.getAnonymousLogger().log(Level.INFO, "Event after save: " + new Gson().toJson(mModel)); int stringResource; if (!mModel.mAttendeesList.isEmpty()) { if (mModel.mUri != null) { Loading