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

Commit 140ebd20 authored by James Kung's avatar James Kung Committed by Android (Google) Code Review
Browse files

Merge "Color/reminder changes preserved from info to edit" into ics-ub-calendar-cream

parents 11457bca 1d1b1e4f
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -1201,14 +1201,7 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
            mActivity.finish();
            return true;
        } else if (itemId == R.id.info_action_edit) {
            Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, mEventId);
            Intent intent = new Intent(Intent.ACTION_EDIT, uri);
            intent.putExtra(EXTRA_EVENT_BEGIN_TIME, mStartMillis);
            intent.putExtra(EXTRA_EVENT_END_TIME, mEndMillis);
            intent.putExtra(EXTRA_EVENT_ALL_DAY, mAllDay);
            intent.setClass(mActivity, EditEventActivity.class);
            intent.putExtra(EVENT_EDIT_ON_LAUNCH, true);
            startActivity(intent);
            doEdit();
            mActivity.finish();
        } else if (itemId == R.id.info_action_delete) {
            mDeleteHelper =
@@ -1408,9 +1401,18 @@ public class EventInfoFragment extends DialogFragment implements OnCheckedChange
        // This ensures that we aren't in the process of closing and have been
        // unattached already
        if (c != null) {
            CalendarController.getInstance(c).sendEventRelatedEvent(
                    this, EventType.EDIT_EVENT, mEventId, mStartMillis, mEndMillis, 0
                    , 0, -1);
            Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, mEventId);
            Intent intent = new Intent(Intent.ACTION_EDIT, uri);
            intent.setClass(mActivity, EditEventActivity.class);
            intent.putExtra(EXTRA_EVENT_BEGIN_TIME, mStartMillis);
            intent.putExtra(EXTRA_EVENT_END_TIME, mEndMillis);
            intent.putExtra(EXTRA_EVENT_ALL_DAY, mAllDay);
            intent.putExtra(EditEventActivity.EXTRA_EVENT_COLOR, mCurrentColor);
            intent.putExtra(EditEventActivity.EXTRA_EVENT_REMINDERS, EventViewUtils
                    .reminderItemsToReminders(mReminderViews, mReminderMinuteValues,
                    mReminderMethodValues));
            intent.putExtra(EVENT_EDIT_ON_LAUNCH, true);
            startActivity(intent);
        }
    }

+21 −1
Original line number Diff line number Diff line
@@ -33,9 +33,12 @@ import android.view.MenuItem;
import com.android.calendar.AbstractCalendarActivity;
import com.android.calendar.CalendarController;
import com.android.calendar.CalendarController.EventInfo;
import com.android.calendar.CalendarEventModel.ReminderEntry;
import com.android.calendar.R;
import com.android.calendar.Utils;

import java.util.ArrayList;

public class EditEventActivity extends AbstractCalendarActivity {
    private static final String TAG = "EditEventActivity";

@@ -43,10 +46,18 @@ public class EditEventActivity extends AbstractCalendarActivity {

    private static final String BUNDLE_KEY_EVENT_ID = "key_event_id";

    public static final String EXTRA_EVENT_COLOR = "event_color";

    public static final String EXTRA_EVENT_REMINDERS = "reminders";

    private static boolean mIsMultipane;

    private EditEventFragment mEditFragment;

    private ArrayList<ReminderEntry> mReminders;

    private int mEventColor;

    private EventInfo mEventInfo;

    @Override
@@ -55,6 +66,8 @@ public class EditEventActivity extends AbstractCalendarActivity {
        setContentView(R.layout.simple_frame_layout);

        mEventInfo = getEventInfoFromIntent(icicle);
        mReminders = getReminderEntriesFromIntent();
        mEventColor = getIntent().getIntExtra(EXTRA_EVENT_COLOR, -1);

        mEditFragment = (EditEventFragment) getFragmentManager().findFragmentById(R.id.main_frame);

@@ -80,7 +93,8 @@ public class EditEventActivity extends AbstractCalendarActivity {
                intent = getIntent();
            }

            mEditFragment = new EditEventFragment(mEventInfo, false, intent);
            mEditFragment = new EditEventFragment(mEventInfo, mReminders, mEventColor,
                    false, intent);

            mEditFragment.mShowModifyDialogOnLaunch = getIntent().getBooleanExtra(
                    CalendarController.EVENT_EDIT_ON_LAUNCH, false);
@@ -92,6 +106,12 @@ public class EditEventActivity extends AbstractCalendarActivity {
        }
    }

    @SuppressWarnings("unchecked")
    private ArrayList<ReminderEntry> getReminderEntriesFromIntent() {
        Intent intent = getIntent();
        return (ArrayList<ReminderEntry>) intent.getSerializableExtra(EXTRA_EVENT_REMINDERS);
    }

    private EventInfo getEventInfoFromIntent(Bundle icicle) {
        EventInfo info = new EventInfo();
        long eventId = -1;
+25 −4
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor

    private final EventInfo mEvent;
    private EventBundle mEventBundle;
    private ArrayList<ReminderEntry> mReminders;
    private int mEventColor;
    private Uri mUri;
    private long mBegin;
    private long mEnd;
@@ -184,7 +186,9 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor
                    mModel.mIsFirstEventInSeries = mBegin == mOriginalModel.mStart;
                    mModel.mStart = mBegin;
                    mModel.mEnd = mEnd;

                    if (mEventColor != -1) {
                        mModel.mEventColor = mEventColor;
                    }
                    eventId = mModel.mId;

                    // TOKEN_ATTENDEES
@@ -202,7 +206,7 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor
                    }

                    // TOKEN_REMINDERS
                    if (mModel.mHasAlarm) {
                    if (mModel.mHasAlarm && mReminders == null) {
                        Uri rUri = Reminders.CONTENT_URI;
                        String[] remArgs = {
                                Long.toString(eventId)
@@ -212,6 +216,10 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor
                                EditEventHelper.REMINDERS_WHERE /* selection */,
                                remArgs /* selection args */, null /* sort order */);
                    } else {
                        Collections.sort(mReminders);
                        mOriginalModel.mReminders = mReminders;
                        mModel.mReminders =
                                (ArrayList<ReminderEntry>) mReminders.clone();
                        setModelIfDone(TOKEN_REMINDERS);
                    }

@@ -395,13 +403,18 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor
    }

    public EditEventFragment() {
        this(null, false, null);
        this(null, null, -1, false, null);
    }

    public EditEventFragment(EventInfo event, boolean readOnly, Intent intent) {
    public EditEventFragment(EventInfo event, ArrayList<ReminderEntry> reminders, int eventColor,
            boolean readOnly, Intent intent) {
        mEvent = event;
        mIsReadOnly = readOnly;
        mIntent = intent;

        mReminders = reminders;
        mEventColor = eventColor;

        setHasOptionsMenu(true);
    }

@@ -435,6 +448,14 @@ public class EditEventFragment extends Fragment implements EventHandler, OnColor
            mEnd = mEventBundle.end;
        }

        if (mReminders != null) {
            mModel.mReminders = mReminders;
        }

        if (mEventColor != -1) {
            mModel.mEventColor = mEventColor;
        }

        if (mBegin <= 0) {
            // use a default value instead
            mBegin = mHelper.constructDefaultStartTime(System.currentTimeMillis());