mirror of
https://github.com/etesync/android
synced 2024-11-22 07:58:09 +00:00
Importing calendar colors from <calendar:color xmlns="http://apple.com/ns/ical/"> element (see #31)
This commit is contained in:
parent
477a3c89f7
commit
c1f57a4470
@ -91,12 +91,20 @@ public class LocalCalendar extends LocalCollection<Event> {
|
||||
public static void create(Account account, ContentResolver resolver, ServerInfo.ResourceInfo info) throws RemoteException {
|
||||
ContentProviderClient client = resolver.acquireContentProviderClient(CalendarContract.AUTHORITY);
|
||||
|
||||
int color = 0xFFC3EA6E;
|
||||
if (info.getColor() != null)
|
||||
try {
|
||||
color = Integer.decode(info.getColor());
|
||||
} catch(Exception ex) {
|
||||
Log.w(TAG, "Couldn't parse calendar color " + info.getColor());
|
||||
}
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Calendars.ACCOUNT_NAME, account.name);
|
||||
values.put(Calendars.ACCOUNT_TYPE, account.type);
|
||||
values.put(Calendars.NAME, info.getPath());
|
||||
values.put(Calendars.CALENDAR_DISPLAY_NAME, info.getTitle());
|
||||
values.put(Calendars.CALENDAR_COLOR, 0xFFC3EA6E);
|
||||
values.put(Calendars.CALENDAR_COLOR, color);
|
||||
values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_OWNER);
|
||||
values.put(Calendars.ALLOWED_AVAILABILITY, Events.AVAILABILITY_BUSY + "," + Events.AVAILABILITY_FREE + "," + Events.AVAILABILITY_TENTATIVE);
|
||||
values.put(Calendars.ALLOWED_ATTENDEE_TYPES, Attendees.TYPE_NONE + "," + Attendees.TYPE_REQUIRED + "," + Attendees.TYPE_OPTIONAL + "," + Attendees.TYPE_RESOURCE);
|
||||
|
@ -26,7 +26,6 @@ import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import at.bitfire.davdroid.R;
|
||||
import at.bitfire.davdroid.URIUtils;
|
||||
|
||||
@ -104,11 +103,11 @@ public class EnterCredentialsFragment extends Fragment implements TextWatcher {
|
||||
void queryServer() {
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
|
||||
String host_path = URIUtils.sanitize(editBaseURL.getText().toString());
|
||||
String host_path = editBaseURL.getText().toString();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
|
||||
args.putString(QueryServerDialogFragment.EXTRA_BASE_URL, protocol + host_path);
|
||||
args.putString(QueryServerDialogFragment.EXTRA_BASE_URL, URIUtils.sanitize(protocol + host_path));
|
||||
args.putString(QueryServerDialogFragment.EXTRA_USER_NAME, editUserName.getText().toString());
|
||||
args.putString(QueryServerDialogFragment.EXTRA_PASSWORD, editPassword.getText().toString());
|
||||
args.putBoolean(QueryServerDialogFragment.EXTRA_AUTH_PREEMPTIVE, checkboxPreemptive.isChecked());
|
||||
|
@ -165,7 +165,7 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
|
||||
ServerInfo.ResourceInfo.Type.ADDRESS_BOOK,
|
||||
resource.getLocation().getPath(),
|
||||
resource.getDisplayName(),
|
||||
resource.getDescription()
|
||||
resource.getDescription(), resource.getColor()
|
||||
);
|
||||
addressBooks.add(info);
|
||||
}
|
||||
@ -187,7 +187,7 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
|
||||
ServerInfo.ResourceInfo.Type.CALENDAR,
|
||||
resource.getLocation().getPath(),
|
||||
resource.getDisplayName(),
|
||||
resource.getDescription()
|
||||
resource.getDescription(), resource.getColor()
|
||||
);
|
||||
calendars.add(info);
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ public class ServerInfo implements Serializable {
|
||||
}
|
||||
|
||||
final Type type;
|
||||
final String path, title, description;
|
||||
final String path, title, description, color;
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,9 @@ public class DavProp {
|
||||
@Element(required=false,name="calendar-description")
|
||||
DavPropCalendarDescription calendarDescription;
|
||||
|
||||
@Element(required=false,name="calendar-color")
|
||||
DavPropCalendarColor calendarColor;
|
||||
|
||||
@Element(required=false)
|
||||
DavPropGetCTag getctag;
|
||||
|
||||
@ -99,6 +102,12 @@ public class DavProp {
|
||||
@Getter private String description;
|
||||
}
|
||||
|
||||
@Namespace(prefix="A",reference="http://apple.com/ns/ical/")
|
||||
public static class DavPropCalendarColor {
|
||||
@Text(required=false)
|
||||
@Getter private String color;
|
||||
}
|
||||
|
||||
@Namespace(prefix="CS",reference="http://calendarserver.org/ns/")
|
||||
public static class DavPropGetCTag {
|
||||
@Text(required=false)
|
||||
|
@ -53,6 +53,7 @@ public class HttpPropfind extends HttpEntityEnclosingRequestBase {
|
||||
propfind.prop.resourcetype = new DavProp.DavPropResourceType();
|
||||
propfind.prop.addressbookDescription = new DavProp.DavPropAddressbookDescription();
|
||||
propfind.prop.calendarDescription = new DavProp.DavPropCalendarDescription();
|
||||
propfind.prop.calendarColor = new DavProp.DavPropCalendarColor();
|
||||
break;
|
||||
case COLLECTION_CTAG:
|
||||
depth = 0;
|
||||
|
@ -58,7 +58,7 @@ public class WebDavResource {
|
||||
|
||||
public enum Property {
|
||||
CURRENT_USER_PRINCIPAL,
|
||||
DISPLAY_NAME, DESCRIPTION,
|
||||
DISPLAY_NAME, DESCRIPTION, COLOR,
|
||||
ADDRESSBOOK_HOMESET, CALENDAR_HOMESET,
|
||||
IS_ADDRESSBOOK, IS_CALENDAR,
|
||||
CTAG, ETAG,
|
||||
@ -213,6 +213,10 @@ public class WebDavResource {
|
||||
return properties.get(Property.DESCRIPTION);
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return properties.get(Property.COLOR);
|
||||
}
|
||||
|
||||
public String getAddressbookHomeSet() {
|
||||
return properties.get(Property.ADDRESSBOOK_HOMESET);
|
||||
}
|
||||
@ -426,6 +430,9 @@ public class WebDavResource {
|
||||
|
||||
if (prop.calendarDescription != null)
|
||||
referenced.properties.put(Property.DESCRIPTION, prop.calendarDescription.getDescription());
|
||||
|
||||
if (prop.calendarColor != null)
|
||||
referenced.properties.put(Property.COLOR, prop.calendarColor.getColor());
|
||||
} else
|
||||
referenced.properties.remove(Property.IS_CALENDAR);
|
||||
}
|
||||
|
@ -116,6 +116,7 @@ exports.getBodyParts = function(conf) {
|
||||
<collection/>\
|
||||
<CAL:calendar/>\
|
||||
</resourcetype>\
|
||||
<A:calendar-color xmlns:A="http://apple.com/ns/ical/">0xFF00FF</A:calendar-color>\
|
||||
</prop>\
|
||||
<status>HTTP/1.1 200 OK</status>\
|
||||
</propstat>\
|
||||
|
@ -111,6 +111,7 @@ public class WebDavResourceTest extends InstrumentationTestCase {
|
||||
WebDavResource dav = new WebDavResource(davCollection, "calendars/test", true);
|
||||
dav.propfind(HttpPropfind.Mode.MEMBERS_COLLECTIONS);
|
||||
assertEquals(3, dav.getMembers().size());
|
||||
assertEquals("0xFF00FF", dav.getMembers().get(2).getColor());
|
||||
for (WebDavResource member : dav.getMembers()) {
|
||||
if (member.getName().contains(".ics"))
|
||||
assertTrue(member.isCalendar());
|
||||
|
Loading…
Reference in New Issue
Block a user