Revert "Refactoring"

This reverts commit eb4806ad64.
This commit is contained in:
M66B 2023-10-26 12:50:30 +02:00
parent 958ef7a714
commit 7b9b50da2c
2 changed files with 33 additions and 34 deletions

View File

@ -33,18 +33,16 @@ import androidx.preference.PreferenceManager;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import javax.mail.Address;
import javax.mail.internet.InternetAddress;
import biweekly.ICalVersion;
import biweekly.ICalendar;
import biweekly.component.ICalComponent;
import biweekly.component.Observance;
import biweekly.component.StandardTime;
import biweekly.component.VAlarm;
import biweekly.component.VEvent;
import biweekly.io.TimezoneAssignment;
@ -452,32 +450,4 @@ public class CalendarHelper {
}
}
}
static int getReplyStatus(Context context, VEvent event, EntityMessage message) {
List<Address> recipients = new ArrayList<>();
if (message.to != null)
recipients.addAll(Arrays.asList(message.to));
if (message.cc != null)
recipients.addAll(Arrays.asList(message.cc));
if (message.bcc != null)
recipients.addAll(Arrays.asList(message.bcc));
List<Attendee> attendees = event.getAttendees();
if (attendees != null)
for (Attendee attendee : attendees) {
String email = attendee.getEmail();
for (Address address : recipients) {
String recipient = ((InternetAddress) address).getAddress();
if (!TextUtils.isEmpty(email) && email.equalsIgnoreCase(recipient)) {
ParticipationStatus pstatus = attendee.getParticipationStatus();
if (ParticipationStatus.ACCEPTED.equals(pstatus))
return CalendarContract.Events.STATUS_CONFIRMED;
else if (ParticipationStatus.DECLINED.equals(pstatus))
return CalendarContract.Events.STATUS_CANCELED;
}
}
}
return CalendarContract.Events.STATUS_TENTATIVE;
}
}

View File

@ -158,6 +158,8 @@ import javax.mail.internet.ParseException;
import biweekly.Biweekly;
import biweekly.ICalendar;
import biweekly.component.VEvent;
import biweekly.parameter.ParticipationStatus;
import biweekly.property.Attendee;
import biweekly.property.Method;
import ezvcard.VCard;
import ezvcard.VCardVersion;
@ -4452,8 +4454,35 @@ public class MessageHelper {
CalendarHelper.delete(context, event, message);
else if (method == null || method.isRequest() || method.isReply()) {
int status = CalendarContract.Events.STATUS_TENTATIVE;
if (method != null && method.isReply())
status = CalendarHelper.getReplyStatus(context, event, message);
if (method != null && method.isReply()) {
List<Address> recipients = new ArrayList<>();
if (message.to != null)
recipients.addAll(Arrays.asList(message.to));
if (message.cc != null)
recipients.addAll(Arrays.asList(message.cc));
if (message.bcc != null)
recipients.addAll(Arrays.asList(message.bcc));
List<Attendee> attendees = event.getAttendees();
if (attendees != null)
for (Attendee attendee : attendees) {
String email = attendee.getEmail();
for (Address address : recipients) {
String recipient = ((InternetAddress) address).getAddress();
if (!TextUtils.isEmpty(email) && email.equalsIgnoreCase(recipient)) {
ParticipationStatus pstatus = attendee.getParticipationStatus();
if (ParticipationStatus.ACCEPTED.equals(pstatus)) {
status = CalendarContract.Events.STATUS_CONFIRMED;
break;
} else if (ParticipationStatus.DECLINED.equals(pstatus)) {
status = CalendarContract.Events.STATUS_CANCELED;
break;
}
}
}
if (status != CalendarContract.Events.STATUS_TENTATIVE)
break;
}
}
if (status == CalendarContract.Events.STATUS_CANCELED) {
CalendarHelper.delete(context, event, message);