Only show 1 phonetic name (per RawContactDelta) on compact editor
Also remove the delete button on the phonetic name
to be consitent with the fully expanded editor.
Bug 19124091
Change-Id: I851943a55d81723af7ec556f4dfef6de4f3d9b5d
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index cb605c6..cad75b9 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -389,13 +389,11 @@
} else if (DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME.equals(mimeType)) {
// Only add phonetic names if there is a non-empty one. Note the use of
// StructuredName mimeType below, even though we matched a pseudo mime type.
- if (hasNonEmptyValuesDelta(
- rawContactDelta, StructuredName.CONTENT_ITEM_TYPE, dataKind)) {
- for (ValuesDelta valuesDelta : getNonEmptyValuesDeltas(
- rawContactDelta, StructuredName.CONTENT_ITEM_TYPE, dataKind)) {
- mPhoneticNames.addView(inflatePhoneticNameEditorView(
- mPhoneticNames, accountType, valuesDelta, rawContactDelta));
- }
+ final ValuesDelta valuesDelta = rawContactDelta.getSuperPrimaryEntry(
+ StructuredName.CONTENT_ITEM_TYPE, /* forceSelection =*/ true);
+ if (hasNonEmptyValue(dataKind, valuesDelta)) {
+ mPhoneticNames.addView(inflatePhoneticNameEditorView(
+ mPhoneticNames, accountType, valuesDelta, rawContactDelta));
}
} else if (Nickname.CONTENT_ITEM_TYPE.equals(mimeType)) {
// Only add nicknames if there is a non-empty one
@@ -486,22 +484,30 @@
return result;
}
for (ValuesDelta valuesDelta : rawContactDelta.getMimeEntries(mimeType)) {
- if (valuesDelta == null) {
- log(Log.VERBOSE, "Null valuesDelta");
- }
- for (EditField editField : dataKind.fieldList) {
- final String column = editField.column;
- final String value = valuesDelta == null ? null : valuesDelta.getAsString(column);
- log(Log.VERBOSE, "Field " + column + " empty=" + TextUtils.isEmpty(value) +
- " value=" + value);
- if (!TextUtils.isEmpty(value)) {
- result.add(valuesDelta);
- }
+ if (hasNonEmptyValue(dataKind, valuesDelta)) {
+ result.add(valuesDelta);
}
}
return result;
}
+ private static boolean hasNonEmptyValue(DataKind dataKind, ValuesDelta valuesDelta) {
+ if (valuesDelta == null) {
+ log(Log.VERBOSE, "Null valuesDelta");
+ return false;
+ }
+ for (EditField editField : dataKind.fieldList) {
+ final String column = editField.column;
+ final String value = valuesDelta == null ? null : valuesDelta.getAsString(column);
+ log(Log.VERBOSE, "Field " + column + " empty=" + TextUtils.isEmpty(value) +
+ " value=" + value);
+ if (!TextUtils.isEmpty(value)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private StructuredNameEditorView inflateStructuredNameEditorView(ViewGroup viewGroup,
AccountType accountType, ValuesDelta valuesDelta, RawContactDelta rawContactDelta,
NameEditorListener nameEditorListener) {
@@ -510,6 +516,7 @@
if (nameEditorListener != null) {
result.setEditorListener(nameEditorListener);
}
+ result.setDeletable(false);
result.setValues(
accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_DISPLAY_NAME),
valuesDelta,
@@ -523,6 +530,7 @@
AccountType accountType, ValuesDelta valuesDelta, RawContactDelta rawContactDelta) {
final PhoneticNameEditorView result = (PhoneticNameEditorView) mLayoutInflater.inflate(
R.layout.phonetic_name_editor_view, viewGroup, /* attachToRoot =*/ false);
+ result.setDeletable(false);
result.setValues(
accountType.getKindForMimetype(DataKind.PSEUDO_MIME_TYPE_PHONETIC_NAME),
valuesDelta,