Commit 652f9884 authored by Ricki Hirner's avatar Ricki Hirner 🐑

New sync logic for ContactsSyncAdapter, using dav4android and vcard4android

parent a4d1c2ab
......@@ -40,7 +40,7 @@ public class HttpClient extends OkHttpClient {
super();
initialize();
// authentication
// authentication and User-Agent
if (preemptive)
networkInterceptors().add(new PreemptiveAuthenticationInterceptor(username, password));
else
......@@ -68,7 +68,7 @@ public class HttpClient extends OkHttpClient {
}
});
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
networkInterceptors().add(logging);
interceptors().add(logging);
}
......
......@@ -11,6 +11,7 @@ import android.accounts.Account;
import android.content.ContentProviderClient;
import android.provider.ContactsContract;
import at.bitfire.davdroid.Constants;
import at.bitfire.vcard4android.AndroidAddressBook;
import at.bitfire.vcard4android.AndroidContact;
import at.bitfire.vcard4android.AndroidContactFactory;
......@@ -25,9 +26,30 @@ public class LocalAddressBook extends AndroidAddressBook {
super(account, provider, AndroidGroupFactory.INSTANCE, LocalContact.Factory.INSTANCE);
}
/*LocalContact[] queryAll() throws ContactsStorageException {
LocalContact contacts[] = (LocalContact[])queryContacts(ContactsContract.RawContacts.DELETED + "=0", null);
public LocalContact[] getAll() throws ContactsStorageException {
LocalContact contacts[] = (LocalContact[])queryContacts(null, null);
return contacts;
}*/
}
/**
* Returns an array of local contacts which have been deleted locally. (DELETED != 0).
*/
public LocalContact[] getDeleted() throws ContactsStorageException {
return (LocalContact[])queryContacts(ContactsContract.RawContacts.DELETED + " != 0", null);
}
/**
* Returns an array of local contacts which have been changed locally (DIRTY != 0).
*/
public LocalContact[] getDirty() throws ContactsStorageException {
return (LocalContact[])queryContacts(ContactsContract.RawContacts.DIRTY + " != 0", null);
}
/**
* Returns an array of local contacts which don't have a file name yet.
*/
public LocalContact[] getWithoutFileName() throws ContactsStorageException {
return (LocalContact[])queryContacts(AndroidContact.COLUMN_FILENAME + " IS NULL", null);
}
}
......@@ -8,19 +8,34 @@
package at.bitfire.davdroid.resource;
import android.content.ContentValues;
import android.os.RemoteException;
import android.provider.ContactsContract;
import at.bitfire.vcard4android.AndroidAddressBook;
import at.bitfire.vcard4android.AndroidContact;
import at.bitfire.vcard4android.AndroidContactFactory;
import at.bitfire.vcard4android.Contact;
import at.bitfire.vcard4android.ContactsStorageException;
public class LocalContact extends AndroidContact {
protected LocalContact(AndroidAddressBook addressBook, long id) {
super(addressBook, id);
protected LocalContact(AndroidAddressBook addressBook, long id, String fileName, String eTag) {
super(addressBook, id, fileName, eTag);
}
public LocalContact(AndroidAddressBook addressBook, Contact contact, String fileName, String eTag) {
super(addressBook, contact, fileName, eTag);
}
public LocalContact(AndroidAddressBook addressBook, Contact contact) {
super(addressBook, contact);
public void updateUID(String uid) throws ContactsStorageException {
try {
ContentValues values = new ContentValues(1);
values.put(COLUMN_UID, uid);
addressBook.provider.update(rawContactSyncURI(), values, null, null);
} catch (RemoteException e) {
throw new ContactsStorageException("Couldn't update UID", e);
}
}
......@@ -28,13 +43,13 @@ public class LocalContact extends AndroidContact {
static final Factory INSTANCE = new Factory();
@Override
public LocalContact newInstance(AndroidAddressBook addressBook, long id) {
return new LocalContact(addressBook, id);
public LocalContact newInstance(AndroidAddressBook addressBook, long id, String fileName, String eTag) {
return new LocalContact(addressBook, id, fileName, eTag);
}
@Override
public LocalContact newInstance(AndroidAddressBook addressBook, Contact contact) {
return new LocalContact(addressBook, contact);
public LocalContact newInstance(AndroidAddressBook addressBook, Contact contact, String fileName, String eTag) {
return new LocalContact(addressBook, contact, fileName, eTag);
}
public LocalContact[] newArray(int size) {
......
Subproject commit 57e1f34c45f070ca9b269f2bea109f6b1cdcb385
Subproject commit 84a2cf0bbad257274e362851020da3822957449d
Subproject commit 644ee03c74d35837974db771a7093f6f28623fbc
Subproject commit 8053287e694d5a1b5c609fbbe3af97775e5a99af
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