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

Commit 63e91409 authored by Daniel Lehmann's avatar Daniel Lehmann
Browse files

Framework changes to allow VCards containing multiple entries

Bug:2501468

Change-Id: I004997c6ed9351e2600e7446615af9e60a14fda8
parent 7b00978d
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ import android.content.ContentResolver;
import android.net.Uri;
import android.util.Log;

import java.util.ArrayList;

/**
 * <P>
 * {@link VCardEntryHandler} implementation which commits the entry to ContentResolver.
@@ -35,7 +37,7 @@ public class VCardEntryCommitter implements VCardEntryHandler {

    private final ContentResolver mContentResolver;
    private long mTimeToCommit;
    private Uri mLastCreatedUri;
    private ArrayList<Uri> mCreatedUris = new ArrayList<Uri>();

    public VCardEntryCommitter(ContentResolver resolver) {
        mContentResolver = resolver;
@@ -52,11 +54,21 @@ public class VCardEntryCommitter implements VCardEntryHandler {

    public void onEntryCreated(final VCardEntry contactStruct) {
        long start = System.currentTimeMillis();
        mLastCreatedUri = contactStruct.pushIntoContentResolver(mContentResolver);
        mCreatedUris.add(contactStruct.pushIntoContentResolver(mContentResolver));
        mTimeToCommit += System.currentTimeMillis() - start;
    }

    // TODO: Compatibility function to not break the build. Will be removed shortly
    @Deprecated
    public Uri getLastCreatedUri() {
        return mLastCreatedUri;
        return mCreatedUris.size() == 0 ? null : mCreatedUris.get(mCreatedUris.size() - 1);
    }

    /**
     * Returns the list of created Uris. This list should not be modified by the caller as it is
     * not a clone.
     */
   public ArrayList<Uri> getCreatedUris() {
        return mCreatedUris;
    }
}
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
@@ -886,6 +886,25 @@ public final class ContactsContract {
        public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
                "as_vcard");

        /**
         * Base {@link Uri} for referencing multiple {@link Contacts} entry,
         * created by appending {@link #LOOKUP_KEY} using
         * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be
         * encoded and joined with the colon (":") seperator. The resulting string
         * has to be encoded again. Provides
         * {@link OpenableColumns} columns when queried, or returns the
         * referenced contact formatted as a vCard when opened through
         * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
         *
         * This is private API because we do not have a well-defined way to
         * specify several entities yet. The format of this Uri might change in the future
         * or the Uri might be completely removed.
         *
         * @hide
         */
        public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
                "as_multi_vcard");

        /**
         * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
         * requested {@link Contacts} entry.