From 6727987051d74526241e4d4a5cd7355eb968c260 Mon Sep 17 00:00:00 2001 From: rfc2822 Date: Fri, 11 Oct 2013 21:50:22 +0200 Subject: [PATCH] fix annoying bug that marked contacts as starred --- src/at/bitfire/davdroid/ical4j/Starred.java | 13 +++++++++---- src/at/bitfire/davdroid/resource/Contact.java | 7 +++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/at/bitfire/davdroid/ical4j/Starred.java b/src/at/bitfire/davdroid/ical4j/Starred.java index 2b1c3d24..1c92e66e 100644 --- a/src/at/bitfire/davdroid/ical4j/Starred.java +++ b/src/at/bitfire/davdroid/ical4j/Starred.java @@ -13,13 +13,18 @@ public class Starred extends Property { public static final String PROPERTY_NAME = "DAVDROID-STARRED"; - public Starred() { + protected boolean isStarred; + + + public Starred(String value) { super(PROPERTY_NAME); + + isStarred = Integer.parseInt(value) > 0; } @Override public String getValue() { - return "1"; + return isStarred ? "1" : "0"; } @Override @@ -30,12 +35,12 @@ public class Starred extends Property { public static class Factory implements PropertyFactory { @Override public Starred createProperty(List params, String value) { - return new Starred(); + return new Starred(value); } @Override public Starred createProperty(Group group, List params, String value) { - return new Starred(); + return new Starred(value); } } } diff --git a/src/at/bitfire/davdroid/resource/Contact.java b/src/at/bitfire/davdroid/resource/Contact.java index 48a6f815..8f837c86 100644 --- a/src/at/bitfire/davdroid/resource/Contact.java +++ b/src/at/bitfire/davdroid/resource/Contact.java @@ -118,9 +118,8 @@ public class Contact extends Resource { if (uid != null) this.uid = uid.getValue(); - for (Property p : vcard.getExtendedProperties(Starred.PROPERTY_NAME)) - Log.i(TAG, p.getValue()); - this.starred = vcard.getExtendedProperty(Starred.PROPERTY_NAME) != null; + Starred starred = (Starred)vcard.getExtendedProperty(Starred.PROPERTY_NAME); + this.starred = starred != null && starred.getValue().equals("1"); Fn fn = (Fn)vcard.getProperty(Id.FN); displayName = (fn != null) ? fn.getValue() : null; @@ -193,7 +192,7 @@ public class Contact extends Resource { } if (starred) - properties.add(new Starred()); + properties.add(new Starred("1")); if (displayName != null) properties.add(new Fn(displayName));