diff options
| -rw-r--r-- | core/java/android/provider/Calendar.java | 252 |
1 files changed, 190 insertions, 62 deletions
diff --git a/core/java/android/provider/Calendar.java b/core/java/android/provider/Calendar.java index 8459b2da469a..0175d72d2124 100644 --- a/core/java/android/provider/Calendar.java +++ b/core/java/android/provider/Calendar.java @@ -76,64 +76,11 @@ public final class Calendar { */ public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter"; + /** - * Columns from the Calendars table that other tables join into themselves. + * Columns for Sync information used by Calendars and Events tables. */ - public interface CalendarsColumns - { - /** - * The color of the calendar - * <P>Type: INTEGER (color value)</P> - */ - public static final String COLOR = "color"; - - /** - * The level of access that the user has for the calendar - * <P>Type: INTEGER (one of the values below)</P> - */ - public static final String ACCESS_LEVEL = "access_level"; - - /** Cannot access the calendar */ - public static final int NO_ACCESS = 0; - /** Can only see free/busy information about the calendar */ - public static final int FREEBUSY_ACCESS = 100; - /** Can read all event details */ - public static final int READ_ACCESS = 200; - public static final int RESPOND_ACCESS = 300; - public static final int OVERRIDE_ACCESS = 400; - /** Full access to modify the calendar, but not the access control settings */ - public static final int CONTRIBUTOR_ACCESS = 500; - public static final int EDITOR_ACCESS = 600; - /** Full access to the calendar */ - public static final int OWNER_ACCESS = 700; - /** Domain admin */ - public static final int ROOT_ACCESS = 800; - - /** - * Is the calendar selected to be displayed? - * <P>Type: INTEGER (boolean)</P> - */ - public static final String SELECTED = "selected"; - - /** - * The timezone the calendar's events occurs in - * <P>Type: TEXT</P> - */ - public static final String TIMEZONE = "timezone"; - - /** - * If this calendar is in the list of calendars that are selected for - * syncing then "sync_events" is 1, otherwise 0. - * <p>Type: INTEGER (boolean)</p> - */ - public static final String SYNC_EVENTS = "sync_events"; - - /** - * Sync state data. - * <p>Type: String (blob)</p> - */ - public static final String SYNC_STATE = "sync_state"; - + public interface SyncColumns { /** * The account that was used to sync the entry to the device. * <P>Type: TEXT</P> @@ -185,6 +132,12 @@ public final class Calendar { */ public static final String _SYNC_DIRTY = "_sync_dirty"; + } + + /** + * Columns from the Account information used by Calendars and Events tables. + */ + public interface AccountColumns { /** * The name of the account instance to which this row belongs, which when paired with * {@link #ACCOUNT_TYPE} identifies a specific account. @@ -201,9 +154,162 @@ public final class Calendar { } /** + * Columns from the Calendars table that other tables join into themselves. + */ + public interface CalendarsColumns { + /** + * The color of the calendar + * <P>Type: INTEGER (color value)</P> + */ + public static final String COLOR = "color"; + + /** + * The level of access that the user has for the calendar + * <P>Type: INTEGER (one of the values below)</P> + */ + public static final String ACCESS_LEVEL = "access_level"; + + /** Cannot access the calendar */ + public static final int NO_ACCESS = 0; + /** Can only see free/busy information about the calendar */ + public static final int FREEBUSY_ACCESS = 100; + /** Can read all event details */ + public static final int READ_ACCESS = 200; + public static final int RESPOND_ACCESS = 300; + public static final int OVERRIDE_ACCESS = 400; + /** Full access to modify the calendar, but not the access control settings */ + public static final int CONTRIBUTOR_ACCESS = 500; + public static final int EDITOR_ACCESS = 600; + /** Full access to the calendar */ + public static final int OWNER_ACCESS = 700; + /** Domain admin */ + public static final int ROOT_ACCESS = 800; + + /** + * Is the calendar selected to be displayed? + * <P>Type: INTEGER (boolean)</P> + */ + public static final String SELECTED = "selected"; + + /** + * The timezone the calendar's events occurs in + * <P>Type: TEXT</P> + */ + public static final String TIMEZONE = "timezone"; + + /** + * If this calendar is in the list of calendars that are selected for + * syncing then "sync_events" is 1, otherwise 0. + * <p>Type: INTEGER (boolean)</p> + */ + public static final String SYNC_EVENTS = "sync_events"; + + /** + * Sync state data. + * <p>Type: String (blob)</p> + */ + public static final String SYNC_STATE = "sync_state"; + + /** + * Whether the row has been deleted. A deleted row should be ignored. + * <P>Type: INTEGER (boolean)</P> + */ + public static final String DELETED = "deleted"; + } + + /** + * Class that represents a Calendar Entity. There is one entry per calendar. + */ + public static class CalendarsEntity implements BaseColumns, SyncColumns, CalendarsColumns { + + public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + + "/calendar_entities"); + + public static EntityIterator newEntityIterator(Cursor cursor, ContentResolver resolver) { + return new EntityIteratorImpl(cursor, resolver); + } + + public static EntityIterator newEntityIterator(Cursor cursor, + ContentProviderClient provider) { + return new EntityIteratorImpl(cursor, provider); + } + + private static class EntityIteratorImpl extends CursorEntityIterator { + private final ContentResolver mResolver; + private final ContentProviderClient mProvider; + + public EntityIteratorImpl(Cursor cursor, ContentResolver resolver) { + super(cursor); + mResolver = resolver; + mProvider = null; + } + + public EntityIteratorImpl(Cursor cursor, ContentProviderClient provider) { + super(cursor); + mResolver = null; + mProvider = provider; + } + + @Override + public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException { + // we expect the cursor is already at the row we need to read from + final long calendarId = cursor.getLong(cursor.getColumnIndexOrThrow(_ID)); + + // Create the content value + ContentValues cv = new ContentValues(); + cv.put(_ID, calendarId); + + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ACCOUNT); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ACCOUNT_TYPE); + + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_ID); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_VERSION); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_TIME); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_DATA); + DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _SYNC_DIRTY); + DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _SYNC_MARK); + + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.URL); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.SELF_URL); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, + Calendars.EDIT_URL); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, + Calendars.EVENTS_URL); + + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.NAME); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, + Calendars.DISPLAY_NAME); + DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, Calendars.HIDDEN); + DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, Calendars.COLOR); + DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, ACCESS_LEVEL); + DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SELECTED); + DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, SYNC_EVENTS); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.LOCATION); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, TIMEZONE); + DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, + Calendars.OWNER_ACCOUNT); + DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, + Calendars.ORGANIZER_CAN_RESPOND); + + DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED); + + // Create the Entity from the ContentValue + Entity entity = new Entity(cv); + + // Set cursor to next row + cursor.moveToNext(); + + // Return the created Entity + return entity; + } + } + } + + /** * Contains a list of available calendars. */ - public static class Calendars implements BaseColumns, CalendarsColumns + public static class Calendars implements BaseColumns, SyncColumns, AccountColumns, + CalendarsColumns { private static final String WHERE_DELETE_FOR_ACCOUNT = Calendars._SYNC_ACCOUNT + "=?" + " AND " + Calendars._SYNC_ACCOUNT_TYPE + "=?"; @@ -258,6 +364,24 @@ public final class Calendar { public static final String URL = "url"; /** + * The URL for the calendar itself + * <P>Type: TEXT (URL)</P> + */ + public static final String SELF_URL = "selfUrl"; + + /** + * The URL for the calendar to be edited + * <P>Type: TEXT (URL)</P> + */ + public static final String EDIT_URL = "editUrl"; + + /** + * The URL for the calendar events + * <P>Type: TEXT (URL)</P> + */ + public static final String EVENTS_URL = "eventsUrl"; + + /** * The name of the calendar * <P>Type: TEXT</P> */ @@ -296,6 +420,9 @@ public final class Calendar { public static final String ORGANIZER_CAN_RESPOND = "organizerCanRespond"; } + /** + * Columns from the Attendees table that other tables join into themselves. + */ public interface AttendeesColumns { /** @@ -361,8 +488,7 @@ public final class Calendar { /** * Columns from the Events table that other tables join into themselves. */ - public interface EventsColumns - { + public interface EventsColumns { /** * The calendar the event belongs to * <P>Type: INTEGER (foreign key to the Calendars table)</P> @@ -616,7 +742,8 @@ public final class Calendar { /** * Contains one entry per calendar event. Recurring events show up as a single entry. */ - public static final class EventsEntity implements BaseColumns, EventsColumns, CalendarsColumns { + public static final class EventsEntity implements BaseColumns, SyncColumns, AccountColumns, + EventsColumns { /** * The content:// style URL for this table */ @@ -721,7 +848,7 @@ public final class Calendar { DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_DATA); DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _SYNC_DIRTY); DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, _SYNC_VERSION); - DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, DELETED); + DatabaseUtils.cursorIntToContentValuesIfPresent(cursor, cv, EventsColumns.DELETED); DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Calendars.URL); Entity entity = new Entity(cv); @@ -813,7 +940,8 @@ public final class Calendar { /** * Contains one entry per calendar event. Recurring events show up as a single entry. */ - public static final class Events implements BaseColumns, EventsColumns, CalendarsColumns { + public static final class Events implements BaseColumns, SyncColumns, AccountColumns, + EventsColumns { private static final String[] FETCH_ENTRY_COLUMNS = new String[] { Events._SYNC_ACCOUNT, Events._SYNC_ID }; |