mirror of https://github.com/M66B/FairEmail.git
Calendar helper: refactoring
This commit is contained in:
parent
f2159ef9c3
commit
69ded38d17
|
@ -70,7 +70,7 @@ public class CalendarHelper {
|
|||
return Helper.getTimeInstance(context, SimpleDateFormat.SHORT).format(cal.getTime());
|
||||
}
|
||||
|
||||
static void insert(Context context, ICalendar icalendar, VEvent event,
|
||||
static void insert(Context context, ICalendar icalendar, VEvent event, int status,
|
||||
String selectedAccount, String selectedName, EntityMessage message) {
|
||||
|
||||
String organizer = (event.getOrganizer() == null ? null : event.getOrganizer().getEmail());
|
||||
|
@ -133,7 +133,7 @@ public class CalendarHelper {
|
|||
values.put(CalendarContract.Events.DESCRIPTION, description);
|
||||
if (!TextUtils.isEmpty(location))
|
||||
values.put(CalendarContract.Events.EVENT_LOCATION, location);
|
||||
values.put(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_TENTATIVE);
|
||||
values.put(CalendarContract.Events.STATUS, status);
|
||||
|
||||
Uri uri = resolver.insert(CalendarContract.Events.CONTENT_URI, values);
|
||||
long eventId = Long.parseLong(uri.getLastPathSegment());
|
||||
|
@ -146,7 +146,8 @@ public class CalendarHelper {
|
|||
" end=" + new Date(end.getTime()) +
|
||||
" rrule=" + rrule +
|
||||
" summary=" + summary +
|
||||
" location=" + location);
|
||||
" location=" + location +
|
||||
" status=" + status);
|
||||
|
||||
for (Attendee a : event.getAttendees())
|
||||
try {
|
||||
|
@ -155,7 +156,7 @@ public class CalendarHelper {
|
|||
String role = (a.getRole() == null ? null : a.getRole().getValue());
|
||||
String level = (a.getParticipationLevel() == null ? null
|
||||
: a.getParticipationLevel().getValue(icalendar.getVersion()));
|
||||
String status = (a.getParticipationStatus() == null ? null : a.getParticipationStatus().getValue());
|
||||
String pstatus = (a.getParticipationStatus() == null ? null : a.getParticipationStatus().getValue());
|
||||
|
||||
ContentValues avalues = new ContentValues();
|
||||
|
||||
|
@ -175,13 +176,13 @@ public class CalendarHelper {
|
|||
else if ("REQUEST".equals(level) || "OPT-PARTICIPANT".equals(level))
|
||||
avalues.put(CalendarContract.Attendees.ATTENDEE_TYPE, CalendarContract.Attendees.TYPE_OPTIONAL);
|
||||
|
||||
if ("ACCEPTED".equals(status) || "CONFIRMED".equals(status))
|
||||
if ("ACCEPTED".equals(pstatus) || "CONFIRMED".equals(pstatus))
|
||||
avalues.put(CalendarContract.Attendees.ATTENDEE_STATUS, CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED);
|
||||
else if ("DECLINED".equals(status))
|
||||
else if ("DECLINED".equals(pstatus))
|
||||
avalues.put(CalendarContract.Attendees.ATTENDEE_STATUS, CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED);
|
||||
else if ("TENTATIVE".equals(status))
|
||||
else if ("TENTATIVE".equals(pstatus))
|
||||
avalues.put(CalendarContract.Attendees.ATTENDEE_STATUS, CalendarContract.Attendees.ATTENDEE_STATUS_TENTATIVE);
|
||||
else if ("NEEDS-ACTION".equals(status))
|
||||
else if ("NEEDS-ACTION".equals(pstatus))
|
||||
avalues.put(CalendarContract.Attendees.ATTENDEE_STATUS, CalendarContract.Attendees.ATTENDEE_STATUS_NONE);
|
||||
|
||||
avalues.put(CalendarContract.Attendees.EVENT_ID, eventId);
|
||||
|
@ -194,7 +195,7 @@ public class CalendarHelper {
|
|||
" name=" + name +
|
||||
" role=" + role +
|
||||
" level=" + level +
|
||||
" status=" + status);
|
||||
" status=" + pstatus);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.content.SharedPreferences;
|
|||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.CalendarContract;
|
||||
import android.system.ErrnoException;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
|
@ -4091,6 +4092,7 @@ public class MessageHelper {
|
|||
}
|
||||
|
||||
CalendarHelper.insert(context, icalendar, event,
|
||||
CalendarContract.Events.STATUS_TENTATIVE,
|
||||
selectedAccount, selectedName, message);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
|
|
Loading…
Reference in New Issue