From fb0552de4685485daf82d8606a507178559d735e Mon Sep 17 00:00:00 2001 From: Ricki Hirner Date: Mon, 18 Apr 2016 00:04:18 +0200 Subject: [PATCH] Find collections when they're identical with their home set --- app/src/main/java/at/bitfire/davdroid/DavService.java | 4 +++- .../at/bitfire/davdroid/ui/setup/DavResourceFinder.java | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/at/bitfire/davdroid/DavService.java b/app/src/main/java/at/bitfire/davdroid/DavService.java index 0d744e10..0cd78a2d 100644 --- a/app/src/main/java/at/bitfire/davdroid/DavService.java +++ b/app/src/main/java/at/bitfire/davdroid/DavService.java @@ -228,7 +228,9 @@ public class DavService extends Service { DavResource dav = new DavResource(httpClient, homeSet); try { dav.propfind(1, CollectionInfo.DAV_PROPERTIES); - for (DavResource member : dav.members) { + Set selfAndMembers = new HashSet<>(dav.members); + selfAndMembers.add(dav); + for (DavResource member : selfAndMembers) { CollectionInfo info = CollectionInfo.fromDavResource(member); info.confirmed = true; App.log.log(Level.FINE, "Found collection", info); diff --git a/app/src/main/java/at/bitfire/davdroid/ui/setup/DavResourceFinder.java b/app/src/main/java/at/bitfire/davdroid/ui/setup/DavResourceFinder.java index ffb12036..462edcbd 100644 --- a/app/src/main/java/at/bitfire/davdroid/ui/setup/DavResourceFinder.java +++ b/app/src/main/java/at/bitfire/davdroid/ui/setup/DavResourceFinder.java @@ -209,8 +209,11 @@ public class DavResourceFinder { // Does the collection refer to address book homesets? AddressbookHomeSet homeSets = (AddressbookHomeSet)dav.properties.get(AddressbookHomeSet.NAME); if (homeSets != null) - for (String href : homeSets.hrefs) - config.homeSets.add(UrlUtils.withTrailingSlash(dav.location.resolve(href)).uri()); + for (String href : homeSets.hrefs) { + HttpUrl location = UrlUtils.withTrailingSlash(dav.location.resolve(href)); + log.info("Found addressbook home-set at " + location); + config.homeSets.add(location.uri()); + } } protected void rememberIfCalendarOrHomeset(@NonNull DavResource dav, @NonNull Configuration.ServiceInfo config) {