summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorDaisuke Miyakawa <dmiyakawa@google.com>2009-11-11 08:41:31 +0900
committerDaisuke Miyakawa <dmiyakawa@google.com>2009-11-11 10:03:10 +0900
commit0cda59112526c03f3b8be0eb885926b7515df756 (patch)
tree52eb797ee227994222cc8326618614312e19627f /core/java/android
parent6780d8c006c9381919c0ee4de3d2bdc6d7a728d6 (diff)
downloadframeworks_base-0cda59112526c03f3b8be0eb885926b7515df756.zip
frameworks_base-0cda59112526c03f3b8be0eb885926b7515df756.tar.gz
frameworks_base-0cda59112526c03f3b8be0eb885926b7515df756.tar.bz2
Make vCard composer use ContentValues object with non-empty name unless the object is not marked as IS_SUPER_PRIMARY.
Previous change selected the first ContactValues object even when its name fields are all empty. This time, vCard composer checks the name fields and skip the object withouth valid name. One exception is the object with IS_SUPER_PRIMARY flag. If IS_SUPER_PRIMARY flag is set, the object will be selected even when the object does not have valid name. Add a unit test for this fix. Internal issue number: 2252304
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/pim/vcard/VCardComposer.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/core/java/android/pim/vcard/VCardComposer.java b/core/java/android/pim/vcard/VCardComposer.java
index 5a14f5f..980dd05 100644
--- a/core/java/android/pim/vcard/VCardComposer.java
+++ b/core/java/android/pim/vcard/VCardComposer.java
@@ -676,6 +676,18 @@ public class VCardComposer {
}
}
+ private boolean containsNonEmptyName(ContentValues contentValues) {
+ final String familyName = contentValues.getAsString(StructuredName.FAMILY_NAME);
+ final String middleName = contentValues.getAsString(StructuredName.MIDDLE_NAME);
+ final String givenName = contentValues.getAsString(StructuredName.GIVEN_NAME);
+ final String prefix = contentValues.getAsString(StructuredName.PREFIX);
+ final String suffix = contentValues.getAsString(StructuredName.SUFFIX);
+ final String displayName = contentValues.getAsString(StructuredName.DISPLAY_NAME);
+ return !(TextUtils.isEmpty(familyName) && TextUtils.isEmpty(middleName) &&
+ TextUtils.isEmpty(givenName) && TextUtils.isEmpty(prefix) &&
+ TextUtils.isEmpty(suffix) && TextUtils.isEmpty(displayName));
+ }
+
private void appendStructuredNamesInternal(final StringBuilder builder,
final List<ContentValues> contentValuesList) {
// For safety, we'll emit just one value around StructuredName, as external importers
@@ -695,12 +707,14 @@ public class VCardComposer {
} else if (primaryContentValues == null) {
// We choose the first "primary" ContentValues
// if "super primary" ContentValues does not exist.
- Integer primary = contentValues.getAsInteger(StructuredName.IS_PRIMARY);
- if (primary != null && primary > 0) {
+ Integer isPrimary = contentValues.getAsInteger(StructuredName.IS_PRIMARY);
+ if (isPrimary != null && isPrimary > 0 &&
+ containsNonEmptyName(contentValues)) {
primaryContentValues = contentValues;
// Do not break, since there may be ContentValues with "super primary"
// afterword.
- } else if (subprimaryContentValues == null) {
+ } else if (subprimaryContentValues == null &&
+ containsNonEmptyName(contentValues)) {
subprimaryContentValues = contentValues;
}
}