Commit 91544b3e authored by Ricki Hirner's avatar Ricki Hirner 🐑

Remove unnecessary getters/setters

* remove getters/setters for protected fields when they're only accessed from package scope
* version bump to 0.8.3
parent bac737a8
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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
......
......@@ -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";
......
......@@ -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;
@Getter @Setter private boolean starred;
@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;
@Getter @Setter private byte[] photo;
@Getter @Setter private Anniversary anniversary;
@Getter @Setter private Birthday birthDay;
protected String unknownProperties;
protected 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;
protected byte[] photo;
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<>();
......
......@@ -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;
@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<>();
@Getter @Setter protected Boolean forPublic;
@Getter @Setter protected Status status;
protected String summary, location, description;
protected DtStart dtStart;
protected DtEnd dtEnd;
// 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<>();
protected Boolean forPublic;
protected Status status;
@Getter @Setter protected boolean opaque;
protected boolean opaque;
@Getter @Setter protected Organizer organizer;
@Getter protected List<Attendee> attendees = new LinkedList<>();
protected Organizer organizer;
@Getter private List<Attendee> attendees = new LinkedList<>();
@Getter protected List<VAlarm> alarms = new LinkedList<>();
@Getter private List<VAlarm> alarms = new LinkedList<>();
public Event(String name, String ETag) {
......
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment