Prevents empty focus contacts without photo from being created.
Bug: 2133257
Dr No: TS
diff --git a/src/com/android/contacts/model/EntityModifier.java b/src/com/android/contacts/model/EntityModifier.java
index d6f6571..5700df2 100644
--- a/src/com/android/contacts/model/EntityModifier.java
+++ b/src/com/android/contacts/model/EntityModifier.java
@@ -85,7 +85,10 @@
if (!hasChild && kind != null) {
// Create child when none exists and valid kind
- insertChild(state, kind);
+ final ValuesDelta child = insertChild(state, kind);
+ if (kind.mimeType.equals(Photo.CONTENT_ITEM_TYPE)) {
+ child.setFromTemplate(true);
+ }
}
}
@@ -321,7 +324,6 @@
public static ValuesDelta insertChild(EntityDelta state, DataKind kind, EditType type) {
// Bail early if invalid kind
if (kind == null) return null;
-
final ContentValues after = new ContentValues();
// Our parent CONTACT_ID is provided later
@@ -338,7 +340,7 @@
}
final ValuesDelta child = ValuesDelta.fromAfter(after);
- state.addEntry(child);
+ state.addEntry(child);
return child;
}
@@ -385,6 +387,7 @@
state.getValues().getAsString(RawContacts.ACCOUNT_TYPE));
final boolean isPhoto = TextUtils.equals(Photo.CONTENT_ITEM_TYPE, kind.mimeType);
final boolean isGooglePhoto = isPhoto && isGoogleSource;
+
if (EntityModifier.isEmpty(entry, kind) && !isGooglePhoto) {
// TODO: remove this verbose logging
Log.w(TAG, "Trimming: " + entry.toString());
@@ -394,7 +397,6 @@
}
}
}
-
if (!hasValues) {
// Trim overall entity if no children exist
state.markDeleted();
diff --git a/src/com/android/contacts/ui/widget/PhotoEditorView.java b/src/com/android/contacts/ui/widget/PhotoEditorView.java
index 184b907..7dfe3d7 100644
--- a/src/com/android/contacts/ui/widget/PhotoEditorView.java
+++ b/src/com/android/contacts/ui/widget/PhotoEditorView.java
@@ -87,6 +87,7 @@
setImageBitmap(photo);
setEnabled(!readOnly);
mHasSetPhoto = true;
+ mEntry.setFromTemplate(false);
} else {
resetDefault();
}
@@ -125,6 +126,7 @@
mEntry.put(Photo.PHOTO, out.toByteArray());
setImageBitmap(photo);
mHasSetPhoto = true;
+ mEntry.setFromTemplate(false);
} catch (IOException e) {
Log.w(TAG, "Unable to serialize photo: " + e.toString());
}
@@ -135,6 +137,7 @@
setScaleType(ImageView.ScaleType.CENTER);
setImageResource(R.drawable.ic_menu_add_picture);
mHasSetPhoto = false;
+ mEntry.setFromTemplate(true);
}
/** {@inheritDoc} */