1
0
mirror of https://github.com/etesync/android synced 2024-11-25 17:38:13 +00:00

fix annoying bug that marked contacts as starred

This commit is contained in:
rfc2822 2013-10-11 21:50:22 +02:00
parent 5d3ef61b77
commit 6727987051
2 changed files with 12 additions and 8 deletions

View File

@ -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<Property> {
@Override
public Starred createProperty(List<Parameter> params, String value) {
return new Starred();
return new Starred(value);
}
@Override
public Starred createProperty(Group group, List<Parameter> params, String value) {
return new Starred();
return new Starred(value);
}
}
}

View File

@ -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));