am 6cf05f1c: Merge change 25206 into eclair
Merge commit '6cf05f1c3d6f4585573c8663a62848a09f6a08ff' into eclair-plus-aosp * commit '6cf05f1c3d6f4585573c8663a62848a09f6a08ff': Make vCard importer code use Account information if possible.
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package android.pim.vcard;
|
package android.pim.vcard;
|
||||||
|
|
||||||
|
import android.accounts.Account;
|
||||||
import android.content.ContentProviderOperation;
|
import android.content.ContentProviderOperation;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
@@ -416,7 +417,8 @@ public class ContactStruct {
|
|||||||
private List<String> mWebsiteList;
|
private List<String> mWebsiteList;
|
||||||
|
|
||||||
private final int mVCardType;
|
private final int mVCardType;
|
||||||
|
private final Account mAccount;
|
||||||
|
|
||||||
// Each Column of four properties has ISPRIMARY field
|
// Each Column of four properties has ISPRIMARY field
|
||||||
// (See android.provider.Contacts)
|
// (See android.provider.Contacts)
|
||||||
// If false even after the parsing loop, we choose the first entry as a "primary"
|
// If false even after the parsing loop, we choose the first entry as a "primary"
|
||||||
@@ -429,9 +431,14 @@ public class ContactStruct {
|
|||||||
public ContactStruct() {
|
public ContactStruct() {
|
||||||
this(VCardConfig.VCARD_TYPE_V21_GENERIC);
|
this(VCardConfig.VCARD_TYPE_V21_GENERIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContactStruct(int vcardType) {
|
public ContactStruct(int vcardType) {
|
||||||
|
this(vcardType, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactStruct(int vcardType, Account account) {
|
||||||
mVCardType = vcardType;
|
mVCardType = vcardType;
|
||||||
|
mAccount = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1021,7 +1028,12 @@ public class ContactStruct {
|
|||||||
new ArrayList<ContentProviderOperation>();
|
new ArrayList<ContentProviderOperation>();
|
||||||
ContentProviderOperation.Builder builder =
|
ContentProviderOperation.Builder builder =
|
||||||
ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);
|
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());
|
operationList.add(builder.build());
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -1183,7 +1195,7 @@ public class ContactStruct {
|
|||||||
builder.withValue(Miscellaneous.BIRTHDAY, mBirthday);
|
builder.withValue(Miscellaneous.BIRTHDAY, mBirthday);
|
||||||
operationList.add(builder.build());
|
operationList.add(builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resolver.applyBatch(ContactsContract.AUTHORITY, operationList);
|
resolver.applyBatch(ContactsContract.AUTHORITY, operationList);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package android.pim.vcard;
|
package android.pim.vcard;
|
||||||
|
|
||||||
|
import android.accounts.Account;
|
||||||
import android.util.CharsetUtils;
|
import android.util.CharsetUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -59,7 +60,8 @@ public class VCardDataBuilder implements VCardBuilder {
|
|||||||
private String mTargetCharset;
|
private String mTargetCharset;
|
||||||
private boolean mStrictLineBreakParsing;
|
private boolean mStrictLineBreakParsing;
|
||||||
|
|
||||||
private int mVCardType;
|
final private int mVCardType;
|
||||||
|
final private Account mAccount;
|
||||||
|
|
||||||
// Just for testing.
|
// Just for testing.
|
||||||
private long mTimePushIntoContentResolver;
|
private long mTimePushIntoContentResolver;
|
||||||
@@ -67,21 +69,22 @@ public class VCardDataBuilder implements VCardBuilder {
|
|||||||
private List<EntryHandler> mEntryHandlers = new ArrayList<EntryHandler>();
|
private List<EntryHandler> mEntryHandlers = new ArrayList<EntryHandler>();
|
||||||
|
|
||||||
public VCardDataBuilder() {
|
public VCardDataBuilder() {
|
||||||
this(null, null, false, VCardConfig.VCARD_TYPE_V21_GENERIC);
|
this(null, null, false, VCardConfig.VCARD_TYPE_V21_GENERIC, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public VCardDataBuilder(int vcardType) {
|
public VCardDataBuilder(int vcardType) {
|
||||||
this(null, null, false, vcardType);
|
this(null, null, false, vcardType, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public VCardDataBuilder(String charset, boolean strictLineBreakParsing, int vcardType) {
|
public VCardDataBuilder(String charset,
|
||||||
this(null, charset, strictLineBreakParsing, vcardType);
|
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,
|
public VCardDataBuilder(String sourceCharset,
|
||||||
String targetCharset,
|
String targetCharset,
|
||||||
boolean strictLineBreakParsing,
|
boolean strictLineBreakParsing,
|
||||||
int vcardType) {
|
int vcardType,
|
||||||
|
Account account) {
|
||||||
if (sourceCharset != null) {
|
if (sourceCharset != null) {
|
||||||
mSourceCharset = sourceCharset;
|
mSourceCharset = sourceCharset;
|
||||||
} else {
|
} else {
|
||||||
@@ -103,6 +107,7 @@ public class VCardDataBuilder implements VCardBuilder {
|
|||||||
}
|
}
|
||||||
mStrictLineBreakParsing = strictLineBreakParsing;
|
mStrictLineBreakParsing = strictLineBreakParsing;
|
||||||
mVCardType = vcardType;
|
mVCardType = vcardType;
|
||||||
|
mAccount = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEntryHandler(EntryHandler entryHandler) {
|
public void addEntryHandler(EntryHandler entryHandler) {
|
||||||
@@ -136,7 +141,7 @@ public class VCardDataBuilder implements VCardBuilder {
|
|||||||
Log.e(LOG_TAG, "This is not VCARD!");
|
Log.e(LOG_TAG, "This is not VCARD!");
|
||||||
}
|
}
|
||||||
|
|
||||||
mCurrentContactStruct = new ContactStruct(mVCardType);
|
mCurrentContactStruct = new ContactStruct(mVCardType, mAccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endRecord() {
|
public void endRecord() {
|
||||||
|
|||||||
Reference in New Issue
Block a user