Search in sources :

Example 1 with CalendarEventModel

use of com.android.calendar.CalendarEventModel in project Etar-Calendar by Etar-Group.

the class EditEventFragment method onAttach.

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mContext = (AppCompatActivity) activity;
    mHelper = new EditEventHelper(activity, null);
    mHandler = new QueryHandler(activity.getContentResolver());
    mModel = new CalendarEventModel(activity, mIntent);
    mInputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    mUseCustomActionBar = !Utils.getConfigBool(mContext, R.bool.multiple_pane_config);
}
Also used : AsyncQueryHandler(android.content.AsyncQueryHandler) CalendarEventModel(com.android.calendar.CalendarEventModel)

Example 2 with CalendarEventModel

use of com.android.calendar.CalendarEventModel in project Etar-Calendar by Etar-Group.

the class EditEventHelperTest method testAddRecurrenceRule.

@Smoke
@SmallTest
public void testAddRecurrenceRule() {
    mActivity = buildTestContext();
    mHelper = new EditEventHelper(mActivity, null);
    mValues = new ContentValues();
    mExpectedValues = new ContentValues();
    mModel1 = new CalendarEventModel();
    mExpectedValues.put(Events.RRULE, "Weekly, Monday");
    mExpectedValues.put(Events.DURATION, "P60S");
    mExpectedValues.put(Events.DTEND, (Long) null);
    mModel1.mRrule = "Weekly, Monday";
    mModel1.mStart = 1;
    mModel1.mEnd = 60001;
    mModel1.mAllDay = false;
    mHelper.addRecurrenceRule(mValues, mModel1);
    assertEquals(mExpectedValues, mValues);
    mExpectedValues.put(Events.DURATION, "P1D");
    mModel1.mAllDay = true;
    mValues.clear();
    mHelper.addRecurrenceRule(mValues, mModel1);
    assertEquals(mExpectedValues, mValues);
}
Also used : ContentValues(android.content.ContentValues) CalendarEventModel(com.android.calendar.CalendarEventModel) SmallTest(android.test.suitebuilder.annotation.SmallTest) Smoke(android.test.suitebuilder.annotation.Smoke)

Example 3 with CalendarEventModel

use of com.android.calendar.CalendarEventModel in project Etar-Calendar by Etar-Group.

the class EditEventView method prepareReminders.

/**
     * Prepares the reminder UI elements.
     * <p>
     * (Re-)loads the minutes / methods lists from the XML assets, adds/removes items as
     * needed for the current set of reminders and calendar properties, and then creates UI
     * elements.
     */
private void prepareReminders() {
    CalendarEventModel model = mModel;
    Resources r = mActivity.getResources();
    // Load the labels and corresponding numeric values for the minutes and methods lists
    // from the assets.  If we're switching calendars, we need to clear and re-populate the
    // lists (which may have elements added and removed based on calendar properties).  This
    // is mostly relevant for "methods", since we shouldn't have any "minutes" values in a
    // new event that aren't in the default set.
    mReminderMinuteValues = loadIntegerArray(r, R.array.reminder_minutes_values);
    mReminderMinuteLabels = loadStringArray(r, R.array.reminder_minutes_labels);
    mReminderMethodValues = loadIntegerArray(r, R.array.reminder_methods_values);
    mReminderMethodLabels = loadStringArray(r, R.array.reminder_methods_labels);
    // a new event, mCalendarAllowedReminders may not be set the first time we're called.
    if (mModel.mCalendarAllowedReminders != null) {
        EventViewUtils.reduceMethodList(mReminderMethodValues, mReminderMethodLabels, mModel.mCalendarAllowedReminders);
    }
    int numReminders = 0;
    if (model.mHasAlarm) {
        ArrayList<ReminderEntry> reminders = model.mReminders;
        numReminders = reminders.size();
        // Insert any minute values that aren't represented in the minutes list.
        for (ReminderEntry re : reminders) {
            if (mReminderMethodValues.contains(re.getMethod())) {
                EventViewUtils.addMinutesToList(mActivity, mReminderMinuteValues, mReminderMinuteLabels, re.getMinutes());
            }
        }
        // Create a UI element for each reminder.  We display all of the reminders we get
        // from the provider, even if the count exceeds the calendar maximum.  (Also, for
        // a new event, we won't have a maxReminders value available.)
        mUnsupportedReminders.clear();
        for (ReminderEntry re : reminders) {
            if (mReminderMethodValues.contains(re.getMethod()) || re.getMethod() == Reminders.METHOD_DEFAULT) {
                EventViewUtils.addReminder(mActivity, mScrollView, this, mReminderItems, mReminderMinuteValues, mReminderMinuteLabels, mReminderMethodValues, mReminderMethodLabels, re, Integer.MAX_VALUE, null);
            } else {
                // TODO figure out a way to display unsupported reminders
                mUnsupportedReminders.add(re);
            }
        }
    }
    updateRemindersVisibility(numReminders);
    EventViewUtils.updateAddReminderButton(mView, mReminderItems, mModel.mCalendarMaxReminders);
}
Also used : ReminderEntry(com.android.calendar.CalendarEventModel.ReminderEntry) CalendarEventModel(com.android.calendar.CalendarEventModel) Resources(android.content.res.Resources)

Example 4 with CalendarEventModel

use of com.android.calendar.CalendarEventModel in project Etar-Calendar by Etar-Group.

the class CreateEventDialogFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle args) {
    super.onActivityCreated(args);
    final Context context = getActivity();
    mController = CalendarController.getInstance(getActivity());
    mEditEventHelper = new EditEventHelper(context);
    mModel = new CalendarEventModel(context);
    mService = new CalendarQueryService(context);
    mService.startQuery(TOKEN_CALENDARS, null, Calendars.CONTENT_URI, EditEventHelper.CALENDARS_PROJECTION, EditEventHelper.CALENDARS_WHERE_WRITEABLE_VISIBLE, null, null);
}
Also used : Context(android.content.Context) CalendarEventModel(com.android.calendar.CalendarEventModel)

Example 5 with CalendarEventModel

use of com.android.calendar.CalendarEventModel in project Etar-Calendar by Etar-Group.

the class EditEventHelperTest method testUpdateRecurrenceRule.

@Smoke
@SmallTest
public void testUpdateRecurrenceRule() {
    int selection = EditEventHelper.DOES_NOT_REPEAT;
    int weekStart = Calendar.SUNDAY;
    mModel1 = new CalendarEventModel();
    mModel1.mTimezone = Time.TIMEZONE_UTC;
    // Fri, April 30th ~ 3:17PM
    mModel1.mStart = 1272665741000L;
    mModel1.mRrule = "This should go away";
    EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
    assertNull(mModel1.mRrule);
    mModel1.mRrule = "This shouldn't change";
    selection = EditEventHelper.REPEATS_CUSTOM;
    EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
    assertEquals("This shouldn't change", mModel1.mRrule);
    selection = EditEventHelper.REPEATS_DAILY;
    EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
    assertEquals("FREQ=DAILY;WKST=SU", mModel1.mRrule);
    selection = EditEventHelper.REPEATS_EVERY_WEEKDAY;
    EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
    assertEquals("FREQ=WEEKLY;WKST=SU;BYDAY=MO,TU,WE,TH,FR", mModel1.mRrule);
    selection = EditEventHelper.REPEATS_WEEKLY_ON_DAY;
    EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
    assertEquals("FREQ=WEEKLY;WKST=SU;BYDAY=FR", mModel1.mRrule);
    selection = EditEventHelper.REPEATS_MONTHLY_ON_DAY;
    EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
    assertEquals("FREQ=MONTHLY;WKST=SU;BYMONTHDAY=30", mModel1.mRrule);
    selection = EditEventHelper.REPEATS_MONTHLY_ON_DAY_COUNT;
    EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
    assertEquals("FREQ=MONTHLY;WKST=SU;BYDAY=-1FR", mModel1.mRrule);
    selection = EditEventHelper.REPEATS_YEARLY;
    EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
    assertEquals("FREQ=YEARLY;WKST=SU", mModel1.mRrule);
}
Also used : CalendarEventModel(com.android.calendar.CalendarEventModel) SmallTest(android.test.suitebuilder.annotation.SmallTest) Smoke(android.test.suitebuilder.annotation.Smoke)

Aggregations

CalendarEventModel (com.android.calendar.CalendarEventModel)9 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 Smoke (android.test.suitebuilder.annotation.Smoke)5 AsyncQueryHandler (android.content.AsyncQueryHandler)1 ContentValues (android.content.ContentValues)1 Context (android.content.Context)1 Resources (android.content.res.Resources)1 MatrixCursor (android.database.MatrixCursor)1 ReminderEntry (com.android.calendar.CalendarEventModel.ReminderEntry)1