Merge "Fix a broken test by supplying the DataKind for structured name"
diff --git a/src/com/android/contacts/editor/LabeledEditorView.java b/src/com/android/contacts/editor/LabeledEditorView.java
index ebd35f9..a6815a7 100644
--- a/src/com/android/contacts/editor/LabeledEditorView.java
+++ b/src/com/android/contacts/editor/LabeledEditorView.java
@@ -341,8 +341,12 @@
}
protected boolean isFieldChanged(String column, String value) {
- String oldValue = mEntry.getAsString(column);
- return !TextUtils.equals(oldValue, value);
+ final String dbValue = mEntry.getAsString(column);
+ // nullable fields (e.g. Middle Name) are usually represented as empty columns,
+ // so lets treat null and empty space equivalently here
+ final String dbValueNoNull = dbValue == null ? "" : dbValue;
+ final String valueNoNull = value == null ? "" : value;
+ return !TextUtils.equals(dbValueNoNull, valueNoNull);
}
protected void rebuildValues() {
diff --git a/src/com/android/contacts/model/EntityModifier.java b/src/com/android/contacts/model/EntityModifier.java
index ab19a35..1e014ef 100644
--- a/src/com/android/contacts/model/EntityModifier.java
+++ b/src/com/android/contacts/model/EntityModifier.java
@@ -430,8 +430,10 @@
if (entries == null) continue;
for (ValuesDelta entry : entries) {
- if ((entry.isInsert() || entry.isUpdate() || entry.isDelete())
- && !isEmpty(entry, kind)) {
+ // An empty Insert must be ignored, because it won't save anything (an example
+ // is an empty name that stays empty)
+ final boolean isRealInsert = entry.isInsert() && !isEmpty(entry, kind);
+ if (isRealInsert || entry.isUpdate() || entry.isDelete()) {
return true;
}
}
diff --git a/src/com/android/contacts/vcard/ExportProcessor.java b/src/com/android/contacts/vcard/ExportProcessor.java
index 9c25aa8..42a71b1 100644
--- a/src/com/android/contacts/vcard/ExportProcessor.java
+++ b/src/com/android/contacts/vcard/ExportProcessor.java
@@ -28,6 +28,7 @@
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
+import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.RawContactsEntity;
import android.text.TextUtils;
import android.util.Log;
@@ -135,7 +136,10 @@
final Uri contentUriForRawContactsEntity = RawContactsEntity.CONTENT_URI.buildUpon()
.appendQueryParameter(RawContactsEntity.FOR_EXPORT_ONLY, "1")
.build();
- if (!composer.initWithRawContactsEntityUri(contentUriForRawContactsEntity)) {
+ // TODO: should provide better selection.
+ if (!composer.init(Contacts.CONTENT_URI, new String[] {Contacts._ID},
+ null, null,
+ null, contentUriForRawContactsEntity)) {
final String errorReason = composer.getErrorReason();
Log.e(LOG_TAG, "initialization of vCard composer failed: " + errorReason);
final String translatedErrorReason =