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

Commit 6cf05f1c authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 25206 into eclair

* changes:
  Make vCard importer code use Account information if possible.
parents 1f1135a2 d5bc296d
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.pim.vcard;

import android.accounts.Account;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -416,6 +417,7 @@ public class ContactStruct {
    private List<String> mWebsiteList;
    
    private final int mVCardType;
    private final Account mAccount;

    // Each Column of four properties has ISPRIMARY field
    // (See android.provider.Contacts)
@@ -431,7 +433,12 @@ public class ContactStruct {
    }

    public ContactStruct(int vcardType) {
        this(vcardType, null);
    }

    public ContactStruct(int vcardType, Account account) {
        mVCardType = vcardType;
        mAccount = account;
    }

    /**
@@ -1021,7 +1028,12 @@ public class ContactStruct {
            new ArrayList<ContentProviderOperation>();  
        ContentProviderOperation.Builder builder =
            ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);
        if (mAccount != null) {
            builder.withValue(RawContacts.ACCOUNT_NAME, mAccount.name);
            builder.withValue(RawContacts.ACCOUNT_TYPE, mAccount.type);
        } else {
            builder.withValues(new ContentValues());
        }
        operationList.add(builder.build());

        {
+12 −7
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.pim.vcard;

import android.accounts.Account;
import android.util.CharsetUtils;
import android.util.Log;

@@ -59,7 +60,8 @@ public class VCardDataBuilder implements VCardBuilder {
    private String mTargetCharset;
    private boolean mStrictLineBreakParsing;
    
    private int mVCardType;
    final private int mVCardType;
    final private Account mAccount;
    
    // Just for testing.
    private long mTimePushIntoContentResolver;
@@ -67,21 +69,22 @@ public class VCardDataBuilder implements VCardBuilder {
    private List<EntryHandler> mEntryHandlers = new ArrayList<EntryHandler>();
    
    public VCardDataBuilder() {
        this(null, null, false, VCardConfig.VCARD_TYPE_V21_GENERIC);
        this(null, null, false, VCardConfig.VCARD_TYPE_V21_GENERIC, null);
    }

    /**
     * @hide 
     */
    public VCardDataBuilder(int vcardType) {
        this(null, null, false, vcardType);
        this(null, null, false, vcardType, null);
    }

    /**
     * @hide 
     */
    public VCardDataBuilder(String charset, boolean strictLineBreakParsing, int vcardType) {
        this(null, charset, strictLineBreakParsing, vcardType);
    public VCardDataBuilder(String charset,
            boolean strictLineBreakParsing, int vcardType, Account account) {
        this(null, charset, strictLineBreakParsing, vcardType, account);
    }
    
    /**
@@ -90,7 +93,8 @@ public class VCardDataBuilder implements VCardBuilder {
    public VCardDataBuilder(String sourceCharset,
            String targetCharset,
            boolean strictLineBreakParsing,
            int vcardType) {
            int vcardType,
            Account account) {
        if (sourceCharset != null) {
            mSourceCharset = sourceCharset;
        } else {
@@ -103,6 +107,7 @@ public class VCardDataBuilder implements VCardBuilder {
        }
        mStrictLineBreakParsing = strictLineBreakParsing;
        mVCardType = vcardType;
        mAccount = account;
    }
    
    public void addEntryHandler(EntryHandler entryHandler) {
@@ -136,7 +141,7 @@ public class VCardDataBuilder implements VCardBuilder {
            Log.e(LOG_TAG, "This is not VCARD!");
        }

        mCurrentContactStruct = new ContactStruct(mVCardType);
        mCurrentContactStruct = new ContactStruct(mVCardType, mAccount);
    }

    public void endRecord() {