From b55e60e1d88c02078c3d6bc0f408fb0065a1e93c Mon Sep 17 00:00:00 2001 From: Daisuke Miyakawa Date: Thu, 24 Sep 2009 11:12:32 -0700 Subject: [PATCH] Fix vCard code. --- .../java/android/pim/vcard/ContactStruct.java | 125 ++++++++++++++++-- .../java/android/pim/vcard/VCardComposer.java | 12 +- 2 files changed, 118 insertions(+), 19 deletions(-) diff --git a/core/java/android/pim/vcard/ContactStruct.java b/core/java/android/pim/vcard/ContactStruct.java index df0c834ccd9dd..d7fc2d16a15a9 100644 --- a/core/java/android/pim/vcard/ContactStruct.java +++ b/core/java/android/pim/vcard/ContactStruct.java @@ -477,44 +477,148 @@ public class ContactStruct { mPhotoList = photoList; mWebsiteList = websiteList; } + + // All getter methods should be used carefully, since they may change + // in the future as of 2009-09-24, on which I cannot be sure this structure + // is completely consolidated. + // When we are sure we will no longer change them, we'll be happy to + // make it complete public (withouth @hide tag) + // + // Also note that these getter methods should be used only after + // all properties being pushed into this object. If not, incorrect + // value will "be stored in the local cache and" be returned to you. /** - * @hide only for testing. + * @hide + */ + public String getFamilyName() { + return mFamilyName; + } + + /** + * @hide + */ + public String getGivenName() { + return mGivenName; + } + + /** + * @hide + */ + public String getMiddleName() { + return mMiddleName; + } + + /** + * @hide + */ + public String getPrefix() { + return mPrefix; + } + + /** + * @hide + */ + public String getSuffix() { + return mSuffix; + } + + /** + * @hide + */ + public String getFullName() { + return mFullName; + } + + /** + * @hide + */ + public String getPhoneticFamilyName() { + return mPhoneticFamilyName; + } + + /** + * @hide + */ + public String getPhoneticGivenName() { + return mPhoneticGivenName; + } + + /** + * @hide + */ + public String getPhoneticMiddleName() { + return mPhoneticMiddleName; + } + + /** + * @hide + */ + public String getPhoneticFullName() { + return mPhoneticFullName; + } + + /** + * @hide + */ + public final List getNickNameList() { + return mNickNameList; + } + + /** + * @hide + */ + public String getDisplayName() { + if (mDisplayName == null) { + constructDisplayName(); + } + return mDisplayName; + } + + /** + * @hide + */ + public String getBirthday() { + return mBirthday; + } + + /** + * @hide */ public final List getPhotoList() { return mPhotoList; } - + /** - * @hide only for testing. + * @hide */ public final List getNotes() { return mNoteList; } /** - * @hide only for testing. + * @hide */ public final List getPhoneList() { return mPhoneList; } /** - * @hide only for testing. + * @hide */ public final List getEmailList() { return mEmailList; } /** - * @hide only for testing. + * @hide */ public final List getPostalList() { return mPostalList; } /** - * @hide only for testing. + * @hide */ public final List getOrganizationList() { return mOrganizationList; @@ -938,13 +1042,6 @@ public class ContactStruct { // Unknown X- words and IANA token. } } - - public String getDisplayName() { - if (mDisplayName == null) { - constructDisplayName(); - } - return mDisplayName; - } /** * Construct the display name. The constructed data must not be null. diff --git a/core/java/android/pim/vcard/VCardComposer.java b/core/java/android/pim/vcard/VCardComposer.java index 45f7ef3f18c06..cff18bccae02e 100644 --- a/core/java/android/pim/vcard/VCardComposer.java +++ b/core/java/android/pim/vcard/VCardComposer.java @@ -960,10 +960,12 @@ public class VCardComposer { .get(Phone.CONTENT_ITEM_TYPE); if (contentValuesList != null) { for (ContentValues contentValues : contentValuesList) { - appendVCardTelephoneLine(builder, contentValues - .getAsInteger(Phone.TYPE), contentValues - .getAsString(Phone.LABEL), contentValues - .getAsString(Phone.NUMBER)); + Integer phoneType = contentValues.getAsInteger(Phone.TYPE); + int phoneTypeAsPrimitive = + (phoneType == null ? Phone.TYPE_HOME : phoneType); + appendVCardTelephoneLine(builder, phoneTypeAsPrimitive, + contentValues.getAsString(Phone.LABEL), + contentValues.getAsString(Phone.NUMBER)); } } else if (mIsDoCoMo) { appendVCardTelephoneLine(builder, Phone.TYPE_HOME, "", ""); @@ -1090,7 +1092,7 @@ public class VCardComposer { private void appendBirthday(final StringBuilder builder, final Map> contentValuesListMap) { List contentValuesList = contentValuesListMap - .get(Website.CONTENT_ITEM_TYPE); + .get(Miscellaneous.CONTENT_ITEM_TYPE); if (contentValuesList != null && contentValuesList.size() > 0) { // Theoretically, there must be only one birthday for each vCard data and // we are afraid of some parse error occuring in some devices, so