am 7390c5af: Merge change 24097 into eclair

Merge commit '7390c5af7a0c2379fa72218ea63a714f843edf0f' into eclair-plus-aosp

* commit '7390c5af7a0c2379fa72218ea63a714f843edf0f':
  Fix small bugs in VCardComposer.java.
This commit is contained in:
Daisuke Miyakawa
2009-09-08 13:41:39 -07:00
committed by Android Git Automerger
2 changed files with 17 additions and 6 deletions

View File

@@ -103,7 +103,7 @@ public class VCardComposer {
private OutputStream mOutputStream; // mWriter will close this. private OutputStream mOutputStream; // mWriter will close this.
private Writer mWriter; private Writer mWriter;
private boolean mFinishIsCalled = false; private boolean mOnTerminateIsCalled = false;
/** /**
* Input stream will be closed on the detruction of this object. * Input stream will be closed on the detruction of this object.
@@ -152,6 +152,7 @@ public class VCardComposer {
} }
public void onTerminate() { public void onTerminate() {
mOnTerminateIsCalled = true;
if (mWriter != null) { if (mWriter != null) {
try { try {
// Flush and sync the data so that a user is able to pull // Flush and sync the data so that a user is able to pull
@@ -177,7 +178,7 @@ public class VCardComposer {
@Override @Override
public void finalize() { public void finalize() {
if (!mFinishIsCalled) { if (!mOnTerminateIsCalled) {
onTerminate(); onTerminate();
} }
} }
@@ -604,11 +605,11 @@ public class VCardComposer {
// FN property // FN property
builder.append(VCARD_PROPERTY_FULL_NAME); builder.append(VCARD_PROPERTY_FULL_NAME);
builder.append(VCARD_ATTR_SEPARATOR);
if (!VCardUtils.containsOnlyAscii(encodedFullname)) { if (!VCardUtils.containsOnlyAscii(encodedFullname)) {
builder.append(VCARD_ATTR_SEPARATOR);
builder.append(mVCardAttributeCharset); builder.append(mVCardAttributeCharset);
builder.append(VCARD_DATA_SEPARATOR);
} }
builder.append(VCARD_DATA_SEPARATOR);
builder.append(encodedFullname); builder.append(encodedFullname);
builder.append(VCARD_COL_SEPARATOR); builder.append(VCARD_COL_SEPARATOR);
} else if (!TextUtils.isEmpty(displayName)) { } else if (!TextUtils.isEmpty(displayName)) {
@@ -1242,6 +1243,9 @@ public class VCardComposer {
case Email.TYPE_OTHER: case Email.TYPE_OTHER:
builder.append(Constants.ATTR_TYPE_INTERNET); builder.append(Constants.ATTR_TYPE_INTERNET);
break; break;
case Email.TYPE_MOBILE:
builder.append(Constants.ATTR_TYPE_CELL);
break;
default: default:
Log.e(LOG_TAG, "Unknown Email type: " + type); Log.e(LOG_TAG, "Unknown Email type: " + type);
builder.append(Constants.ATTR_TYPE_INTERNET); builder.append(Constants.ATTR_TYPE_INTERNET);

View File

@@ -47,6 +47,8 @@ public class VCardParser_V30 extends VCardParser_V21 {
private String mPreviousLine; private String mPreviousLine;
private boolean mEmittedAgentWarning = false;
@Override @Override
protected String getVersion() { protected String getVersion() {
return Constants.VERSION_V30; return Constants.VERSION_V30;
@@ -221,7 +223,7 @@ public class VCardParser_V30 extends VCardParser_V21 {
} }
@Override @Override
protected void handleAgent(String propertyValue) throws VCardException { protected void handleAgent(String propertyValue) {
// The way how vCard 3.0 supports "AGENT" is completely different from vCard 2.0. // The way how vCard 3.0 supports "AGENT" is completely different from vCard 2.0.
// //
// e.g. // e.g.
@@ -238,7 +240,12 @@ public class VCardParser_V30 extends VCardParser_V21 {
// CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com // CID:JQPUBLIC.part3.960129T083020.xyzMail@host3.com
// //
// This is not VCARD. Should we support this? // This is not VCARD. Should we support this?
throw new VCardException("AGENT in vCard 3.0 is not supported yet."); // throw new VCardException("AGENT in vCard 3.0 is not supported yet.");
if (!mEmittedAgentWarning) {
Log.w(LOG_TAG, "AGENT in vCard 3.0 is not supported yet. Ignore it");
mEmittedAgentWarning = true;
}
// Just ignore the line for now, since we cannot know how to handle it...
} }
/** /**