1
0
mirror of https://github.com/etesync/android synced 2024-11-15 20:38:58 +00:00

Remove unnecessary getters/setters

* remove getters/setters for protected fields when they're only accessed from package scope
* version bump to 0.8.3
This commit is contained in:
Ricki Hirner 2015-08-09 20:02:37 +02:00
parent be80b6fde8
commit fc1874af85
9 changed files with 156 additions and 157 deletions

View File

@ -45,7 +45,7 @@ public class ContactTest extends InstrumentationTestCase {
assertTrue(new String(c.toEntity().toByteArray()).contains("VERSION:3.0"));
// now let's generate VCard 4.0
c.setVCardVersion(VCardVersion.V4_0);
c.vCardVersion = VCardVersion.V4_0;
assertEquals("text/vcard; version=4.0", c.getContentType().toString());
assertTrue(new String(c.toEntity().toByteArray()).contains("VERSION:4.0"));
}
@ -53,11 +53,11 @@ public class ContactTest extends InstrumentationTestCase {
public void testReferenceVCard3() throws IOException, InvalidResourceException {
Contact c = parseVCF("reference-vcard3.vcf", Charset.forName(CharEncoding.UTF_8));
assertEquals("Gümp", c.getFamilyName());
assertEquals("Förrest", c.getGivenName());
assertEquals("Förrest Gümp", c.getDisplayName());
assertEquals("Bubba Gump Shrimpß Co.", c.getOrganization().getValues().get(0));
assertEquals("Shrimp Man", c.getJobTitle());
assertEquals("Gümp", c.familyName);
assertEquals("Förrest", c.givenName);
assertEquals("Förrest Gümp", c.displayName);
assertEquals("Bubba Gump Shrimpß Co.", c.organization.getValues().get(0));
assertEquals("Shrimp Man", c.jobTitle);
Telephone phone1 = c.getPhoneNumbers().get(0);
assertEquals("(111) 555-1212", phone1.getText());
@ -76,21 +76,21 @@ public class ContactTest extends InstrumentationTestCase {
@Cleanup InputStream photoStream = assetMgr.open("davdroid-logo-192.png", AssetManager.ACCESS_STREAMING);
byte[] expectedPhoto = IOUtils.toByteArray(photoStream);
assertTrue(Arrays.equals(c.getPhoto(), expectedPhoto));
assertTrue(Arrays.equals(c.photo, expectedPhoto));
}
public void testParseInvalidUnknownProperties() throws IOException {
Contact c = parseVCF("invalid-unknown-properties.vcf");
assertEquals("VCard with invalid unknown properties", c.getDisplayName());
assertNull(c.getUnknownProperties());
assertEquals("VCard with invalid unknown properties", c.displayName);
assertNull(c.unknownProperties);
}
public void testParseLatin1() throws IOException {
Contact c = parseVCF("latin1.vcf", Charset.forName(CharEncoding.ISO_8859_1));
assertEquals("Özkan Äuçek", c.getDisplayName());
assertEquals("Özkan", c.getGivenName());
assertEquals("Äuçek", c.getFamilyName());
assertNull(c.getUnknownProperties());
assertEquals("Özkan Äuçek", c.displayName);
assertEquals("Özkan", c.givenName);
assertEquals("Äuçek", c.familyName);
assertNull(c.unknownProperties);
}

View File

@ -61,8 +61,8 @@ public class EventTest extends InstrumentationTestCase {
assertEquals(1, event.getExceptions().size());
Event exception = event.getExceptions().get(0);
assertEquals("20150503", exception.getRecurrenceId().getValue());
assertEquals("Another summary for the third day", exception.getSummary());
assertEquals("20150503", exception.recurrenceId.getValue());
assertEquals("Another summary for the third day", exception.summary);
}
public void testStartEndTimes() throws IOException, ParserException, InvalidResourceException {
@ -104,7 +104,7 @@ public class EventTest extends InstrumentationTestCase {
public void testUnfolding() throws IOException, InvalidResourceException {
Event e = parseCalendar("two-line-description-without-crlf.ics");
assertEquals("http://www.tgbornheim.de/index.php?sessionid=&page=&id=&sportcentergroup=&day=6", e.getDescription());
assertEquals("http://www.tgbornheim.de/index.php?sessionid=&page=&id=&sportcentergroup=&day=6", e.description);
}

View File

@ -150,15 +150,15 @@ public class LocalCalendarTest extends InstrumentationTestCase {
assertNotNull("Couldn't build and insert event", event);
// compare with original event
try {
assertEquals(event.getSummary(), event2.getSummary());
assertEquals(event.getDescription(), event2.getDescription());
assertEquals(event.getLocation(), event2.getLocation());
assertEquals(event.getDtStart(), event2.getDtStart());
assertEquals(event.summary, event2.summary);
assertEquals(event.description, event2.description);
assertEquals(event.location, event2.location);
assertEquals(event.dtStart, event2.dtStart);
assertFalse(event2.isAllDay());
assertEquals(1, event2.getAlarms().size());
VAlarm alarm = event2.getAlarms().get(0);
assertEquals(event.getSummary(), alarm.getDescription().getValue()); // should be built from event name
assertEquals(event.summary, alarm.getDescription().getValue()); // should be built from event name
assertEquals(new Dur(0, 0, -(24*60 + 60*2 + 3), 0), alarm.getTrigger().getDuration()); // calendar provider stores trigger in minutes
} finally {
testCalendar.delete(event);
@ -184,10 +184,10 @@ public class LocalCalendarTest extends InstrumentationTestCase {
assertNotNull("Couldn't build and insert event", event);
// compare with original event
try {
assertEquals(event.getSummary(), event2.getSummary());
assertEquals(event.getDescription(), event2.getDescription());
assertEquals(event.getLocation(), event2.getLocation());
assertEquals(event.getDtStart(), event2.getDtStart());
assertEquals(event.summary, event2.summary);
assertEquals(event.description, event2.description);
assertEquals(event.location, event2.location);
assertEquals(event.dtStart, event2.dtStart);
assertTrue(event2.isAllDay());
} finally {
testCalendar.delete(event);

View File

@ -9,7 +9,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.bitfire.davdroid"
android:versionCode="69" android:versionName="0.8.2"
android:versionCode="70" android:versionName="0.8.3"
android:installLocation="internalOnly">
<uses-sdk

View File

@ -11,7 +11,7 @@ import net.fortuna.ical4j.model.property.ProdId;
public class Constants {
public static final String
APP_VERSION = "0.8.2",
APP_VERSION = "0.8.3",
ACCOUNT_TYPE = "bitfire.at.davdroid",
WEB_URL_HELP = "https://davdroid.bitfire.at/configuration?pk_campaign=davdroid-app",
WEB_URL_VIEW_LOGS = "https://github.com/bitfireAT/davdroid/wiki/How-to-view-the-logs";

View File

@ -70,28 +70,28 @@ import lombok.ToString;
public class Contact extends Resource {
private final static String TAG = "davdroid.Contact";
@Getter @Setter protected VCardVersion vCardVersion = VCardVersion.V3_0;
protected VCardVersion vCardVersion = VCardVersion.V3_0;
public static final ContentType
MIME_VCARD3 = ContentType.create("text/vcard", CharEncoding.UTF_8),
MIME_VCARD4 = ContentType.parse("text/vcard; version=4.0");
public final static String
public static final String
PROPERTY_STARRED = "X-DAVDROID-STARRED",
PROPERTY_PHONETIC_FIRST_NAME = "X-PHONETIC-FIRST-NAME",
PROPERTY_PHONETIC_MIDDLE_NAME = "X-PHONETIC-MIDDLE-NAME",
PROPERTY_PHONETIC_LAST_NAME = "X-PHONETIC-LAST-NAME",
PROPERTY_SIP = "X-SIP";
public final static EmailType EMAIL_TYPE_MOBILE = EmailType.get("x-mobile");
public static final EmailType EMAIL_TYPE_MOBILE = EmailType.get("x-mobile");
public final static TelephoneType
public static final TelephoneType
PHONE_TYPE_CALLBACK = TelephoneType.get("x-callback"),
PHONE_TYPE_COMPANY_MAIN = TelephoneType.get("x-company_main"),
PHONE_TYPE_RADIO = TelephoneType.get("x-radio"),
PHONE_TYPE_ASSISTANT = TelephoneType.get("X-assistant"),
PHONE_TYPE_MMS = TelephoneType.get("x-mms");
public final static RelatedType
public static final RelatedType
RELATED_TYPE_BROTHER = RelatedType.get("brother"),
RELATED_TYPE_FATHER = RelatedType.get("father"),
RELATED_TYPE_MANAGER = RelatedType.get("manager"),
@ -99,22 +99,22 @@ public class Contact extends Resource {
RELATED_TYPE_REFERRED_BY = RelatedType.get("referred-by"),
RELATED_TYPE_SISTER = RelatedType.get("sister");
@Getter @Setter private String unknownProperties;
protected String unknownProperties;
protected boolean starred;
@Getter @Setter private boolean starred;
protected String displayName, nickName;
protected String prefix, givenName, middleName, familyName, suffix;
protected String phoneticGivenName, phoneticMiddleName, phoneticFamilyName;
protected String note;
protected Organization organization;
protected String jobTitle, jobDescription;
@Getter @Setter private String displayName, nickName;
@Getter @Setter private String prefix, givenName, middleName, familyName, suffix;
@Getter @Setter private String phoneticGivenName, phoneticMiddleName, phoneticFamilyName;
@Getter @Setter private String note;
@Getter @Setter private Organization organization;
@Getter @Setter private String jobTitle, jobDescription;
protected byte[] photo;
@Getter @Setter private byte[] photo;
@Getter @Setter private Anniversary anniversary;
@Getter @Setter private Birthday birthDay;
protected Anniversary anniversary;
protected Birthday birthDay;
// lists must not be set to null (because they're iterated using "for"), so only getters are exposed
@Getter private List<Telephone> phoneNumbers = new LinkedList<>();
@Getter private List<Email> emails = new LinkedList<>();
@Getter private List<Impp> impps = new LinkedList<>();

View File

@ -66,28 +66,30 @@ import lombok.Setter;
public class Event extends iCalendar {
private final static String TAG = "davdroid.Event";
@Getter @Setter protected RecurrenceId recurrenceId;
protected RecurrenceId recurrenceId;
@Getter @Setter protected String summary, location, description;
protected String summary, location, description;
@Getter protected DtStart dtStart;
@Getter protected DtEnd dtEnd;
@Getter @Setter protected Duration duration;
@Getter protected List<RDate> rdates = new LinkedList<>();
@Getter @Setter protected RRule rrule;
@Getter protected List<ExDate> exdates = new LinkedList<>();
@Getter @Setter protected ExRule exrule;
@Getter protected List<Event> exceptions = new LinkedList<>();
protected DtStart dtStart;
protected DtEnd dtEnd;
@Getter @Setter protected Boolean forPublic;
@Getter @Setter protected Status status;
// lists must not be set to null (because they're iterated using "for"), so only getters are exposed
protected Duration duration;
@Getter private List<RDate> rdates = new LinkedList<>();
protected RRule rrule;
@Getter private List<ExDate> exdates = new LinkedList<>();
protected ExRule exrule;
@Getter private List<Event> exceptions = new LinkedList<>();
@Getter @Setter protected boolean opaque;
protected Boolean forPublic;
protected Status status;
@Getter @Setter protected Organizer organizer;
@Getter protected List<Attendee> attendees = new LinkedList<>();
protected boolean opaque;
@Getter protected List<VAlarm> alarms = new LinkedList<>();
protected Organizer organizer;
@Getter private List<Attendee> attendees = new LinkedList<>();
@Getter private List<VAlarm> alarms = new LinkedList<>();
public Event(String name, String ETag) {

View File

@ -136,7 +136,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
public Contact newResource(long localID, String resourceName, String eTag) {
Contact c = new Contact(localID, resourceName, eTag);
c.setVCardVersion(accountSettings.getAddressBookVCardVersion());
c.vCardVersion = accountSettings.getAddressBookVCardVersion();
return c;
}
@ -187,8 +187,8 @@ public class LocalAddressBook extends LocalCollection<Contact> {
ContentValues values = e.getEntityValues();
c.setUid(values.getAsString(entryColumnUID()));
c.setUnknownProperties(values.getAsString(COLUMN_UNKNOWN_PROPERTIES));
c.setStarred(values.getAsInteger(RawContacts.STARRED) != 0);
c.unknownProperties = values.getAsString(COLUMN_UNKNOWN_PROPERTIES);
c.starred = values.getAsInteger(RawContacts.STARRED) != 0;
List<Entity.NamedContentValues> subValues = e.getSubValues();
for (Entity.NamedContentValues subValue : subValues) {
@ -247,17 +247,17 @@ public class LocalAddressBook extends LocalCollection<Contact> {
}
private void populateStructuredName(Contact c, ContentValues row) {
c.setDisplayName(row.getAsString(StructuredName.DISPLAY_NAME));
c.displayName = row.getAsString(StructuredName.DISPLAY_NAME);
c.setPrefix(row.getAsString(StructuredName.PREFIX));
c.setGivenName(row.getAsString(StructuredName.GIVEN_NAME));
c.setMiddleName(row.getAsString(StructuredName.MIDDLE_NAME));
c.setFamilyName(row.getAsString(StructuredName.FAMILY_NAME));
c.setSuffix(row.getAsString(StructuredName.SUFFIX));
c.prefix = row.getAsString(StructuredName.PREFIX);
c.givenName = row.getAsString(StructuredName.GIVEN_NAME);
c.middleName = row.getAsString(StructuredName.MIDDLE_NAME);
c.familyName = row.getAsString(StructuredName.FAMILY_NAME);
c.suffix = row.getAsString(StructuredName.SUFFIX);
c.setPhoneticGivenName(row.getAsString(StructuredName.PHONETIC_GIVEN_NAME));
c.setPhoneticMiddleName(row.getAsString(StructuredName.PHONETIC_MIDDLE_NAME));
c.setPhoneticFamilyName(row.getAsString(StructuredName.PHONETIC_FAMILY_NAME));
c.phoneticGivenName = row.getAsString(StructuredName.PHONETIC_GIVEN_NAME);
c.phoneticMiddleName = row.getAsString(StructuredName.PHONETIC_MIDDLE_NAME);
c.phoneticFamilyName = row.getAsString(StructuredName.PHONETIC_FAMILY_NAME);
}
protected void populatePhoneNumber(Contact c, ContentValues row) {
@ -364,12 +364,12 @@ public class LocalAddressBook extends LocalCollection<Contact> {
try {
@Cleanup AssetFileDescriptor fd = providerClient.openAssetFile(photoUri, "r");
@Cleanup InputStream is = fd.createInputStream();
c.setPhoto(IOUtils.toByteArray(is));
c.photo = IOUtils.toByteArray(is);
} catch(IOException ex) {
Log.w(TAG, "Couldn't read high-res contact photo", ex);
}
} else
c.setPhoto(row.getAsByteArray(Photo.PHOTO));
c.photo = row.getAsByteArray(Photo.PHOTO);
}
protected void populateOrganization(Contact c, ContentValues row) {
@ -384,13 +384,13 @@ public class LocalAddressBook extends LocalCollection<Contact> {
org.addValue(company);
if (StringUtils.isNotEmpty(department))
org.addValue(department);
c.setOrganization(org);
c.organization = org;
}
if (StringUtils.isNotEmpty(title))
c.setJobTitle(title);
c.jobTitle = title;
if (StringUtils.isNotEmpty(role))
c.setJobDescription(role);
c.jobDescription = role;
}
protected void populateIMPP(Contact c, ContentValues row) {
@ -449,11 +449,11 @@ public class LocalAddressBook extends LocalCollection<Contact> {
protected void populateNickname(Contact c, ContentValues row) {
// TYPE (maiden name, short name, ) and LABEL are not processed here because Contacts app doesn't support it
c.setNickName(row.getAsString(Nickname.NAME));
c.nickName = row.getAsString(Nickname.NAME);
}
protected void populateNote(Contact c, ContentValues row) {
c.setNote(row.getAsString(Note.NOTE));
c.note = row.getAsString(Note.NOTE);
}
protected void populatePostalAddress(Contact c, ContentValues row) {
@ -539,10 +539,10 @@ public class LocalAddressBook extends LocalCollection<Contact> {
Date date = formatter.parse(row.getAsString(CommonDataKinds.Event.START_DATE));
switch (row.getAsInteger(CommonDataKinds.Event.TYPE)) {
case CommonDataKinds.Event.TYPE_ANNIVERSARY:
c.setAnniversary(new Anniversary(date));
c.anniversary = new Anniversary(date);
break;
case CommonDataKinds.Event.TYPE_BIRTHDAY:
c.setBirthDay(new Birthday(date));
c.birthDay = new Birthday(date);
break;
}
} catch (ParseException e) {
@ -658,8 +658,8 @@ public class LocalAddressBook extends LocalCollection<Contact> {
.withValue(entryColumnRemoteName(), contact.getName())
.withValue(entryColumnUID(), contact.getUid())
.withValue(entryColumnETag(), contact.getETag())
.withValue(COLUMN_UNKNOWN_PROPERTIES, contact.getUnknownProperties())
.withValue(RawContacts.STARRED, contact.isStarred() ? 1 : 0);
.withValue(COLUMN_UNKNOWN_PROPERTIES, contact.unknownProperties)
.withValue(RawContacts.STARRED, contact.starred ? 1 : 0);
}
@ -675,19 +675,19 @@ public class LocalAddressBook extends LocalCollection<Contact> {
for (ezvcard.property.Email email : contact.getEmails())
queueOperation(buildEmail(newDataInsertBuilder(localID, backrefIdx), email));
if (contact.getPhoto() != null)
queueOperation(buildPhoto(newDataInsertBuilder(localID, backrefIdx), contact.getPhoto()));
if (contact.photo != null)
queueOperation(buildPhoto(newDataInsertBuilder(localID, backrefIdx), contact.photo));
queueOperation(buildOrganization(newDataInsertBuilder(localID, backrefIdx), contact));
for (Impp impp : contact.getImpps())
queueOperation(buildIMPP(newDataInsertBuilder(localID, backrefIdx), impp));
if (contact.getNickName() != null)
queueOperation(buildNickName(newDataInsertBuilder(localID, backrefIdx), contact.getNickName()));
if (contact.nickName != null)
queueOperation(buildNickName(newDataInsertBuilder(localID, backrefIdx), contact.nickName));
if (contact.getNote() != null)
queueOperation(buildNote(newDataInsertBuilder(localID, backrefIdx), contact.getNote()));
if (contact.note != null)
queueOperation(buildNote(newDataInsertBuilder(localID, backrefIdx), contact.note));
for (Address address : contact.getAddresses())
queueOperation(buildAddress(newDataInsertBuilder(localID, backrefIdx), address));
@ -698,10 +698,10 @@ public class LocalAddressBook extends LocalCollection<Contact> {
for (String url : contact.getURLs())
queueOperation(buildURL(newDataInsertBuilder(localID, backrefIdx), url));
if (contact.getAnniversary() != null)
queueOperation(buildEvent(newDataInsertBuilder(localID, backrefIdx), contact.getAnniversary(), CommonDataKinds.Event.TYPE_ANNIVERSARY));
if (contact.getBirthDay() != null)
queueOperation(buildEvent(newDataInsertBuilder(localID, backrefIdx), contact.getBirthDay(), CommonDataKinds.Event.TYPE_BIRTHDAY));
if (contact.anniversary != null)
queueOperation(buildEvent(newDataInsertBuilder(localID, backrefIdx), contact.anniversary, CommonDataKinds.Event.TYPE_ANNIVERSARY));
if (contact.birthDay != null)
queueOperation(buildEvent(newDataInsertBuilder(localID, backrefIdx), contact.birthDay, CommonDataKinds.Event.TYPE_BIRTHDAY));
for (Related related : contact.getRelations())
for (RelatedType type : related.getTypes())
@ -721,15 +721,15 @@ public class LocalAddressBook extends LocalCollection<Contact> {
protected Builder buildStructuredName(Builder builder, Contact contact) {
return builder
.withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
.withValue(StructuredName.PREFIX, contact.getPrefix())
.withValue(StructuredName.DISPLAY_NAME, contact.getDisplayName())
.withValue(StructuredName.GIVEN_NAME, contact.getGivenName())
.withValue(StructuredName.MIDDLE_NAME, contact.getMiddleName())
.withValue(StructuredName.FAMILY_NAME, contact.getFamilyName())
.withValue(StructuredName.SUFFIX, contact.getSuffix())
.withValue(StructuredName.PHONETIC_GIVEN_NAME, contact.getPhoneticGivenName())
.withValue(StructuredName.PHONETIC_MIDDLE_NAME, contact.getPhoneticMiddleName())
.withValue(StructuredName.PHONETIC_FAMILY_NAME, contact.getPhoneticFamilyName());
.withValue(StructuredName.PREFIX, contact.prefix)
.withValue(StructuredName.DISPLAY_NAME, contact.displayName)
.withValue(StructuredName.GIVEN_NAME, contact.givenName)
.withValue(StructuredName.MIDDLE_NAME, contact.middleName)
.withValue(StructuredName.FAMILY_NAME, contact.familyName)
.withValue(StructuredName.SUFFIX, contact.suffix)
.withValue(StructuredName.PHONETIC_GIVEN_NAME, contact.phoneticGivenName)
.withValue(StructuredName.PHONETIC_MIDDLE_NAME, contact.phoneticMiddleName)
.withValue(StructuredName.PHONETIC_FAMILY_NAME, contact.phoneticFamilyName);
}
protected Builder buildPhoneNumber(Builder builder, Telephone number) {
@ -842,10 +842,10 @@ public class LocalAddressBook extends LocalCollection<Contact> {
}
protected Builder buildOrganization(Builder builder, Contact contact) {
if (contact.getOrganization() == null && contact.getJobTitle() == null && contact.getJobDescription() == null)
if (contact.organization == null && contact.jobTitle == null && contact.jobDescription == null)
return null;
ezvcard.property.Organization organization = contact.getOrganization();
ezvcard.property.Organization organization = contact.organization;
String company = null, department = null;
if (organization != null) {
Iterator<String> org = organization.getValues().iterator();
@ -859,8 +859,8 @@ public class LocalAddressBook extends LocalCollection<Contact> {
.withValue(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE)
.withValue(Organization.COMPANY, company)
.withValue(Organization.DEPARTMENT, department)
.withValue(Organization.TITLE, contact.getJobTitle())
.withValue(Organization.JOB_DESCRIPTION, contact.getJobDescription());
.withValue(Organization.TITLE, contact.jobTitle)
.withValue(Organization.JOB_DESCRIPTION, contact.jobDescription);
}
protected Builder buildIMPP(Builder builder, Impp impp) {

View File

@ -78,8 +78,8 @@ import lombok.Getter;
public class LocalCalendar extends LocalCollection<Event> {
private static final String TAG = "davdroid.LocalCalendar";
@Getter private String url;
@Getter private long id;
@Getter protected String url;
@Getter protected long id;
protected static final String COLLECTION_COLUMN_CTAG = Calendars.CAL_SYNC1;
@ -333,9 +333,9 @@ public class LocalCalendar extends LocalCollection<Event> {
protected void populateEvent(Event e, ContentValues values) {
e.setUid(values.getAsString(entryColumnUID()));
e.setSummary(values.getAsString(Events.TITLE));
e.setLocation(values.getAsString(Events.EVENT_LOCATION));
e.setDescription(values.getAsString(Events.DESCRIPTION));
e.summary = values.getAsString(Events.TITLE);
e.location = values.getAsString(Events.EVENT_LOCATION);
e.description = values.getAsString(Events.DESCRIPTION);
final boolean allDay = values.getAsInteger(Events.ALL_DAY) != 0;
final long tsStart = values.getAsLong(Events.DTSTART);
@ -360,14 +360,14 @@ public class LocalCalendar extends LocalCollection<Event> {
if (tsEnd != null)
e.setDtEnd(tsEnd, tzId);
else if (!StringUtils.isEmpty(duration))
e.setDuration(new Duration(new Dur(duration)));
e.duration = new Duration(new Dur(duration));
}
// recurrence
try {
String strRRule = values.getAsString(Events.RRULE);
if (!StringUtils.isEmpty(strRRule))
e.setRrule(new RRule(strRRule));
e.rrule = new RRule(strRRule);
String strRDate = values.getAsString(Events.RDATE);
if (!StringUtils.isEmpty(strRDate)) {
@ -379,7 +379,7 @@ public class LocalCalendar extends LocalCollection<Event> {
if (!StringUtils.isEmpty(strExRule)) {
ExRule exRule = new ExRule();
exRule.setValue(strExRule);
e.setExrule(exRule);
e.exrule = exRule;
}
String strExDate = values.getAsString(Events.EXDATE);
@ -406,28 +406,28 @@ public class LocalCalendar extends LocalCollection<Event> {
new DateTime(originalInstanceTime);
if (originalDate instanceof DateTime)
((DateTime)originalDate).setUtc(true);
e.setRecurrenceId(new RecurrenceId(originalDate));
e.recurrenceId = new RecurrenceId(originalDate);
}
// status
if (values.containsKey(Events.STATUS))
switch (values.getAsInteger(Events.STATUS)) {
case Events.STATUS_CONFIRMED:
e.setStatus(Status.VEVENT_CONFIRMED);
e.status = Status.VEVENT_CONFIRMED;
break;
case Events.STATUS_TENTATIVE:
e.setStatus(Status.VEVENT_TENTATIVE);
e.status = Status.VEVENT_TENTATIVE;
break;
case Events.STATUS_CANCELED:
e.setStatus(Status.VEVENT_CANCELLED);
e.status = Status.VEVENT_CANCELLED;
}
// availability
e.setOpaque(values.getAsInteger(Events.AVAILABILITY) != Events.AVAILABILITY_FREE);
e.opaque = values.getAsInteger(Events.AVAILABILITY) != Events.AVAILABILITY_FREE;
// set ORGANIZER
try {
e.setOrganizer(new Organizer(new URI("mailto", values.getAsString(Events.ORGANIZER), null)));
e.organizer = new Organizer(new URI("mailto", values.getAsString(Events.ORGANIZER), null));
} catch (URISyntaxException ex) {
Log.e(TAG, "Error when creating ORGANIZER mailto URI, ignoring", ex);
}
@ -436,10 +436,10 @@ public class LocalCalendar extends LocalCollection<Event> {
switch (values.getAsInteger(Events.ACCESS_LEVEL)) {
case Events.ACCESS_CONFIDENTIAL:
case Events.ACCESS_PRIVATE:
e.setForPublic(false);
e.forPublic = false;
break;
case Events.ACCESS_PUBLIC:
e.setForPublic(true);
e.forPublic = true;
}
}
@ -526,7 +526,7 @@ public class LocalCalendar extends LocalCollection<Event> {
PropertyList props = alarm.getProperties();
props.add(Action.DISPLAY);
props.add(new Description(event.getSummary()));
props.add(new Description(event.summary));
event.getAlarms().add(alarm);
}
@ -547,8 +547,7 @@ public class LocalCalendar extends LocalCollection<Event> {
.withValue(Events.GUESTS_CAN_MODIFY, 1)
.withValue(Events.GUESTS_CAN_SEE_GUESTS, 1);
final RecurrenceId recurrenceId = event.getRecurrenceId();
if (recurrenceId == null) {
if (event.recurrenceId == null) {
// this event is a "master event" (not an exception)
builder .withValue(entryColumnRemoteName(), event.getName())
.withValue(entryColumnETag(), event.getETag())
@ -563,9 +562,9 @@ public class LocalCalendar extends LocalCollection<Event> {
}
boolean recurring = false;
if (event.getRrule() != null) {
if (event.rrule != null) {
recurring = true;
builder.withValue(Events.RRULE, event.getRrule().getValue());
builder.withValue(Events.RRULE, event.rrule.getValue());
}
if (!event.getRdates().isEmpty()) {
recurring = true;
@ -575,9 +574,9 @@ public class LocalCalendar extends LocalCollection<Event> {
Log.e(TAG, "Couldn't parse RDate(s)", e);
}
}
if (event.getExrule() != null)
builder.withValue(Events.EXRULE, event.getExrule().getValue());
if (!event.getExdates().isEmpty())
if (event.exrule != null)
builder.withValue(Events.EXRULE, event.exrule.getValue());
if (!event.getExceptions().isEmpty())
try {
builder.withValue(Events.EXDATE, DateUtils.recurrenceSetsToAndroidString(event.getExdates(), event.isAllDay()));
} catch (ParseException e) {
@ -588,28 +587,27 @@ public class LocalCalendar extends LocalCollection<Event> {
// because that's the way Android likes it (see docs)
if (recurring) {
// calculate DURATION from start and end date
Duration duration = new Duration(event.getDtStart().getDate(), event.getDtEnd().getDate());
Duration duration = new Duration(event.dtStart.getDate(), event.dtEnd.getDate());
builder.withValue(Events.DURATION, duration.getValue());
} else
builder .withValue(Events.DTEND, event.getDtEndInMillis())
.withValue(Events.EVENT_END_TIMEZONE, event.getDtEndTzID());
if (event.getSummary() != null)
builder.withValue(Events.TITLE, event.getSummary());
if (event.getLocation() != null)
builder.withValue(Events.EVENT_LOCATION, event.getLocation());
if (event.getDescription() != null)
builder.withValue(Events.DESCRIPTION, event.getDescription());
if (event.summary != null)
builder.withValue(Events.TITLE, event.summary);
if (event.location != null)
builder.withValue(Events.EVENT_LOCATION, event.location);
if (event.description != null)
builder.withValue(Events.DESCRIPTION, event.description);
Organizer organizer = event.getOrganizer();
if (organizer != null) {
final URI uri = organizer.getCalAddress();
if (event.organizer != null) {
final URI uri = event.organizer.getCalAddress();
String email = null;
if (uri != null && "mailto".equalsIgnoreCase(uri.getScheme()))
email = uri.getSchemeSpecificPart();
else {
iCalendar.Email emailParam = (iCalendar.Email)organizer.getParameter(iCalendar.Email.PARAMETER_NAME);
iCalendar.Email emailParam = (iCalendar.Email)event.organizer.getParameter(iCalendar.Email.PARAMETER_NAME);
if (emailParam != null)
email = emailParam.getValue();
else
@ -618,20 +616,20 @@ public class LocalCalendar extends LocalCollection<Event> {
builder.withValue(Events.ORGANIZER, email != null ? email : uri.toString());
}
Status status = event.getStatus();
if (status != null) {
//Status status = event.getStatus();
if (event.status!= null) {
int statusCode = Events.STATUS_TENTATIVE;
if (status == Status.VEVENT_CONFIRMED)
if (event.status == Status.VEVENT_CONFIRMED)
statusCode = Events.STATUS_CONFIRMED;
else if (status == Status.VEVENT_CANCELLED)
else if (event.status == Status.VEVENT_CANCELLED)
statusCode = Events.STATUS_CANCELED;
builder.withValue(Events.STATUS, statusCode);
}
builder.withValue(Events.AVAILABILITY, event.isOpaque() ? Events.AVAILABILITY_BUSY : Events.AVAILABILITY_FREE);
builder.withValue(Events.AVAILABILITY, event.opaque ? Events.AVAILABILITY_BUSY : Events.AVAILABILITY_FREE);
if (event.getForPublic() != null)
builder.withValue(Events.ACCESS_LEVEL, event.getForPublic() ? Events.ACCESS_PUBLIC : Events.ACCESS_PRIVATE);
if (event.forPublic != null)
builder.withValue(Events.ACCESS_LEVEL, event.forPublic ? Events.ACCESS_PUBLIC : Events.ACCESS_PRIVATE);
return builder;
}
@ -672,13 +670,12 @@ public class LocalCalendar extends LocalCollection<Event> {
buildEntry(builder, exception, false);
builder.withValue(Events.ORIGINAL_SYNC_ID, exception.getName());
final RecurrenceId recurrenceId = exception.getRecurrenceId();
final boolean originalAllDay = master.isAllDay();
Date date = recurrenceId.getDate();
Date date = exception.recurrenceId.getDate();
if (originalAllDay && date instanceof DateTime) { // correct VALUE=DATE-TIME RECURRENCE-IDs to VALUE=DATE
final DateFormat dateFormatDate = new SimpleDateFormat("yyyyMMdd");
final String dateString = dateFormatDate.format(recurrenceId.getDate());
final String dateString = dateFormatDate.format(exception.recurrenceId.getDate());
try {
date = new Date(dateString);
} catch (ParseException e) {