Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 275335ad authored by Ricki Hirner's avatar Ricki Hirner
Browse files

New resource detection

* new resource detection: only CalDAV yet
parent f824386d
Loading
Loading
Loading
Loading
+272 −186

File changed.

Preview size limit exceeded, changes collapsed.

+16 −11
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public class ServerInfo implements Serializable {

	@RequiredArgsConstructor(suppressConstructorProperties=true)
	@Data
	public static class ResourceInfo implements Serializable {
	public static class ResourceInfo implements Cloneable, Serializable {
		public enum Type {
			ADDRESS_BOOK,
			CALENDAR
@@ -64,7 +64,13 @@ public class ServerInfo implements Serializable {


		// copy constructor
		public ResourceInfo(ResourceInfo src) {

        @Override
        public ResourceInfo clone() {
            return new ResourceInfo(this);
        }

        private ResourceInfo(ResourceInfo src) {
            enabled = src.enabled;
            type = src.type;
            readOnly = src.readOnly;
@@ -77,7 +83,6 @@ public class ServerInfo implements Serializable {
            timezone = src.timezone;
        }


		// some logic

		public String getTitle() {
+4 −2
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ package at.bitfire.davdroid.syncadapter;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.ContentProviderClient;
@@ -77,8 +78,8 @@ public class AccountSettings {
            }

            // check whether Android version has changed
            int lastAndroidVersion = NumberUtils.toInt(accountManager.getUserData(account, KEY_LAST_ANDROID_VERSION));
            if (lastAndroidVersion < Build.VERSION.SDK_INT) {
            String lastAndroidVersionInt = accountManager.getUserData(account, KEY_LAST_ANDROID_VERSION);
            if (lastAndroidVersionInt != null && NumberUtils.toInt(lastAndroidVersionInt) < Build.VERSION.SDK_INT) {
                // notify user
                showNotification(Constants.NOTIFICATION_ANDROID_VERSION_UPDATED,
                        context.getString(R.string.settings_android_update_title),
@@ -89,6 +90,7 @@ public class AccountSettings {
		}
	}

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    protected void showNotification(int id, String title, String message) {
        NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification.Builder n = new Notification.Builder(context);
+15 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.squareup.okhttp.ResponseBody;

import org.apache.commons.codec.Charsets;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -72,7 +73,10 @@ public class ContactsSyncManager extends SyncManager {
        // prepare local address book
        localCollection = new LocalAddressBook(account, provider);

        collectionURL = HttpUrl.parse(localAddressBook().getURL());
        String url = localAddressBook().getURL();
        if (url == null)
            throw new ContactsStorageException("Couldn't get address book URL");
        collectionURL = HttpUrl.parse(url);
        davCollection = new DavAddressBook(httpClient, collectionURL);
    }

@@ -101,7 +105,16 @@ public class ContactsSyncManager extends SyncManager {
    @Override
    protected void listRemote() throws IOException, HttpException, DavException {
        // fetch list of remote VCards and build hash table to index file name

        try {
            davAddressBook().addressbookQuery();
        } catch(HttpException e) {
            if (e.status/100 == 4) {
                Constants.log.warn("Server error on REPORT addressbook query, falling back to PROPFIND", e);
                davAddressBook().propfind(1, GetETag.NAME);
            }
        }

        remoteResources = new HashMap<>(davCollection.members.size());
        for (DavResource vCard : davCollection.members) {
            String fileName = vCard.fileName();
+1 −1
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ abstract public class SyncManager {
            Notification notification;
            builder .setSmallIcon(R.drawable.ic_launcher)
                    .setContentTitle(context.getString(R.string.sync_error_title, account.name))
                    .setContentIntent(PendingIntent.getActivity(context, 0, detailsIntent, PendingIntent.FLAG_UPDATE_CURRENT));
                    .setContentIntent(PendingIntent.getActivity(context, 0, detailsIntent, PendingIntent.FLAG_CANCEL_CURRENT));

            if (Build.VERSION.SDK_INT >= 20)
                builder.setLocalOnly(true);
Loading