From 63e914096ebfc767dc764519e41a2f4d8e578791 Mon Sep 17 00:00:00 2001 From: Daniel Lehmann Date: Fri, 12 Mar 2010 13:44:31 -0800 Subject: Framework changes to allow VCards containing multiple entries Bug:2501468 Change-Id: I004997c6ed9351e2600e7446615af9e60a14fda8 --- core/java/android/pim/vcard/VCardEntryCommitter.java | 18 +++++++++++++++--- core/java/android/provider/ContactsContract.java | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/core/java/android/pim/vcard/VCardEntryCommitter.java b/core/java/android/pim/vcard/VCardEntryCommitter.java index 3cd64b0..2f99e4a 100644 --- a/core/java/android/pim/vcard/VCardEntryCommitter.java +++ b/core/java/android/pim/vcard/VCardEntryCommitter.java @@ -19,6 +19,8 @@ import android.content.ContentResolver; import android.net.Uri; import android.util.Log; +import java.util.ArrayList; + /** *

* {@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 mCreatedUris = new ArrayList(); 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 getCreatedUris() { + return mCreatedUris; } } \ No newline at end of file diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java index c06a1e2..40a408a 100644 --- a/core/java/android/provider/ContactsContract.java +++ b/core/java/android/provider/ContactsContract.java @@ -887,6 +887,25 @@ public final class ContactsContract { "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. * -- cgit v1.1