Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 306bf1d4 authored by Hasib Prince's avatar Hasib Prince
Browse files

poc of move event to another calendar

parent 7b788f14
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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'
+0 −1
Original line number Diff line number Diff line
@@ -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" />
+23 −2
Original line number Diff line number Diff line
@@ -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)
@@ -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();
+17 −5
Original line number Diff line number Diff line
@@ -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;
@@ -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) {
@@ -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) {
@@ -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);
@@ -2586,4 +2597,5 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
            }
        }
    }

}
+28 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;

@@ -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);

@@ -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) {
@@ -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))
@@ -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