Merge change 25206 into eclair
* changes: Make vCard importer code use Account information if possible.
This commit is contained in:
@@ -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,7 +417,8 @@ 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)
|
||||
// If false even after the parsing loop, we choose the first entry as a "primary"
|
||||
@@ -429,9 +431,14 @@ public class ContactStruct {
|
||||
public ContactStruct() {
|
||||
this(VCardConfig.VCARD_TYPE_V21_GENERIC);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
builder.withValues(new ContentValues());
|
||||
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());
|
||||
|
||||
{
|
||||
@@ -1183,7 +1195,7 @@ public class ContactStruct {
|
||||
builder.withValue(Miscellaneous.BIRTHDAY, mBirthday);
|
||||
operationList.add(builder.build());
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
resolver.applyBatch(ContactsContract.AUTHORITY, operationList);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user