Add the flag "FLAG_APPEND_TYPE_PARAM" to VCardConfig, which

enables vCard composer to append "TYPE=" to type param/attribute
everytime possible, which should fix the issue 2180800.

issue number: 2180800
This commit is contained in:
Daisuke Miyakawa
2009-10-12 15:05:21 -07:00
parent d48e25d4e3
commit 7c6770c26b
2 changed files with 22 additions and 1 deletions

View File

@ -288,6 +288,7 @@ public class VCardComposer {
private final boolean mUsesUtf8;
private final boolean mUsesShiftJis;
private final boolean mUsesQPToPrimaryProperties;
private final boolean mAppendTypeParamName;
private Cursor mCursor;
private int mIdColumn;
@ -353,6 +354,7 @@ public class VCardComposer {
mUsesUtf8 = VCardConfig.usesUtf8(vcardType);
mUsesShiftJis = VCardConfig.usesShiftJis(vcardType);
mUsesQPToPrimaryProperties = VCardConfig.usesQPToPrimaryProperties(vcardType);
mAppendTypeParamName = VCardConfig.appendTypeParamName(vcardType);
mHandlerList = new ArrayList<OneEntryHandler>();
if (mIsDoCoMo) {
@ -1756,7 +1758,7 @@ public class VCardComposer {
private void appendTypeAttribute(final StringBuilder builder, final String type) {
// Note: In vCard 3.0, Type strings also can be like this: "TYPE=HOME,PREF"
if (mIsV30) {
if (mIsV30 || mAppendTypeParamName) {
builder.append(Constants.ATTR_TYPE).append(VCARD_ATTR_EQUAL);
}
builder.append(type);

View File

@ -106,6 +106,21 @@ public class VCardConfig {
*/
public static final int FLAG_USE_QP_TO_PRIMARY_PROPERTIES = 0x10000000;
/**
* The flag indicating the vCard composer "for 2.1" emits "TYPE=" string every time
* possible. The default behavior does not emit it and is valid, while adding "TYPE="
* is also valid. In vCrad 3.0, this flag is unnecessary, since "TYPE=" is MUST in
* vCard 3.0 specification.
*
* If you are targeting to some importer which cannot accept type attributes (params)
* without "TYPE=" string (which should be rare though), please use this flag.
*
* XXX: Really rare?
*
* e.g. int vcardType = (VCARD_TYPE_V21_GENERIC | FLAG_APPEND_TYPE_PARAM);
*/
public static final int FLAG_APPEND_TYPE_PARAM = 0x08000000;
//// The followings are VCard types available from importer/exporter. ////
/**
@ -300,6 +315,10 @@ public class VCardConfig {
((vcardType & FLAG_USE_QP_TO_PRIMARY_PROPERTIES) != 0));
}
public static boolean appendTypeParamName(int vcardType) {
return (vcardType & FLAG_APPEND_TYPE_PARAM) != 0;
}
private VCardConfig() {
}
}