Java 类android.provider.CalendarContract.Attendees 实例源码

项目:Calendar_lunar    文件:CalendarController.java   
public  int getResponse() {
    if (eventType != EventType.VIEW_EVENT) {
        Log.wtf(TAG, "illegal call to getResponse , wrong event type " + eventType);
        return Attendees.ATTENDEE_STATUS_NONE;
    }

    int response = (int)(extraLong & ATTENTEE_STATUS_MASK);
    switch (response) {
        case ATTENDEE_STATUS_NONE_MASK:
            return Attendees.ATTENDEE_STATUS_NONE;
        case ATTENDEE_STATUS_ACCEPTED_MASK:
            return Attendees.ATTENDEE_STATUS_ACCEPTED;
        case ATTENDEE_STATUS_DECLINED_MASK:
            return Attendees.ATTENDEE_STATUS_DECLINED;
        case ATTENDEE_STATUS_TENTATIVE_MASK:
            return Attendees.ATTENDEE_STATUS_TENTATIVE;
        default:
            Log.wtf(TAG,"Unknown attendee response " + response);
    }
    return ATTENDEE_STATUS_NONE_MASK;
}
项目:Calendar_lunar    文件:CalendarController.java   
public static long buildViewExtraLong(int response, boolean allDay) {
    long extra = allDay ? ALL_DAY_MASK : 0;

    switch (response) {
        case Attendees.ATTENDEE_STATUS_NONE:
            extra |= ATTENDEE_STATUS_NONE_MASK;
            break;
        case Attendees.ATTENDEE_STATUS_ACCEPTED:
            extra |= ATTENDEE_STATUS_ACCEPTED_MASK;
            break;
        case Attendees.ATTENDEE_STATUS_DECLINED:
            extra |= ATTENDEE_STATUS_DECLINED_MASK;
            break;
        case Attendees.ATTENDEE_STATUS_TENTATIVE:
            extra |= ATTENDEE_STATUS_TENTATIVE_MASK;
            break;
        default:
            Log.wtf(TAG,"Unknown attendee response " + response);
            extra |= ATTENDEE_STATUS_NONE_MASK;
            break;
    }
    return extra;
}
项目:Calendar_lunar    文件:AllInOneActivity.java   
private long parseViewAction(final Intent intent) {
    long timeMillis = -1;
    Uri data = intent.getData();
    if (data != null && data.isHierarchical()) {
        List<String> path = data.getPathSegments();
        if (path.size() == 2 && path.get(0).equals("events")) {
            try {
                mViewEventId = Long.valueOf(data.getLastPathSegment());
                if (mViewEventId != -1) {
                    mIntentEventStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0);
                    mIntentEventEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0);
                    mIntentAttendeeResponse = intent.getIntExtra(
                            ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_NONE);
                    mIntentAllDay = intent.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false);
                    timeMillis = mIntentEventStartMillis;
                }
            } catch (NumberFormatException e) {
                // Ignore if mViewEventId can't be parsed
            }
        }
    }
    return timeMillis;
}
项目:Calendar_lunar    文件:Event.java   
public static final Event newInstance() {
    Event e = new Event();

    e.id = 0;
    e.title = null;
    e.color = 0;
    e.location = null;
    e.allDay = false;
    e.startDay = 0;
    e.endDay = 0;
    e.startTime = 0;
    e.endTime = 0;
    e.startMillis = 0;
    e.endMillis = 0;
    e.hasAlarm = false;
    e.isRepeating = false;
    e.selfAttendeeStatus = Attendees.ATTENDEE_STATUS_NONE;

    return e;
}
项目:Calendar_lunar    文件:EventInfoFragment.java   
private void updateResponse(long eventId, long attendeeId, int status) {
    // Update the attendee status in the attendees table. the provider
    // takes care of updating the self attendance status.
    ContentValues values = new ContentValues();

    if (!TextUtils.isEmpty(mCalendarOwnerAccount)) {
        values.put(Attendees.ATTENDEE_EMAIL, mCalendarOwnerAccount);
    }
    values.put(Attendees.ATTENDEE_STATUS, status);
    values.put(Attendees.EVENT_ID, eventId);

    Uri uri = ContentUris.withAppendedId(Attendees.CONTENT_URI, attendeeId);

    mHandler.startUpdate(mHandler.getNextToken(), null, uri, values, null,
            null, Utils.UNDO_DELAY);
}
项目:Calendar_lunar    文件:EventInfoFragment.java   
public static int getResponseFromButtonId(int buttonId) {
    int response;
    switch (buttonId) {
    case R.id.response_yes:
        response = Attendees.ATTENDEE_STATUS_ACCEPTED;
        break;
    case R.id.response_maybe:
        response = Attendees.ATTENDEE_STATUS_TENTATIVE;
        break;
    case R.id.response_no:
        response = Attendees.ATTENDEE_STATUS_DECLINED;
        break;
    default:
        response = Attendees.ATTENDEE_STATUS_NONE;
    }
    return response;
}
项目:Calendar_lunar    文件:EventInfoFragment.java   
public static int findButtonIdForResponse(int response) {
    int buttonId;
    switch (response) {
    case Attendees.ATTENDEE_STATUS_ACCEPTED:
        buttonId = R.id.response_yes;
        break;
    case Attendees.ATTENDEE_STATUS_TENTATIVE:
        buttonId = R.id.response_maybe;
        break;
    case Attendees.ATTENDEE_STATUS_DECLINED:
        buttonId = R.id.response_no;
        break;
    default:
        buttonId = -1;
    }
    return buttonId;
}
项目:siiMobilityAppKit    文件:CalendarProviderAccessor.java   
@Override
 protected EnumMap<KeyIndex, String> initContentProviderKeys() {
   EnumMap<KeyIndex, String> keys = new EnumMap<KeyIndex, String>(
           KeyIndex.class);
   keys.put(KeyIndex.CALENDARS_ID, Calendars._ID);
   keys.put(KeyIndex.CALENDARS_NAME, Calendars.NAME);
keys.put(KeyIndex.CALENDARS_DISPLAY_NAME, Calendars.CALENDAR_DISPLAY_NAME);
   keys.put(KeyIndex.CALENDARS_VISIBLE, Calendars.VISIBLE);
   keys.put(KeyIndex.EVENTS_ID, Events._ID);
   keys.put(KeyIndex.EVENTS_CALENDAR_ID, Events.CALENDAR_ID);
   keys.put(KeyIndex.EVENTS_DESCRIPTION, Events.DESCRIPTION);
   keys.put(KeyIndex.EVENTS_LOCATION, Events.EVENT_LOCATION);
   keys.put(KeyIndex.EVENTS_SUMMARY, Events.TITLE);
   keys.put(KeyIndex.EVENTS_START, Events.DTSTART);
   keys.put(KeyIndex.EVENTS_END, Events.DTEND);
   keys.put(KeyIndex.EVENTS_RRULE, Events.RRULE);
   keys.put(KeyIndex.EVENTS_ALL_DAY, Events.ALL_DAY);
   keys.put(KeyIndex.INSTANCES_ID, Instances._ID);
   keys.put(KeyIndex.INSTANCES_EVENT_ID, Instances.EVENT_ID);
   keys.put(KeyIndex.INSTANCES_BEGIN, Instances.BEGIN);
   keys.put(KeyIndex.INSTANCES_END, Instances.END);
   keys.put(KeyIndex.ATTENDEES_ID, Attendees._ID);
   keys.put(KeyIndex.ATTENDEES_EVENT_ID, Attendees.EVENT_ID);
   keys.put(KeyIndex.ATTENDEES_NAME, Attendees.ATTENDEE_NAME);
   keys.put(KeyIndex.ATTENDEES_EMAIL, Attendees.ATTENDEE_EMAIL);
   keys.put(KeyIndex.ATTENDEES_STATUS, Attendees.ATTENDEE_STATUS);
   return keys;
 }
项目:siiMobilityAppKit    文件:CalendarProviderAccessor.java   
@Override
protected Cursor queryAttendees(String[] projection, String selection,
                                String[] selectionArgs, String sortOrder) {
  return this.cordova.getActivity().getContentResolver().query(
          Attendees.CONTENT_URI, projection, selection, selectionArgs,
          sortOrder);
}
项目:siiMobilityAppKit    文件:CalendarProviderAccessor.java   
@Override
 protected EnumMap<KeyIndex, String> initContentProviderKeys() {
   EnumMap<KeyIndex, String> keys = new EnumMap<KeyIndex, String>(
           KeyIndex.class);
   keys.put(KeyIndex.CALENDARS_ID, Calendars._ID);
   keys.put(KeyIndex.CALENDARS_NAME, Calendars.NAME);
keys.put(KeyIndex.CALENDARS_DISPLAY_NAME, Calendars.CALENDAR_DISPLAY_NAME);
   keys.put(KeyIndex.CALENDARS_VISIBLE, Calendars.VISIBLE);
   keys.put(KeyIndex.EVENTS_ID, Events._ID);
   keys.put(KeyIndex.EVENTS_CALENDAR_ID, Events.CALENDAR_ID);
   keys.put(KeyIndex.EVENTS_DESCRIPTION, Events.DESCRIPTION);
   keys.put(KeyIndex.EVENTS_LOCATION, Events.EVENT_LOCATION);
   keys.put(KeyIndex.EVENTS_SUMMARY, Events.TITLE);
   keys.put(KeyIndex.EVENTS_START, Events.DTSTART);
   keys.put(KeyIndex.EVENTS_END, Events.DTEND);
   keys.put(KeyIndex.EVENTS_RRULE, Events.RRULE);
   keys.put(KeyIndex.EVENTS_ALL_DAY, Events.ALL_DAY);
   keys.put(KeyIndex.INSTANCES_ID, Instances._ID);
   keys.put(KeyIndex.INSTANCES_EVENT_ID, Instances.EVENT_ID);
   keys.put(KeyIndex.INSTANCES_BEGIN, Instances.BEGIN);
   keys.put(KeyIndex.INSTANCES_END, Instances.END);
   keys.put(KeyIndex.ATTENDEES_ID, Attendees._ID);
   keys.put(KeyIndex.ATTENDEES_EVENT_ID, Attendees.EVENT_ID);
   keys.put(KeyIndex.ATTENDEES_NAME, Attendees.ATTENDEE_NAME);
   keys.put(KeyIndex.ATTENDEES_EMAIL, Attendees.ATTENDEE_EMAIL);
   keys.put(KeyIndex.ATTENDEES_STATUS, Attendees.ATTENDEE_STATUS);
   return keys;
 }
项目:siiMobilityAppKit    文件:CalendarProviderAccessor.java   
@Override
protected Cursor queryAttendees(String[] projection, String selection,
                                String[] selectionArgs, String sortOrder) {
  return this.cordova.getActivity().getContentResolver().query(
          Attendees.CONTENT_URI, projection, selection, selectionArgs,
          sortOrder);
}
项目:medicineReminder    文件:CalendarProviderAccessor.java   
@Override
protected EnumMap<KeyIndex, String> initContentProviderKeys() {
  EnumMap<KeyIndex, String> keys = new EnumMap<KeyIndex, String>(
      KeyIndex.class);
  keys.put(KeyIndex.CALENDARS_ID, Calendars._ID);
  keys.put(KeyIndex.CALENDARS_NAME, Calendars.NAME);
  keys.put(KeyIndex.CALENDARS_VISIBLE, Calendars.VISIBLE);
  keys.put(KeyIndex.EVENTS_ID, Events._ID);
  keys.put(KeyIndex.EVENTS_CALENDAR_ID, Events.CALENDAR_ID);
  keys.put(KeyIndex.EVENTS_DESCRIPTION, Events.DESCRIPTION);
  keys.put(KeyIndex.EVENTS_LOCATION, Events.EVENT_LOCATION);
  keys.put(KeyIndex.EVENTS_SUMMARY, Events.TITLE);
  keys.put(KeyIndex.EVENTS_START, Events.DTSTART);
  keys.put(KeyIndex.EVENTS_END, Events.DTEND);
  keys.put(KeyIndex.EVENTS_RRULE, Events.RRULE);
  keys.put(KeyIndex.EVENTS_ALL_DAY, Events.ALL_DAY);
  keys.put(KeyIndex.INSTANCES_ID, Instances._ID);
  keys.put(KeyIndex.INSTANCES_EVENT_ID, Instances.EVENT_ID);
  keys.put(KeyIndex.INSTANCES_BEGIN, Instances.BEGIN);
  keys.put(KeyIndex.INSTANCES_END, Instances.END);
  keys.put(KeyIndex.ATTENDEES_ID, Attendees._ID);
  keys.put(KeyIndex.ATTENDEES_EVENT_ID, Attendees.EVENT_ID);
  keys.put(KeyIndex.ATTENDEES_NAME, Attendees.ATTENDEE_NAME);
  keys.put(KeyIndex.ATTENDEES_EMAIL, Attendees.ATTENDEE_EMAIL);
  keys.put(KeyIndex.ATTENDEES_STATUS, Attendees.ATTENDEE_STATUS);
  return keys;
}
项目:medicineReminder    文件:CalendarProviderAccessor.java   
@Override
protected Cursor queryAttendees(String[] projection, String selection,
                                String[] selectionArgs, String sortOrder) {
  return this.cordova.getActivity().getContentResolver().query(
      Attendees.CONTENT_URI, projection, selection, selectionArgs,
      sortOrder);
}
项目:medicineReminder    文件:CalendarProviderAccessor.java   
@Override
protected EnumMap<KeyIndex, String> initContentProviderKeys() {
  EnumMap<KeyIndex, String> keys = new EnumMap<KeyIndex, String>(
      KeyIndex.class);
  keys.put(KeyIndex.CALENDARS_ID, Calendars._ID);
  keys.put(KeyIndex.CALENDARS_NAME, Calendars.NAME);
  keys.put(KeyIndex.CALENDARS_VISIBLE, Calendars.VISIBLE);
  keys.put(KeyIndex.EVENTS_ID, Events._ID);
  keys.put(KeyIndex.EVENTS_CALENDAR_ID, Events.CALENDAR_ID);
  keys.put(KeyIndex.EVENTS_DESCRIPTION, Events.DESCRIPTION);
  keys.put(KeyIndex.EVENTS_LOCATION, Events.EVENT_LOCATION);
  keys.put(KeyIndex.EVENTS_SUMMARY, Events.TITLE);
  keys.put(KeyIndex.EVENTS_START, Events.DTSTART);
  keys.put(KeyIndex.EVENTS_END, Events.DTEND);
  keys.put(KeyIndex.EVENTS_RRULE, Events.RRULE);
  keys.put(KeyIndex.EVENTS_ALL_DAY, Events.ALL_DAY);
  keys.put(KeyIndex.INSTANCES_ID, Instances._ID);
  keys.put(KeyIndex.INSTANCES_EVENT_ID, Instances.EVENT_ID);
  keys.put(KeyIndex.INSTANCES_BEGIN, Instances.BEGIN);
  keys.put(KeyIndex.INSTANCES_END, Instances.END);
  keys.put(KeyIndex.ATTENDEES_ID, Attendees._ID);
  keys.put(KeyIndex.ATTENDEES_EVENT_ID, Attendees.EVENT_ID);
  keys.put(KeyIndex.ATTENDEES_NAME, Attendees.ATTENDEE_NAME);
  keys.put(KeyIndex.ATTENDEES_EMAIL, Attendees.ATTENDEE_EMAIL);
  keys.put(KeyIndex.ATTENDEES_STATUS, Attendees.ATTENDEE_STATUS);
  return keys;
}
项目:medicineReminder    文件:CalendarProviderAccessor.java   
@Override
protected Cursor queryAttendees(String[] projection, String selection,
                                String[] selectionArgs, String sortOrder) {
  return this.cordova.getActivity().getContentResolver().query(
      Attendees.CONTENT_URI, projection, selection, selectionArgs,
      sortOrder);
}
项目:cordova-plugin-calendarsync    文件:EventAccessor.java   
/** Fetch all the attendees of the specified event,
   and put them in a JSONArray.
*/
private JSONArray getAttendees(long eventId) {
    Cursor c = Attendees.query(
        context.getContentResolver(),
        eventId,
        ATTENDEE_COLUMNS
    );

    JSONArray result = Tools.rows2JSONArray(c, ATTENDEE_COLUMNS);
    c.close();
    return result;
}
项目:CucumberSync    文件:LocalCalendar.java   
@Override
protected void addDataRows(Resource resource, long localID, int backrefIdx) {
    Event event = (Event)resource;
    for (Attendee attendee : event.getAttendees())
        pendingOperations.add(buildAttendee(newDataInsertBuilder(Attendees.CONTENT_URI, Attendees.EVENT_ID, localID, backrefIdx), attendee).build());
    for (VAlarm alarm : event.getAlarms())
        pendingOperations.add(buildReminder(newDataInsertBuilder(Reminders.CONTENT_URI, Reminders.EVENT_ID, localID, backrefIdx), alarm).build());
}
项目:CucumberSync    文件:LocalCalendar.java   
@Override
protected void removeDataRows(Resource resource) {
    Event event = (Event)resource;
    pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Attendees.CONTENT_URI))
            .withSelection(Attendees.EVENT_ID + "=?",
            new String[] { String.valueOf(event.getLocalID()) }).build());
    pendingOperations.add(ContentProviderOperation.newDelete(syncAdapterURI(Reminders.CONTENT_URI))
            .withSelection(Reminders.EVENT_ID + "=?",
                    new String[]{String.valueOf(event.getLocalID())}).build());
}
项目:CucumberSync    文件:LocalCalendar.java   
@SuppressLint("InlinedApi")
protected Builder buildAttendee(Builder builder, Attendee attendee) {
    String email = attendee.getEmail();

    String cn = attendee.getCommonName();
    if (cn != null)
        builder = builder.withValue(Attendees.ATTENDEE_NAME, cn);

    int type = Attendees.TYPE_NONE;
    if (attendee.getCalendarUserType() == CalendarUserType.RESOURCE)
        type = Attendees.TYPE_RESOURCE;
    else {
        int relationship;
        if (attendee.getRole() == Role.CHAIR)
            relationship = Attendees.RELATIONSHIP_ORGANIZER;
        else {
            relationship = Attendees.RELATIONSHIP_ATTENDEE;
        }
        builder = builder.withValue(Attendees.ATTENDEE_RELATIONSHIP, relationship);
    }

    int status = Attendees.ATTENDEE_STATUS_NONE;
    ParticipationStatus partStat = attendee.getParticipationStatus();
    if (partStat == null || partStat == ParticipationStatus.NEEDS_ACTION)
        status = Attendees.ATTENDEE_STATUS_INVITED;
    else if (partStat == ParticipationStatus.ACCEPTED)
        status = Attendees.ATTENDEE_STATUS_ACCEPTED;
    else if (partStat == ParticipationStatus.DECLINED)
        status = Attendees.ATTENDEE_STATUS_DECLINED;
    else if (partStat == ParticipationStatus.TENTATIVE)
        status = Attendees.ATTENDEE_STATUS_TENTATIVE;

    return builder
        .withValue(Attendees.ATTENDEE_EMAIL, email)
        .withValue(Attendees.ATTENDEE_TYPE, type)
        .withValue(Attendees.ATTENDEE_STATUS, status);
}
项目:haxsync    文件:CalendarUtil.java   
public static void addAttendee(Context c, long eventID, EventAttendee attendee){
    ContentValues cv = new ContentValues();
    cv.put(Attendees.ATTENDEE_NAME, attendee.getName());
    cv.put(Attendees.ATTENDEE_EMAIL, attendee.getEmail());
    cv.put(Attendees.EVENT_ID, eventID);
    cv.put(Attendees.ATTENDEE_STATUS, attendee.getAttendeeStatus());

    c.getContentResolver().insert(Attendees.CONTENT_URI, cv);
}
项目:haxsync    文件:FacebookUtil.java   
public static int convertStatus(String statusString){
    if (statusString.equals("attending")){
        return Attendees.ATTENDEE_STATUS_ACCEPTED;
    } else if (statusString.equals("unsure")){
        return  Attendees.ATTENDEE_STATUS_TENTATIVE;
    } else if (statusString.equals("declined")){
        return Attendees.ATTENDEE_STATUS_DECLINED;
    } else {
        return Attendees.ATTENDEE_STATUS_INVITED;
    }
}
项目:Calendar_lunar    文件:AgendaListView.java   
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
    if (id != -1) {
        // Switch to the EventInfo view
        EventInfo event = mWindowAdapter.getEventByPosition(position);
        long oldInstanceId = mWindowAdapter.getSelectedInstanceId();
        mWindowAdapter.setSelectedView(v);

        // If events are shown to the side of the agenda list , do nothing
        // when the same
        // event is selected , otherwise show the selected event.

        if (event != null && (oldInstanceId != mWindowAdapter.getSelectedInstanceId() ||
                !mShowEventDetailsWithAgenda)) {
            long startTime = event.begin;
            long endTime = event.end;
            if (event.allDay) {
                startTime = Utils.convertAlldayLocalToUTC(mTime, startTime, mTimeZone);
                endTime = Utils.convertAlldayLocalToUTC(mTime, endTime, mTimeZone);
            }
            mTime.set(startTime);
            CalendarController controller = CalendarController.getInstance(mContext);
            controller.sendEventRelatedEventWithExtra(this, EventType.VIEW_EVENT, event.id,
                    startTime, endTime, 0, 0, CalendarController.EventInfo.buildViewExtraLong(
                            Attendees.ATTENDEE_STATUS_NONE, event.allDay),
                    controller.getTime());
        }
    }
}
项目:Calendar_lunar    文件:AgendaWindowAdapter.java   
private String buildQuerySelection() {
    // Respect the preference to show/hide declined events

    if (mHideDeclined) {
        return Calendars.VISIBLE + "=1 AND "
                + Instances.SELF_ATTENDEE_STATUS + "!="
                + Attendees.ATTENDEE_STATUS_DECLINED;
    } else {
        return Calendars.VISIBLE + "=1";
    }
}
项目:Calendar_lunar    文件:CalendarController.java   
public void sendEventRelatedEvent(Object sender, long eventType, long eventId, long startMillis,
        long endMillis, int x, int y, long selectedMillis) {
    // TODO: pass the real allDay status or at least a status that says we don't know the
    // status and have the receiver query the data.
    // The current use of this method for VIEW_EVENT is by the day view to show an EventInfo
    // so currently the missing allDay status has no effect.
    sendEventRelatedEventWithExtra(sender, eventType, eventId, startMillis, endMillis, x, y,
            EventInfo.buildViewExtraLong(Attendees.ATTENDEE_STATUS_NONE, false),
            selectedMillis);
}
项目:Calendar_lunar    文件:EditEventView.java   
public boolean fillModelFromReadOnlyUi() {
    if (mModel == null || (mCalendarsCursor == null && mModel.mUri == null)) {
        return false;
    }
    mModel.mReminders = EventViewUtils.reminderItemsToReminders(
                mReminderItems, mReminderMinuteValues, mReminderMethodValues);
    mModel.mReminders.addAll(mUnsupportedReminders);
    mModel.normalizeReminders();
    int status = EventInfoFragment.getResponseFromButtonId(
            mResponseRadioGroup.getCheckedRadioButtonId());
    if (status != Attendees.ATTENDEE_STATUS_NONE) {
        mModel.mSelfAttendeeStatus = status;
    }
    return true;
}
项目:Calendar_lunar    文件:MonthByWeekFragment.java   
protected String updateWhere() {
    // TODO fix selection/selection args after b/3206641 is fixed
    String where = WHERE_CALENDARS_VISIBLE;
    if (mHideDeclined || !mShowDetailsInMonth) {
        where += " AND " + Instances.SELF_ATTENDEE_STATUS + "!="
                + Attendees.ATTENDEE_STATUS_DECLINED;
    }
    return where;
}
项目:Calendar_lunar    文件:EventInfoFragment.java   
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mActivity = activity;
    mEditResponseHelper = new EditResponseHelper(activity);

    if (mAttendeeResponseFromIntent != Attendees.ATTENDEE_STATUS_NONE) {
        mEditResponseHelper.setWhichEvents(UPDATE_ALL);
    }
    mHandler = new QueryHandler(activity);
    if (!mIsDialog) {
        setHasOptionsMenu(true);
    }
}
项目:Calendar_lunar    文件:EventInfoFragment.java   
void updateResponse(View view) {
    // we only let the user accept/reject/etc. a meeting if:
    // a) you can edit the event's containing calendar AND
    // b) you're not the organizer and only attendee AND
    // c) organizerCanRespond is enabled for the calendar
    // (if the attendee data has been hidden, the visible number of
    // attendees
    // will be 1 -- the calendar owner's).
    // (there are more cases involved to be 100% accurate, such as
    // paying attention to whether or not an attendee status was
    // included in the feed, but we're currently omitting those corner cases
    // for simplicity).

    // TODO Switch to EditEventHelper.canRespond when this class uses
    // CalendarEventModel.
    if (!mCanModifyCalendar
            || (mHasAttendeeData && mIsOrganizer && mNumOfAttendees <= 1)
            || (mIsOrganizer && !mOwnerCanRespond)) {
        setVisibilityCommon(view, R.id.response_container, View.GONE);
        return;
    }

    setVisibilityCommon(view, R.id.response_container, View.VISIBLE);

    int response;
    if (mUserSetResponse != Attendees.ATTENDEE_STATUS_NONE) {
        response = mUserSetResponse;
    } else if (mAttendeeResponseFromIntent != Attendees.ATTENDEE_STATUS_NONE) {
        response = mAttendeeResponseFromIntent;
    } else {
        response = mOriginalAttendeeResponse;
    }

    int buttonToCheck = findButtonIdForResponse(response);
    RadioGroup radioGroup = (RadioGroup) view
            .findViewById(R.id.response_value);
    radioGroup.check(buttonToCheck); // -1 clear all radio buttons
    radioGroup.setOnCheckedChangeListener(this);
}
项目:Calendar_lunar    文件:EditEventHelperTest.java   
private void addOwnerAttendeeToOps(ArrayList<ContentProviderOperation> expectedOps, int id) {
    addOwnerAttendee();
    ContentProviderOperation.Builder b;
    b = ContentProviderOperation.newInsert(Attendees.CONTENT_URI).withValues(mExpectedValues);
    b.withValueBackReference(Reminders.EVENT_ID, id);
    expectedOps.add(b.build());
}
项目:Calendar_lunar    文件:EditEventHelperTest.java   
private void addOwnerAttendee() {
    mExpectedValues.clear();
    mExpectedValues.put(Attendees.ATTENDEE_EMAIL, mModel1.mOwnerAccount);
    mExpectedValues.put(Attendees.ATTENDEE_RELATIONSHIP, Attendees.RELATIONSHIP_ORGANIZER);
    mExpectedValues.put(Attendees.ATTENDEE_TYPE, Attendees.TYPE_NONE);
    mExpectedValues.put(Attendees.ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_ACCEPTED);
}
项目:CucumberSync    文件:LocalCalendar.java   
@SuppressLint("InlinedApi")
public static void create(Account account, ContentResolver resolver, ServerInfo.ResourceInfo info) throws RemoteException {
    ContentProviderClient client = resolver.acquireContentProviderClient(CalendarContract.AUTHORITY);

    //FIXME - change default colour
    int color = 0xFFC3EA6E;     // fallback: "DAVdroid green"
    if (info.getColor() != null) {
        Pattern p = Pattern.compile("#(\\p{XDigit}{6})(\\p{XDigit}{2})?");
        Matcher m = p.matcher(info.getColor());
        if (m.find()) {
            int color_rgb = Integer.parseInt(m.group(1), 16);
            int color_alpha = m.group(2) != null ? (Integer.parseInt(m.group(2), 16) & 0xFF) : 0xFF;
            color = (color_alpha << 24) | color_rgb;
        }
    }

    ContentValues values = new ContentValues();
    values.put(Calendars.ACCOUNT_NAME, account.name);
    values.put(Calendars.ACCOUNT_TYPE, account.type);
    values.put(Calendars.NAME, info.getCollection());
    values.put(Calendars.CALENDAR_DISPLAY_NAME, info.getTitle());
    values.put(Calendars.CALENDAR_COLOR, color);
    values.put(Calendars.OWNER_ACCOUNT, account.name);
    values.put(Calendars.SYNC_EVENTS, 1);
    values.put(Calendars.VISIBLE, 1);
    values.put(Calendars.ALLOWED_REMINDERS, Reminders.METHOD_ALERT);

    if (info.isReadOnly())
        values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_READ);
    else {
        values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_OWNER);
        values.put(Calendars.CAN_ORGANIZER_RESPOND, 1);
        values.put(Calendars.CAN_MODIFY_TIME_ZONE, 1);
    }

    if (android.os.Build.VERSION.SDK_INT >= 15) {
        values.put(Calendars.ALLOWED_AVAILABILITY, Events.AVAILABILITY_BUSY + "," + Events.AVAILABILITY_FREE + "," + Events.AVAILABILITY_TENTATIVE);
        values.put(Calendars.ALLOWED_ATTENDEE_TYPES, Attendees.TYPE_NONE + "," + Attendees.TYPE_OPTIONAL + "," + Attendees.TYPE_REQUIRED + "," + Attendees.TYPE_RESOURCE);
    }

    if (info.getTimezone() != null)
        values.put(Calendars.CALENDAR_TIME_ZONE, info.getTimezone());

    Log.i(TAG, "Inserting calendar: " + values.toString() + " -> " + calendarsURI(account).toString());
    client.insert(calendarsURI(account), values);
}
项目:CucumberSync    文件:LocalCalendar.java   
void populateAttendees(Event e) throws RemoteException {
    Uri attendeesUri = Attendees.CONTENT_URI.buildUpon()
            .appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
            .build();
    @Cleanup Cursor c = providerClient.query(attendeesUri, new String[]{
            /* 0 */ Attendees.ATTENDEE_EMAIL, Attendees.ATTENDEE_NAME, Attendees.ATTENDEE_TYPE,
            /* 3 */ Attendees.ATTENDEE_RELATIONSHIP, Attendees.STATUS
    }, Attendees.EVENT_ID + "=?", new String[]{String.valueOf(e.getLocalID())}, null);

    while (c != null && c.moveToNext()) {

        Attendee attendee = new Attendee(c.getString(1), c.getString(0));

        // type
        int type = c.getInt(2);
        attendee.setParameter("TYPE", (type == Attendees.TYPE_RESOURCE) ? "RESOURCE" : "NONE");

        // role
        int relationship = c.getInt(3);
        switch (relationship) {
            case Attendees.RELATIONSHIP_ORGANIZER:
                attendee.setRole(Role.CHAIR);
                break;
            case Attendees.RELATIONSHIP_ATTENDEE:
            case Attendees.RELATIONSHIP_PERFORMER:
            case Attendees.RELATIONSHIP_SPEAKER:
                attendee.setRole(Role.ATTENDEE);
                break;
            case Attendees.RELATIONSHIP_NONE:
                //No role
                break;
            default:
                //Ignore
        }

        // status
        switch (c.getInt(4)) {
            case Attendees.ATTENDEE_STATUS_INVITED:
                attendee.setParticipationStatus(ParticipationStatus.NEEDS_ACTION);
                break;
            case Attendees.ATTENDEE_STATUS_ACCEPTED:
                attendee.setParticipationStatus(ParticipationStatus.ACCEPTED);
                break;
            case Attendees.ATTENDEE_STATUS_DECLINED:
                attendee.setParticipationStatus(ParticipationStatus.DECLINED);
                break;
            case Attendees.ATTENDEE_STATUS_TENTATIVE:
                attendee.setParticipationStatus(ParticipationStatus.TENTATIVE);
                break;
            default:
                //Ignore
        }

        e.addAttendee(attendee);
    }
}
项目:haxsync    文件:CalendarUtil.java   
public static void removeAttendees(Context c, long eventID){
    String where = Attendees.EVENT_ID + " = '" + eventID + "'";
    c.getContentResolver().delete(Attendees.CONTENT_URI, where, null);
}
项目:Calendar_lunar    文件:EventInfoActivity.java   
@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Get the info needed for the fragment
    Intent intent = getIntent();
    int attendeeResponse = 0;
    mEventId = 0;
    boolean isDialog = false;

    if (icicle != null) {
        mEventId = icicle.getLong(EventInfoFragment.BUNDLE_KEY_EVENT_ID);
        mStartMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_START_MILLIS);
        mEndMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_END_MILLIS);
        attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE);
        isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG);
    } else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
        mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0);
        mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0);
        attendeeResponse = intent.getIntExtra(ATTENDEE_STATUS,
                Attendees.ATTENDEE_STATUS_NONE);
        Uri data = intent.getData();
        if (data != null) {
            try {
                mEventId = Long.parseLong(data.getLastPathSegment());
            } catch (NumberFormatException e) {
                Log.wtf(TAG,"No event id");
            }
        }
    }

    // If we do not support showing full screen event info in this configuration,
    // close the activity and show the event in AllInOne.
    Resources res = getResources();
    if (!res.getBoolean(R.bool.agenda_show_event_info_full_screen)
            && !res.getBoolean(R.bool.show_event_info_full_screen)) {
        CalendarController.getInstance(this)
                .launchViewEvent(mEventId, mStartMillis, mEndMillis, attendeeResponse);
        finish();
        return;
    }

    setContentView(R.layout.simple_frame_layout);

    // Get the fragment if exists
    mInfoFragment = (EventInfoFragment)
            getFragmentManager().findFragmentById(R.id.main_frame);


    // Remove the application title
    ActionBar bar = getActionBar();
    if (bar != null) {
        bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
    }

    // Create a new fragment if none exists
    if (mInfoFragment == null) {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis,
                attendeeResponse, isDialog, isDialog ?
                        EventInfoFragment.DIALOG_WINDOW_STYLE :
                            EventInfoFragment.FULL_WINDOW_STYLE);
        ft.replace(R.id.main_frame, mInfoFragment);
        ft.commit();
    }
}
项目:Calendar_lunar    文件:AgendaWindowAdapter.java   
public void refresh(Time goToTime, long id, String searchQuery, boolean forced,
        boolean refreshEventInfo) {
    if (searchQuery != null) {
        mSearchQuery = searchQuery;
    }

    if (DEBUGLOG) {
        Log.e(TAG, this + ": refresh " + goToTime.toString() + " id " + id
                + ((searchQuery != null) ? searchQuery : "")
                + (forced ? " forced" : " not forced")
                + (refreshEventInfo ? " refresh event info" : ""));
    }

    int startDay = Time.getJulianDay(goToTime.toMillis(false), goToTime.gmtoff);

    if (!forced && isInRange(startDay, startDay)) {
        // No need to re-query
        if (!mAgendaListView.isEventVisible(goToTime, id)) {
            int gotoPosition = findEventPositionNearestTime(goToTime, id);
            if (gotoPosition > 0) {
                mAgendaListView.setSelectionFromTop(gotoPosition +
                        OFF_BY_ONE_BUG, mStickyHeaderSize);
                if (mListViewScrollState == OnScrollListener.SCROLL_STATE_FLING) {
                    mAgendaListView.smoothScrollBy(0, 0);
                }
                if (refreshEventInfo) {
                    long newInstanceId = findInstanceIdFromPosition(gotoPosition);
                    if (newInstanceId != getSelectedInstanceId()) {
                        setSelectedInstanceId(newInstanceId);
                        new Handler().post(new Runnable() {
                            @Override
                            public void run() {
                                notifyDataSetChanged();
                            }
                        });
                        Cursor tempCursor = getCursorByPosition(gotoPosition);
                        if (tempCursor != null) {
                            int tempCursorPosition = getCursorPositionByPosition(gotoPosition);
                            EventInfo event =
                                    buildEventInfoFromCursor(tempCursor, tempCursorPosition,
                                            false);
                            CalendarController.getInstance(mContext)
                                    .sendEventRelatedEventWithExtra(this, EventType.VIEW_EVENT,
                                            event.id, event.begin, event.end, 0,
                                            0, CalendarController.EventInfo.buildViewExtraLong(
                                                    Attendees.ATTENDEE_STATUS_NONE,
                                                    event.allDay), -1);
                        }
                    }
                }
            }

            Time actualTime = new Time(mTimeZone);
            actualTime.set(goToTime);
            CalendarController.getInstance(mContext).sendEvent(this, EventType.UPDATE_TITLE,
                    actualTime, actualTime, -1, ViewType.CURRENT);
        }
        return;
    }

    // If AllInOneActivity is sending a second GOTO event(in OnResume), ignore it.
    if (!mCleanQueryInitiated || searchQuery != null) {
        // Query for a total of MIN_QUERY_DURATION days
        int endDay = startDay + MIN_QUERY_DURATION;

        mSelectedInstanceId = -1;
        mCleanQueryInitiated = true;
        queueQuery(startDay, endDay, goToTime, searchQuery, QUERY_TYPE_CLEAN, id);

        // Pre-fetch more data to overcome a race condition in AgendaListView.shiftSelection
        // Queuing more data with the goToTime set to the selected time skips the call to
        // shiftSelection on refresh.
        mOlderRequests++;
        queueQuery(0, 0, goToTime, searchQuery, QUERY_TYPE_OLDER, id);
        mNewerRequests++;
        queueQuery(0, 0, goToTime, searchQuery, QUERY_TYPE_NEWER, id);
    }
}
项目:Calendar_lunar    文件:AgendaFragment.java   
private void showEventInfo(EventInfo event, boolean allDay, boolean replaceFragment) {

        // Ignore unknown events
        if (event.id == -1) {
            Log.e(TAG, "showEventInfo, event ID = " + event.id);
            return;
        }

        // Create a fragment to show the event to the side of the agenda list
        if (mShowEventDetailsWithAgenda) {
            FragmentManager fragmentManager = getFragmentManager();
            if (fragmentManager == null) {
                // Got a goto event before the fragment finished attaching,
                // stash the event and handle it later.
                mOnAttachedInfo = event;
                mOnAttachAllDay = allDay;
                return;
            }
            FragmentTransaction ft = fragmentManager.beginTransaction();

            if (allDay) {
                event.startTime.timezone = Time.TIMEZONE_UTC;
                event.endTime.timezone = Time.TIMEZONE_UTC;
            }

            long startMillis = event.startTime.toMillis(true);
            long endMillis = event.endTime.toMillis(true);
            EventInfoFragment fOld =
                    (EventInfoFragment)fragmentManager.findFragmentById(R.id.agenda_event_info);
            if (fOld == null || replaceFragment || fOld.getStartMillis() != startMillis ||
                    fOld.getEndMillis() != endMillis || fOld.getEventId() != event.id) {
                mEventFragment = new EventInfoFragment(mActivity, event.id,
                        event.startTime.toMillis(true), event.endTime.toMillis(true),
                        Attendees.ATTENDEE_STATUS_NONE, false,
                        EventInfoFragment.DIALOG_WINDOW_STYLE);
                ft.replace(R.id.agenda_event_info, mEventFragment);
                mController.registerEventHandler(R.id.agenda_event_info,
                        mEventFragment);
                ft.commit();
            } else {
                fOld.reloadEvents();
            }
        }
//        else {
//            Intent intent = new Intent(Intent.ACTION_VIEW);
//            Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, event.id);
//            intent.setData(eventUri);
//            intent.setClass(getActivity(), AllInOneActivity.class);
//            intent.putExtra(EVENT_BEGIN_TIME, event.startTime != null ? event.startTime
//                    .toMillis(true) : -1);
//            intent.putExtra(EVENT_END_TIME, event.endTime != null ? event.endTime.toMillis(true)
//                    : -1);
//            startActivity(intent);
//        }
    }
项目:Calendar_lunar    文件:Event.java   
/**
 * Loads <i>days</i> days worth of instances starting at <i>startDay</i>.
 */
public static void loadEvents(Context context, ArrayList<Event> events, int startDay, int days,
        int requestId, AtomicInteger sequenceNumber) {

    if (PROFILE) {
        Debug.startMethodTracing("loadEvents");
    }

    Cursor cEvents = null;
    Cursor cAllday = null;

    events.clear();
    try {
        int endDay = startDay + days - 1;

        // We use the byDay instances query to get a list of all events for
        // the days we're interested in.
        // The sort order is: events with an earlier start time occur
        // first and if the start times are the same, then events with
        // a later end time occur first. The later end time is ordered
        // first so that long rectangles in the calendar views appear on
        // the left side.  If the start and end times of two events are
        // the same then we sort alphabetically on the title.  This isn't
        // required for correctness, it just adds a nice touch.

        // Respect the preference to show/hide declined events
        SharedPreferences prefs = GeneralPreferences.getSharedPreferences(context);
        boolean hideDeclined = prefs.getBoolean(GeneralPreferences.KEY_HIDE_DECLINED,
                false);

        String where = EVENTS_WHERE;
        String whereAllday = ALLDAY_WHERE;
        if (hideDeclined) {
            String hideString = " AND " + Instances.SELF_ATTENDEE_STATUS + "!="
                    + Attendees.ATTENDEE_STATUS_DECLINED;
            where += hideString;
            whereAllday += hideString;
        }

        cEvents = instancesQuery(context.getContentResolver(), EVENT_PROJECTION, startDay,
                endDay, where, null, SORT_EVENTS_BY);
        cAllday = instancesQuery(context.getContentResolver(), EVENT_PROJECTION, startDay,
                endDay, whereAllday, null, SORT_ALLDAY_BY);

        // Check if we should return early because there are more recent
        // load requests waiting.
        if (requestId != sequenceNumber.get()) {
            return;
        }

        buildEventsFromCursor(events, cEvents, context, startDay, endDay);
        buildEventsFromCursor(events, cAllday, context, startDay, endDay);

    } finally {
        if (cEvents != null) {
            cEvents.close();
        }
        if (cAllday != null) {
            cAllday.close();
        }
        if (PROFILE) {
            Debug.stopMethodTracing();
        }
    }
}
项目:Calendar_lunar    文件:AlertReceiver.java   
private static Cursor getAttendeesCursor(Context context, long eventId) {
    return context.getContentResolver().query(Attendees.CONTENT_URI,
            ATTENDEES_PROJECTION, ATTENDEES_WHERE, new String[] { Long.toString(eventId) },
            ATTENDEES_SORT_ORDER);
}
项目:Calendar_lunar    文件:AlertReceiver.java   
/**
 * Creates an Intent for emailing the attendees of the event.  Returns null if there
 * are no emailable attendees.
 */
static Intent createEmailIntent(Context context, long eventId, String body) {
    // TODO: Refactor to move query part into Utils.createEmailAttendeeIntent, to
    // be shared with EventInfoFragment.

    // Query for the owner account(s).
    String ownerAccount = null;
    String syncAccount = null;
    String eventTitle = null;
    Cursor eventCursor = getEventCursor(context, eventId);
    try {
        if (eventCursor != null && eventCursor.moveToFirst()) {
            ownerAccount = eventCursor.getString(EVENT_INDEX_OWNER_ACCOUNT);
            syncAccount = eventCursor.getString(EVENT_INDEX_ACCOUNT_NAME);
            eventTitle = eventCursor.getString(EVENT_INDEX_TITLE);
        }
    } finally {
        if (eventCursor != null) {
            eventCursor.close();
        }
    }
    if (TextUtils.isEmpty(eventTitle)) {
        eventTitle = context.getResources().getString(R.string.no_title_label);
    }

    // Query for the attendees.
    List<String> toEmails = new ArrayList<String>();
    List<String> ccEmails = new ArrayList<String>();
    Cursor attendeesCursor = getAttendeesCursor(context, eventId);
    try {
        if (attendeesCursor != null && attendeesCursor.moveToFirst()) {
            do {
                int status = attendeesCursor.getInt(ATTENDEES_INDEX_STATUS);
                String email = attendeesCursor.getString(ATTENDEES_INDEX_EMAIL);
                switch(status) {
                    case Attendees.ATTENDEE_STATUS_DECLINED:
                        addIfEmailable(ccEmails, email, syncAccount);
                        break;
                    default:
                        addIfEmailable(toEmails, email, syncAccount);
                }
            } while (attendeesCursor.moveToNext());
        }
    } finally {
        if (attendeesCursor != null) {
            attendeesCursor.close();
        }
    }

    Intent intent = null;
    if (ownerAccount != null && (toEmails.size() > 0 || ccEmails.size() > 0)) {
        intent = Utils.createEmailAttendeesIntent(context.getResources(), eventTitle, body,
                toEmails, ccEmails, ownerAccount);
    }

    if (intent == null) {
        return null;
    }
    else {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        return intent;
    }
}