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

Commit aac2806e authored by John Spurlock's avatar John Spurlock Committed by Android Git Automerger
Browse files

am 0c9c89a1: am 0bc8afff: Merge "Zen: Remove calendar rule attendance attribute." into mnc-dev

* commit '0c9c89a1':
  Zen: Remove calendar rule attendance attribute.
parents 864e2183 0c9c89a1
Loading
Loading
Loading
Loading
+2 −11
Original line number Diff line number Diff line
@@ -692,7 +692,6 @@ public class ZenModeConfig implements Parcelable {
                .authority(SYSTEM_AUTHORITY)
                .appendPath(EVENT_PATH)
                .appendQueryParameter("calendar", Long.toString(event.calendar))
                .appendQueryParameter("attendance", Integer.toString(event.attendance))
                .appendQueryParameter("reply", Integer.toString(event.reply))
                .build();
    }
@@ -710,22 +709,16 @@ public class ZenModeConfig implements Parcelable {
        if (!isEvent) return null;
        final EventInfo rt = new EventInfo();
        rt.calendar = tryParseLong(conditionId.getQueryParameter("calendar"), 0L);
        rt.attendance = tryParseInt(conditionId.getQueryParameter("attendance"), 0);
        rt.reply = tryParseInt(conditionId.getQueryParameter("reply"), 0);
        return rt;
    }

    public static class EventInfo {
        public static final int ATTENDANCE_REQUIRED_OR_OPTIONAL = 0;
        public static final int ATTENDANCE_REQUIRED = 1;
        public static final int ATTENDANCE_OPTIONAL = 2;

        public static final int REPLY_ANY = 0;
        public static final int REPLY_ANY_EXCEPT_NO = 1;
        public static final int REPLY_ANY_EXCEPT_NO = 0;
        public static final int REPLY_YES_OR_MAYBE = 1;
        public static final int REPLY_YES = 2;

        public long calendar;  // CalendarContract.Calendars._ID, or 0 for any
        public int attendance;
        public int reply;

        @Override
@@ -738,14 +731,12 @@ public class ZenModeConfig implements Parcelable {
            if (!(o instanceof EventInfo)) return false;
            final EventInfo other = (EventInfo) o;
            return calendar == other.calendar
                    && attendance == other.attendance
                    && reply == other.reply;
        }

        public EventInfo copy() {
            final EventInfo rt = new EventInfo();
            rt.calendar = calendar;
            rt.attendance = attendance;
            rt.reply = reply;
            return rt;
        }
+8 −30
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ public class CalendarTracker {
        Attendees.EVENT_ID,
        Attendees.ATTENDEE_EMAIL,
        Attendees.ATTENDEE_STATUS,
        Attendees.ATTENDEE_TYPE,
    };

    private static final String ATTENDEE_SELECTION = Attendees.EVENT_ID + " = ? AND "
@@ -191,16 +190,13 @@ public class CalendarTracker {
                final long rowEventId = cursor.getLong(0);
                final String rowEmail = cursor.getString(1);
                final int status = cursor.getInt(2);
                final int type = cursor.getInt(3);
                final boolean meetsReply = meetsReply(filter.reply, status);
                final boolean meetsAttendance = meetsAttendance(filter.attendance, type);
                if (DEBUG) Log.d(TAG, (DEBUG_ATTENDEES ? String.format(
                        "rowEventId=%s, rowEmail=%s, ", rowEventId, rowEmail) : "") +
                        String.format("status=%s, type=%s, meetsReply=%s, meetsAttendance=%s",
                        attendeeStatusToString(status), attendeeTypeToString(type), meetsReply,
                        meetsAttendance));
                        String.format("status=%s, meetsReply=%s",
                        attendeeStatusToString(status), meetsReply));
                final boolean eventMeets = rowEventId == eventId && Objects.equals(rowEmail, email)
                        && meetsReply && meetsAttendance;
                        && meetsReply;
                rt |= eventMeets;
            }
            return rt;
@@ -232,35 +228,17 @@ public class CalendarTracker {
        }
    }

    private static String attendeeTypeToString(int type) {
        switch (type) {
            case Attendees.TYPE_NONE: return "TYPE_NONE";
            case Attendees.TYPE_REQUIRED: return "TYPE_REQUIRED";
            case Attendees.TYPE_OPTIONAL: return "TYPE_OPTIONAL";
            case Attendees.TYPE_RESOURCE: return "TYPE_RESOURCE";
            default: return "TYPE_" + type;
        }
    }

    private static boolean meetsAttendance(int attendance, int attendeeType) {
        switch (attendance) {
            case EventInfo.ATTENDANCE_OPTIONAL:
                return attendeeType == Attendees.TYPE_OPTIONAL;
            case EventInfo.ATTENDANCE_REQUIRED:
                return attendeeType == Attendees.TYPE_REQUIRED;
            default: // EventInfo.ATTENDANCE_REQUIRED_OR_OPTIONAL
                return true;
        }
    }

    private static boolean meetsReply(int reply, int attendeeStatus) {
        switch (reply) {
            case EventInfo.REPLY_YES:
                return attendeeStatus == Attendees.ATTENDEE_STATUS_ACCEPTED;
            case EventInfo.REPLY_YES_OR_MAYBE:
                return attendeeStatus == Attendees.ATTENDEE_STATUS_ACCEPTED
                        || attendeeStatus == Attendees.ATTENDEE_STATUS_TENTATIVE;
            case EventInfo.REPLY_ANY_EXCEPT_NO:
                return attendeeStatus != Attendees.ATTENDEE_STATUS_DECLINED;
            default: // EventInfo.REPLY_ANY
                return true;
            default:
                return false;
        }
    }