Loading core/java/android/pim/vcard/VCardBuilder.java +14 −13 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ public class VCardBuilder { private final boolean mIsJapaneseMobilePhone; private final boolean mOnlyOneNoteFieldIsAvailable; private final boolean mIsDoCoMo; private final boolean mUsesQuotedPrintable; private final boolean mShouldUseQuotedPrintable; private final boolean mUsesAndroidProperty; private final boolean mUsesDefactProperty; private final boolean mUsesUtf8; Loading @@ -110,7 +110,7 @@ public class VCardBuilder { mVCardType = vcardType; mIsV30 = VCardConfig.isV30(vcardType); mUsesQuotedPrintable = VCardConfig.usesQuotedPrintable(vcardType); mShouldUseQuotedPrintable = VCardConfig.shouldUseQuotedPrintable(vcardType); mIsDoCoMo = VCardConfig.isDoCoMo(vcardType); mIsJapaneseMobilePhone = VCardConfig.needsToConvertPhoneticString(vcardType); mOnlyOneNoteFieldIsAvailable = VCardConfig.onlyOneNoteFieldIsAvailable(vcardType); Loading Loading @@ -529,7 +529,7 @@ public class VCardBuilder { if (mUsesDefactProperty) { if (!TextUtils.isEmpty(phoneticGivenName)) { final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticGivenName)); final String encodedPhoneticGivenName; if (reallyUseQuotedPrintable) { Loading @@ -552,7 +552,7 @@ public class VCardBuilder { } if (!TextUtils.isEmpty(phoneticMiddleName)) { final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticMiddleName)); final String encodedPhoneticMiddleName; if (reallyUseQuotedPrintable) { Loading @@ -575,7 +575,7 @@ public class VCardBuilder { } if (!TextUtils.isEmpty(phoneticFamilyName)) { final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticFamilyName)); final String encodedPhoneticFamilyName; if (reallyUseQuotedPrintable) { Loading Loading @@ -846,7 +846,7 @@ public class VCardBuilder { if (!appendCharset && !VCardUtils.containsOnlyPrintableAscii(data)) { appendCharset = true; } if (mUsesQuotedPrintable && if (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(data)) { reallyUseQuotedPrintable = true; break; Loading Loading @@ -1017,13 +1017,13 @@ public class VCardBuilder { final String orgline = orgBuilder.toString(); appendLine(VCardConstants.PROPERTY_ORG, orgline, !VCardUtils.containsOnlyPrintableAscii(orgline), (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(orgline))); if (!TextUtils.isEmpty(title)) { appendLine(VCardConstants.PROPERTY_TITLE, title, !VCardUtils.containsOnlyPrintableAscii(title), (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(title))); } } Loading Loading @@ -1094,7 +1094,7 @@ public class VCardBuilder { final boolean shouldAppendCharsetInfo = !VCardUtils.containsOnlyPrintableAscii(noteStr); final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(noteStr)); appendLine(VCardConstants.PROPERTY_NOTE, noteStr, shouldAppendCharsetInfo, reallyUseQuotedPrintable); Loading @@ -1105,7 +1105,7 @@ public class VCardBuilder { final boolean shouldAppendCharsetInfo = !VCardUtils.containsOnlyPrintableAscii(noteStr); final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(noteStr)); appendLine(VCardConstants.PROPERTY_NOTE, noteStr, shouldAppendCharsetInfo, reallyUseQuotedPrintable); Loading Loading @@ -1541,9 +1541,10 @@ public class VCardBuilder { public void appendLineWithCharsetAndQPDetection(final String propertyName, final List<String> parameterList, final String rawValue) { final boolean needCharset = (mUsesQuotedPrintable && !VCardUtils.containsOnlyPrintableAscii(rawValue)); !VCardUtils.containsOnlyPrintableAscii(rawValue); final boolean reallyUseQuotedPrintable = !VCardUtils.containsOnlyNonCrLfPrintableAscii(rawValue); (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(rawValue)); appendLine(propertyName, parameterList, rawValue, needCharset, reallyUseQuotedPrintable); } Loading @@ -1553,7 +1554,7 @@ public class VCardBuilder { boolean needCharset = false; boolean reallyUseQuotedPrintable = false; for (String rawValue : rawValueList) { if (!needCharset && mUsesQuotedPrintable && if (!needCharset && mShouldUseQuotedPrintable && !VCardUtils.containsOnlyPrintableAscii(rawValue)) { needCharset = true; } Loading core/java/android/pim/vcard/VCardConfig.java +5 −12 Original line number Diff line number Diff line Loading @@ -27,10 +27,7 @@ import java.util.Set; * but in VCardUtils. */ public class VCardConfig { private static final String LOG_TAG = "vcard.VCardConfig"; // TODO: may be better to make the instance of this available and stop using static methods and // one integer. private static final String LOG_TAG = "VCardConfig"; /* package */ static final int LOG_LEVEL_NONE = 0; /* package */ static final int LOG_LEVEL_PERFORMANCE_MEASUREMENT = 0x1; Loading @@ -44,9 +41,6 @@ public class VCardConfig { // decode the unicode to the original charset. If not, this setting will cause some bug. public static final String DEFAULT_CHARSET = "iso-8859-1"; // TODO: make the other codes use this flag public static final boolean IGNORE_CASE_EXCEPT_VALUE = true; public static final int FLAG_V21 = 0; public static final int FLAG_V30 = 1; Loading Loading @@ -319,7 +313,7 @@ public class VCardConfig { FLAG_CONVERT_PHONETIC_NAME_STRINGS | FLAG_REFRAIN_QP_TO_PRIMARY_PROPERTIES); public static final String VCARD_TYPE_V21_JAPANESE_MOBILE_STR = "v21_japanese_mobile"; /* package */ static final String VCARD_TYPE_V21_JAPANESE_MOBILE_STR = "v21_japanese_mobile"; /** * <P> Loading @@ -334,7 +328,7 @@ public class VCardConfig { public static final int VCARD_TYPE_DOCOMO = (VCARD_TYPE_V21_JAPANESE_MOBILE | FLAG_DOCOMO); private static final String VCARD_TYPE_DOCOMO_STR = "docomo"; /* package */ static final String VCARD_TYPE_DOCOMO_STR = "docomo"; public static int VCARD_TYPE_DEFAULT = VCARD_TYPE_V21_GENERIC_UTF8; Loading Loading @@ -369,7 +363,6 @@ public class VCardConfig { if (sVCardTypeMap.containsKey(loweredKey)) { return sVCardTypeMap.get(loweredKey); } else { // XXX: should return the value indicating the input is invalid? Log.e(LOG_TAG, "Unknown vCard type String: \"" + vcardTypeString + "\""); return VCARD_TYPE_DEFAULT; } Loading @@ -379,7 +372,7 @@ public class VCardConfig { return ((vcardType & FLAG_V30) != 0); } public static boolean usesQuotedPrintable(final int vcardType) { public static boolean shouldUseQuotedPrintable(final int vcardType) { return !isV30(vcardType); } Loading Loading @@ -408,7 +401,7 @@ public class VCardConfig { } public static boolean refrainsQPToPrimaryProperties(final int vcardType) { return (!usesQuotedPrintable(vcardType) || return (!shouldUseQuotedPrintable(vcardType) || ((vcardType & FLAG_REFRAIN_QP_TO_PRIMARY_PROPERTIES) != 0)); } Loading core/java/android/pim/vcard/VCardEntry.java +53 −74 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.util.Log; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; Loading @@ -57,11 +58,11 @@ import java.util.Map; public class VCardEntry { private static final String LOG_TAG = "VCardEntry"; private final static int DEFAULT_ORGANIZATION_TYPE = Organization.TYPE_WORK; private static final String ACCOUNT_TYPE_GOOGLE = "com.google"; private static final String GOOGLE_MY_CONTACTS_GROUP = "System Group: My Contacts"; // Key: the name shown in VCard. e.g. "X-AIM", "X-ICQ" // Value: the result of {@link Contacts.ContactMethods#encodePredefinedImProtocol} private static final Map<String, Integer> sImMap = new HashMap<String, Integer>(); static { Loading Loading @@ -107,9 +108,6 @@ public class VCardEntry { } } /** * @hide only for testing */ static public class EmailData { public final int type; public final String data; Loading Loading @@ -154,17 +152,12 @@ public class VCardEntry { public final String region; public final String postalCode; public final String country; public final int type; // Used only when type variable is TYPE_CUSTOM. public final String label; // isPrimary is changable only when there's no appropriate one existing in // the original VCard. public boolean isPrimary; public PostalData(int type, List<String> propValueList, String label, boolean isPrimary) { public PostalData(final int type, final List<String> propValueList, final String label, boolean isPrimary) { this.type = type; dataArray = new String[ADDR_MAX_DATA_SIZE]; Loading Loading @@ -197,7 +190,6 @@ public class VCardEntry { this.region = dataArray[4]; this.postalCode = dataArray[5]; this.country = dataArray[6]; this.label = label; this.isPrimary = isPrimary; } Loading @@ -207,7 +199,7 @@ public class VCardEntry { if (!(obj instanceof PostalData)) { return false; } PostalData postalData = (PostalData)obj; final PostalData postalData = (PostalData)obj; return (Arrays.equals(dataArray, postalData.dataArray) && (type == postalData.type && (type == StructuredPostal.TYPE_CUSTOM ? Loading @@ -215,7 +207,7 @@ public class VCardEntry { (isPrimary == postalData.isPrimary)); } public String getFormattedAddress(int vcardType) { public String getFormattedAddress(final int vcardType) { StringBuilder builder = new StringBuilder(); boolean empty = true; if (VCardConfig.isJapaneseDevice(vcardType)) { Loading @@ -225,9 +217,10 @@ public class VCardEntry { if (!TextUtils.isEmpty(addressPart)) { if (!empty) { builder.append(' '); } else { empty = false; } builder.append(addressPart); empty = false; } } } else { Loading @@ -236,9 +229,10 @@ public class VCardEntry { if (!TextUtils.isEmpty(addressPart)) { if (!empty) { builder.append(' '); } else { empty = false; } builder.append(addressPart); empty = false; } } } Loading @@ -255,14 +249,13 @@ public class VCardEntry { static public class OrganizationData { public final int type; // non-final is Intended: we may change the values since this info is separated into // non-final is Intentional: we may change the values since this info is separated into // two parts in vCard: "ORG" + "TITLE". public String companyName; public String departmentName; public String titleName; // isPrimary is changable only when there's no appropriate one existing in // the original VCard. public boolean isPrimary; public OrganizationData(int type, String companyName, String departmentName, Loading Loading @@ -303,8 +296,8 @@ public class VCardEntry { public final String data; public final boolean isPrimary; public ImData(int protocol, String customProtocol, int type, String data, boolean isPrimary) { public ImData(final int protocol, final String customProtocol, final int type, final String data, final boolean isPrimary) { this.protocol = protocol; this.customProtocol = customProtocol; this.type = type; Loading Loading @@ -333,7 +326,7 @@ public class VCardEntry { } } static public class PhotoData { public static class PhotoData { public static final String FORMAT_FLASH = "SWF"; public final int type; public final String formatName; // used when type is not defined in ContactsContract. Loading Loading @@ -367,7 +360,7 @@ public class VCardEntry { } } static /* package */ class Property { /* package */ static class Property { private String mPropertyName; private Map<String, Collection<String>> mParameterMap = new HashMap<String, Collection<String>>(); Loading Loading @@ -464,18 +457,12 @@ public class VCardEntry { mAccount = account; } /** * Add a phone info to phoneList. * @param data phone number * @param type type col of content://contacts/phones * @param label lable col of content://contacts/phones */ private void addPhone(int type, String data, String label, boolean isPrimary) { if (mPhoneList == null) { mPhoneList = new ArrayList<PhoneData>(); } StringBuilder builder = new StringBuilder(); String trimed = data.trim(); final StringBuilder builder = new StringBuilder(); final String trimed = data.trim(); final String formattedNumber; if (type == Phone.TYPE_PAGER) { formattedNumber = trimed; Loading Loading @@ -532,13 +519,15 @@ public class VCardEntry { departmentName, titleName, isPrimary)); } private static final List<String> sEmptyList = new ArrayList<String>(0); private static final List<String> sEmptyList = Collections.unmodifiableList(new ArrayList<String>(0)); /** * Set "ORG" related values to the appropriate data. If there's more than one * OrganizationData objects, this input data are attached to the last one which does not * have valid values (not including empty but only null). If there's no * OrganizationData object, a new OrganizationData is created, whose title is set to null. * {@link OrganizationData} objects, this input data are attached to the last one which * does not have valid values (not including empty but only null). If there's no * {@link OrganizationData} object, a new {@link OrganizationData} is created, * whose title is set to null. */ private void handleOrgValue(final int type, List<String> orgList, boolean isPrimary) { if (orgList == null) { Loading Loading @@ -596,8 +585,6 @@ public class VCardEntry { addNewOrganization(type, companyName, departmentName, null, isPrimary); } private final static int DEFAULT_ORGANIZATION_TYPE = Organization.TYPE_WORK; /** * Set "title" value to the appropriate data. If there's more than one * OrganizationData objects, this input is attached to the last one which does not Loading Loading @@ -659,21 +646,16 @@ public class VCardEntry { switch (size) { // fallthrough case 5: mSuffix = elems.get(4); case 4: mPrefix = elems.get(3); case 3: mMiddleName = elems.get(2); case 2: mGivenName = elems.get(1); default: mFamilyName = elems.get(0); case 5: mSuffix = elems.get(4); case 4: mPrefix = elems.get(3); case 3: mMiddleName = elems.get(2); case 2: mGivenName = elems.get(1); default: mFamilyName = elems.get(0); } } /** * Some Japanese mobile phones use this field for phonetic name, * Note: Some Japanese mobile phones use this field for phonetic name, * since vCard 2.1 does not have "SORT-STRING" type. * Also, in some cases, the field has some ';'s in it. * Assume the ';' means the same meaning in N property Loading Loading @@ -729,17 +711,14 @@ public class VCardEntry { switch (size) { // fallthrough case 3: mPhoneticMiddleName = elems.get(2); case 2: mPhoneticGivenName = elems.get(1); default: mPhoneticFamilyName = elems.get(0); case 3: mPhoneticMiddleName = elems.get(2); case 2: mPhoneticGivenName = elems.get(1); default: mPhoneticFamilyName = elems.get(0); } } public void addProperty(Property property) { String propName = property.mPropertyName; public void addProperty(final Property property) { final String propName = property.mPropertyName; final Map<String, Collection<String>> paramMap = property.mParameterMap; final List<String> propValueList = property.mPropertyValueList; byte[] propBytes = property.mPropertyBytes; Loading core/java/android/pim/vcard/VCardEntryCommitter.java +10 −7 Original line number Diff line number Diff line Loading @@ -19,17 +19,20 @@ import android.content.ContentResolver; import android.util.Log; /** * EntryHandler implementation which commits the entry to ContentResolver. * * Note: * <P> * {@link VCardEntryHandler} implementation which commits the entry to ContentResolver. * </P> * <P> * Note:<BR /> * Each vCard may contain big photo images encoded by BASE64, * If we store all vCard entries in memory, OutOfMemoryError may be thrown. * Thus, this class push each VCard entry into ContentResolver immediately. * </P> */ public class VCardEntryCommitter implements VCardEntryHandler { public static String LOG_TAG = "vcard.EntryComitter"; public static String LOG_TAG = "VCardEntryComitter"; private ContentResolver mContentResolver; private final ContentResolver mContentResolver; private long mTimeToCommit; public VCardEntryCommitter(ContentResolver resolver) { Loading core/java/android/pim/vcard/VCardEntryConstructor.java +51 −74 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/java/android/pim/vcard/VCardBuilder.java +14 −13 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ public class VCardBuilder { private final boolean mIsJapaneseMobilePhone; private final boolean mOnlyOneNoteFieldIsAvailable; private final boolean mIsDoCoMo; private final boolean mUsesQuotedPrintable; private final boolean mShouldUseQuotedPrintable; private final boolean mUsesAndroidProperty; private final boolean mUsesDefactProperty; private final boolean mUsesUtf8; Loading @@ -110,7 +110,7 @@ public class VCardBuilder { mVCardType = vcardType; mIsV30 = VCardConfig.isV30(vcardType); mUsesQuotedPrintable = VCardConfig.usesQuotedPrintable(vcardType); mShouldUseQuotedPrintable = VCardConfig.shouldUseQuotedPrintable(vcardType); mIsDoCoMo = VCardConfig.isDoCoMo(vcardType); mIsJapaneseMobilePhone = VCardConfig.needsToConvertPhoneticString(vcardType); mOnlyOneNoteFieldIsAvailable = VCardConfig.onlyOneNoteFieldIsAvailable(vcardType); Loading Loading @@ -529,7 +529,7 @@ public class VCardBuilder { if (mUsesDefactProperty) { if (!TextUtils.isEmpty(phoneticGivenName)) { final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticGivenName)); final String encodedPhoneticGivenName; if (reallyUseQuotedPrintable) { Loading @@ -552,7 +552,7 @@ public class VCardBuilder { } if (!TextUtils.isEmpty(phoneticMiddleName)) { final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticMiddleName)); final String encodedPhoneticMiddleName; if (reallyUseQuotedPrintable) { Loading @@ -575,7 +575,7 @@ public class VCardBuilder { } if (!TextUtils.isEmpty(phoneticFamilyName)) { final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(phoneticFamilyName)); final String encodedPhoneticFamilyName; if (reallyUseQuotedPrintable) { Loading Loading @@ -846,7 +846,7 @@ public class VCardBuilder { if (!appendCharset && !VCardUtils.containsOnlyPrintableAscii(data)) { appendCharset = true; } if (mUsesQuotedPrintable && if (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(data)) { reallyUseQuotedPrintable = true; break; Loading Loading @@ -1017,13 +1017,13 @@ public class VCardBuilder { final String orgline = orgBuilder.toString(); appendLine(VCardConstants.PROPERTY_ORG, orgline, !VCardUtils.containsOnlyPrintableAscii(orgline), (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(orgline))); if (!TextUtils.isEmpty(title)) { appendLine(VCardConstants.PROPERTY_TITLE, title, !VCardUtils.containsOnlyPrintableAscii(title), (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(title))); } } Loading Loading @@ -1094,7 +1094,7 @@ public class VCardBuilder { final boolean shouldAppendCharsetInfo = !VCardUtils.containsOnlyPrintableAscii(noteStr); final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(noteStr)); appendLine(VCardConstants.PROPERTY_NOTE, noteStr, shouldAppendCharsetInfo, reallyUseQuotedPrintable); Loading @@ -1105,7 +1105,7 @@ public class VCardBuilder { final boolean shouldAppendCharsetInfo = !VCardUtils.containsOnlyPrintableAscii(noteStr); final boolean reallyUseQuotedPrintable = (mUsesQuotedPrintable && (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(noteStr)); appendLine(VCardConstants.PROPERTY_NOTE, noteStr, shouldAppendCharsetInfo, reallyUseQuotedPrintable); Loading Loading @@ -1541,9 +1541,10 @@ public class VCardBuilder { public void appendLineWithCharsetAndQPDetection(final String propertyName, final List<String> parameterList, final String rawValue) { final boolean needCharset = (mUsesQuotedPrintable && !VCardUtils.containsOnlyPrintableAscii(rawValue)); !VCardUtils.containsOnlyPrintableAscii(rawValue); final boolean reallyUseQuotedPrintable = !VCardUtils.containsOnlyNonCrLfPrintableAscii(rawValue); (mShouldUseQuotedPrintable && !VCardUtils.containsOnlyNonCrLfPrintableAscii(rawValue)); appendLine(propertyName, parameterList, rawValue, needCharset, reallyUseQuotedPrintable); } Loading @@ -1553,7 +1554,7 @@ public class VCardBuilder { boolean needCharset = false; boolean reallyUseQuotedPrintable = false; for (String rawValue : rawValueList) { if (!needCharset && mUsesQuotedPrintable && if (!needCharset && mShouldUseQuotedPrintable && !VCardUtils.containsOnlyPrintableAscii(rawValue)) { needCharset = true; } Loading
core/java/android/pim/vcard/VCardConfig.java +5 −12 Original line number Diff line number Diff line Loading @@ -27,10 +27,7 @@ import java.util.Set; * but in VCardUtils. */ public class VCardConfig { private static final String LOG_TAG = "vcard.VCardConfig"; // TODO: may be better to make the instance of this available and stop using static methods and // one integer. private static final String LOG_TAG = "VCardConfig"; /* package */ static final int LOG_LEVEL_NONE = 0; /* package */ static final int LOG_LEVEL_PERFORMANCE_MEASUREMENT = 0x1; Loading @@ -44,9 +41,6 @@ public class VCardConfig { // decode the unicode to the original charset. If not, this setting will cause some bug. public static final String DEFAULT_CHARSET = "iso-8859-1"; // TODO: make the other codes use this flag public static final boolean IGNORE_CASE_EXCEPT_VALUE = true; public static final int FLAG_V21 = 0; public static final int FLAG_V30 = 1; Loading Loading @@ -319,7 +313,7 @@ public class VCardConfig { FLAG_CONVERT_PHONETIC_NAME_STRINGS | FLAG_REFRAIN_QP_TO_PRIMARY_PROPERTIES); public static final String VCARD_TYPE_V21_JAPANESE_MOBILE_STR = "v21_japanese_mobile"; /* package */ static final String VCARD_TYPE_V21_JAPANESE_MOBILE_STR = "v21_japanese_mobile"; /** * <P> Loading @@ -334,7 +328,7 @@ public class VCardConfig { public static final int VCARD_TYPE_DOCOMO = (VCARD_TYPE_V21_JAPANESE_MOBILE | FLAG_DOCOMO); private static final String VCARD_TYPE_DOCOMO_STR = "docomo"; /* package */ static final String VCARD_TYPE_DOCOMO_STR = "docomo"; public static int VCARD_TYPE_DEFAULT = VCARD_TYPE_V21_GENERIC_UTF8; Loading Loading @@ -369,7 +363,6 @@ public class VCardConfig { if (sVCardTypeMap.containsKey(loweredKey)) { return sVCardTypeMap.get(loweredKey); } else { // XXX: should return the value indicating the input is invalid? Log.e(LOG_TAG, "Unknown vCard type String: \"" + vcardTypeString + "\""); return VCARD_TYPE_DEFAULT; } Loading @@ -379,7 +372,7 @@ public class VCardConfig { return ((vcardType & FLAG_V30) != 0); } public static boolean usesQuotedPrintable(final int vcardType) { public static boolean shouldUseQuotedPrintable(final int vcardType) { return !isV30(vcardType); } Loading Loading @@ -408,7 +401,7 @@ public class VCardConfig { } public static boolean refrainsQPToPrimaryProperties(final int vcardType) { return (!usesQuotedPrintable(vcardType) || return (!shouldUseQuotedPrintable(vcardType) || ((vcardType & FLAG_REFRAIN_QP_TO_PRIMARY_PROPERTIES) != 0)); } Loading
core/java/android/pim/vcard/VCardEntry.java +53 −74 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ import android.util.Log; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; Loading @@ -57,11 +58,11 @@ import java.util.Map; public class VCardEntry { private static final String LOG_TAG = "VCardEntry"; private final static int DEFAULT_ORGANIZATION_TYPE = Organization.TYPE_WORK; private static final String ACCOUNT_TYPE_GOOGLE = "com.google"; private static final String GOOGLE_MY_CONTACTS_GROUP = "System Group: My Contacts"; // Key: the name shown in VCard. e.g. "X-AIM", "X-ICQ" // Value: the result of {@link Contacts.ContactMethods#encodePredefinedImProtocol} private static final Map<String, Integer> sImMap = new HashMap<String, Integer>(); static { Loading Loading @@ -107,9 +108,6 @@ public class VCardEntry { } } /** * @hide only for testing */ static public class EmailData { public final int type; public final String data; Loading Loading @@ -154,17 +152,12 @@ public class VCardEntry { public final String region; public final String postalCode; public final String country; public final int type; // Used only when type variable is TYPE_CUSTOM. public final String label; // isPrimary is changable only when there's no appropriate one existing in // the original VCard. public boolean isPrimary; public PostalData(int type, List<String> propValueList, String label, boolean isPrimary) { public PostalData(final int type, final List<String> propValueList, final String label, boolean isPrimary) { this.type = type; dataArray = new String[ADDR_MAX_DATA_SIZE]; Loading Loading @@ -197,7 +190,6 @@ public class VCardEntry { this.region = dataArray[4]; this.postalCode = dataArray[5]; this.country = dataArray[6]; this.label = label; this.isPrimary = isPrimary; } Loading @@ -207,7 +199,7 @@ public class VCardEntry { if (!(obj instanceof PostalData)) { return false; } PostalData postalData = (PostalData)obj; final PostalData postalData = (PostalData)obj; return (Arrays.equals(dataArray, postalData.dataArray) && (type == postalData.type && (type == StructuredPostal.TYPE_CUSTOM ? Loading @@ -215,7 +207,7 @@ public class VCardEntry { (isPrimary == postalData.isPrimary)); } public String getFormattedAddress(int vcardType) { public String getFormattedAddress(final int vcardType) { StringBuilder builder = new StringBuilder(); boolean empty = true; if (VCardConfig.isJapaneseDevice(vcardType)) { Loading @@ -225,9 +217,10 @@ public class VCardEntry { if (!TextUtils.isEmpty(addressPart)) { if (!empty) { builder.append(' '); } else { empty = false; } builder.append(addressPart); empty = false; } } } else { Loading @@ -236,9 +229,10 @@ public class VCardEntry { if (!TextUtils.isEmpty(addressPart)) { if (!empty) { builder.append(' '); } else { empty = false; } builder.append(addressPart); empty = false; } } } Loading @@ -255,14 +249,13 @@ public class VCardEntry { static public class OrganizationData { public final int type; // non-final is Intended: we may change the values since this info is separated into // non-final is Intentional: we may change the values since this info is separated into // two parts in vCard: "ORG" + "TITLE". public String companyName; public String departmentName; public String titleName; // isPrimary is changable only when there's no appropriate one existing in // the original VCard. public boolean isPrimary; public OrganizationData(int type, String companyName, String departmentName, Loading Loading @@ -303,8 +296,8 @@ public class VCardEntry { public final String data; public final boolean isPrimary; public ImData(int protocol, String customProtocol, int type, String data, boolean isPrimary) { public ImData(final int protocol, final String customProtocol, final int type, final String data, final boolean isPrimary) { this.protocol = protocol; this.customProtocol = customProtocol; this.type = type; Loading Loading @@ -333,7 +326,7 @@ public class VCardEntry { } } static public class PhotoData { public static class PhotoData { public static final String FORMAT_FLASH = "SWF"; public final int type; public final String formatName; // used when type is not defined in ContactsContract. Loading Loading @@ -367,7 +360,7 @@ public class VCardEntry { } } static /* package */ class Property { /* package */ static class Property { private String mPropertyName; private Map<String, Collection<String>> mParameterMap = new HashMap<String, Collection<String>>(); Loading Loading @@ -464,18 +457,12 @@ public class VCardEntry { mAccount = account; } /** * Add a phone info to phoneList. * @param data phone number * @param type type col of content://contacts/phones * @param label lable col of content://contacts/phones */ private void addPhone(int type, String data, String label, boolean isPrimary) { if (mPhoneList == null) { mPhoneList = new ArrayList<PhoneData>(); } StringBuilder builder = new StringBuilder(); String trimed = data.trim(); final StringBuilder builder = new StringBuilder(); final String trimed = data.trim(); final String formattedNumber; if (type == Phone.TYPE_PAGER) { formattedNumber = trimed; Loading Loading @@ -532,13 +519,15 @@ public class VCardEntry { departmentName, titleName, isPrimary)); } private static final List<String> sEmptyList = new ArrayList<String>(0); private static final List<String> sEmptyList = Collections.unmodifiableList(new ArrayList<String>(0)); /** * Set "ORG" related values to the appropriate data. If there's more than one * OrganizationData objects, this input data are attached to the last one which does not * have valid values (not including empty but only null). If there's no * OrganizationData object, a new OrganizationData is created, whose title is set to null. * {@link OrganizationData} objects, this input data are attached to the last one which * does not have valid values (not including empty but only null). If there's no * {@link OrganizationData} object, a new {@link OrganizationData} is created, * whose title is set to null. */ private void handleOrgValue(final int type, List<String> orgList, boolean isPrimary) { if (orgList == null) { Loading Loading @@ -596,8 +585,6 @@ public class VCardEntry { addNewOrganization(type, companyName, departmentName, null, isPrimary); } private final static int DEFAULT_ORGANIZATION_TYPE = Organization.TYPE_WORK; /** * Set "title" value to the appropriate data. If there's more than one * OrganizationData objects, this input is attached to the last one which does not Loading Loading @@ -659,21 +646,16 @@ public class VCardEntry { switch (size) { // fallthrough case 5: mSuffix = elems.get(4); case 4: mPrefix = elems.get(3); case 3: mMiddleName = elems.get(2); case 2: mGivenName = elems.get(1); default: mFamilyName = elems.get(0); case 5: mSuffix = elems.get(4); case 4: mPrefix = elems.get(3); case 3: mMiddleName = elems.get(2); case 2: mGivenName = elems.get(1); default: mFamilyName = elems.get(0); } } /** * Some Japanese mobile phones use this field for phonetic name, * Note: Some Japanese mobile phones use this field for phonetic name, * since vCard 2.1 does not have "SORT-STRING" type. * Also, in some cases, the field has some ';'s in it. * Assume the ';' means the same meaning in N property Loading Loading @@ -729,17 +711,14 @@ public class VCardEntry { switch (size) { // fallthrough case 3: mPhoneticMiddleName = elems.get(2); case 2: mPhoneticGivenName = elems.get(1); default: mPhoneticFamilyName = elems.get(0); case 3: mPhoneticMiddleName = elems.get(2); case 2: mPhoneticGivenName = elems.get(1); default: mPhoneticFamilyName = elems.get(0); } } public void addProperty(Property property) { String propName = property.mPropertyName; public void addProperty(final Property property) { final String propName = property.mPropertyName; final Map<String, Collection<String>> paramMap = property.mParameterMap; final List<String> propValueList = property.mPropertyValueList; byte[] propBytes = property.mPropertyBytes; Loading
core/java/android/pim/vcard/VCardEntryCommitter.java +10 −7 Original line number Diff line number Diff line Loading @@ -19,17 +19,20 @@ import android.content.ContentResolver; import android.util.Log; /** * EntryHandler implementation which commits the entry to ContentResolver. * * Note: * <P> * {@link VCardEntryHandler} implementation which commits the entry to ContentResolver. * </P> * <P> * Note:<BR /> * Each vCard may contain big photo images encoded by BASE64, * If we store all vCard entries in memory, OutOfMemoryError may be thrown. * Thus, this class push each VCard entry into ContentResolver immediately. * </P> */ public class VCardEntryCommitter implements VCardEntryHandler { public static String LOG_TAG = "vcard.EntryComitter"; public static String LOG_TAG = "VCardEntryComitter"; private ContentResolver mContentResolver; private final ContentResolver mContentResolver; private long mTimeToCommit; public VCardEntryCommitter(ContentResolver resolver) { Loading
core/java/android/pim/vcard/VCardEntryConstructor.java +51 −74 File changed.Preview size limit exceeded, changes collapsed. Show changes