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

Commit 54a6394c authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Accept the calendar name in addition to the owner as a calendar filter." into nyc-dev

parents a8574a1d a9864d23
Loading
Loading
Loading
Loading
+18 −57
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public class CalendarTracker {
            Instances.TITLE,
            Instances.VISIBLE,
            Instances.EVENT_ID,
            Instances.CALENDAR_DISPLAY_NAME,
            Instances.OWNER_ACCOUNT,
            Instances.CALENDAR_ID,
            Instances.AVAILABILITY,
@@ -87,49 +88,6 @@ public class CalendarTracker {
        pw.print(prefix); pw.print("u="); pw.println(mUserContext.getUserId());
    }

    public void dumpContent(Uri uri) {
        Log.d(TAG, "dumpContent: " + uri);
        final Cursor cursor = mUserContext.getContentResolver().query(uri, null, null, null, null);
        try {
            int r = 0;
            while (cursor.moveToNext()) {
                Log.d(TAG, "Row " + (++r) + ": id="
                        + cursor.getInt(cursor.getColumnIndex(BaseColumns._ID)));
                for (int i = 0; i < cursor.getColumnCount(); i++) {
                    final String name = cursor.getColumnName(i);
                    final int type = cursor.getType(i);
                    Object o = null;
                    String typeName = null;
                    switch (type) {
                        case Cursor.FIELD_TYPE_INTEGER:
                            o = cursor.getLong(i);
                            typeName = "INTEGER";
                            break;
                        case Cursor.FIELD_TYPE_STRING:
                            o = cursor.getString(i);
                            typeName = "STRING";
                            break;
                        case Cursor.FIELD_TYPE_NULL:
                            o = null;
                            typeName = "NULL";
                            break;
                        default:
                            throw new UnsupportedOperationException("type: " + type);
                    }
                    if (name.equals(BaseColumns._ID)
                            || name.toLowerCase().contains("sync")
                            || o == null) {
                        continue;
                    }
                    Log.d(TAG, "  " + name + "(" + typeName + ")=" + o);
                }
            }
            Log.d(TAG, "  " + uri + " " + r + " rows");
        } finally {
            cursor.close();
        }
    }

    private ArraySet<Long> getPrimaryCalendars() {
        final long start = System.currentTimeMillis();
        final ArraySet<Long> rt = new ArraySet<>();
@@ -170,18 +128,21 @@ public class CalendarTracker {
                final String title = cursor.getString(2);
                final boolean calendarVisible = cursor.getInt(3) == 1;
                final int eventId = cursor.getInt(4);
                final String owner = cursor.getString(5);
                final long calendarId = cursor.getLong(6);
                final int availability = cursor.getInt(7);
                final String name = cursor.getString(5);
                final String owner = cursor.getString(6);
                final long calendarId = cursor.getLong(7);
                final int availability = cursor.getInt(8);
                final boolean calendarPrimary = primaryCalendars.contains(calendarId);
                if (DEBUG) Log.d(TAG, String.format("%s %s-%s v=%s a=%s eid=%s o=%s cid=%s p=%s",
                if (DEBUG) Log.d(TAG, String.format(
                        "%s %s-%s v=%s a=%s eid=%s n=%s o=%s cid=%s p=%s",
                        title,
                        new Date(begin), new Date(end), calendarVisible,
                        availabilityToString(availability), eventId, owner, calendarId,
                        availabilityToString(availability), eventId, name, owner, calendarId,
                        calendarPrimary));
                final boolean meetsTime = time >= begin && time < end;
                final boolean meetsCalendar = calendarVisible && calendarPrimary
                        && (filter.calendar == null || Objects.equals(filter.calendar, owner));
                        && (filter.calendar == null || Objects.equals(filter.calendar, owner)
                        || Objects.equals(filter.calendar, name));
                final boolean meetsAvailability = availability != Instances.AVAILABILITY_FREE;
                if (meetsCalendar && meetsAvailability) {
                    if (DEBUG) Log.d(TAG, "  MEETS CALENDAR & AVAILABILITY");