diff options
author | Walter Jang <wjang@google.com> | 2015-06-15 13:55:15 -0700 |
---|---|---|
committer | Walter Jang <wjang@google.com> | 2015-06-17 13:42:45 -0700 |
commit | 25f9694fcad5ce1856f5c214c4167dc58464ef4f (patch) | |
tree | d356a08137f97ce6443f2c21dc160fba6e4c0b92 /src/com | |
parent | 0299c1d4ff397d57dbc87d1bd453077cafbb36b7 (diff) | |
download | Contacts-25f9694fcad5ce1856f5c214c4167dc58464ef4f.tar.gz |
Fix detection of empty structured names
TextFieldEditorView.isEmpty does not do the right thing
for structured names because that methods just checks every
child of the fields ViewGroup and the view retains values
for fields that may have been erased by toggling the
name expansion. The result is that the FIELD_TURNED_EMPTY
EditorListener event is never fired.
Bug 21851290
Change-Id: Iaae3ba102a899de9dfd76d0469c9c2f1d094b0bd
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/contacts/editor/StructuredNameEditorView.java | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/com/android/contacts/editor/StructuredNameEditorView.java b/src/com/android/contacts/editor/StructuredNameEditorView.java index 5f764f925..c0463b06d 100644 --- a/src/com/android/contacts/editor/StructuredNameEditorView.java +++ b/src/com/android/contacts/editor/StructuredNameEditorView.java @@ -212,24 +212,30 @@ public class StructuredNameEditorView extends TextFieldsEditorView { */ public String getDisplayName() { final ValuesDelta valuesDelta = getValues(); - if (hasShortAndLongForms() && areOptionalFieldsVisible()) { - final String displayName = valuesDelta.getDisplayName(); - if (!TextUtils.isEmpty(displayName)) { - return displayName; + if (hasShortAndLongForms()) { + if (areOptionalFieldsVisible()) { + final Map<String, String> structuredNameMap = valuesToStructuredNameMap(valuesDelta); + final String displayName = NameConverter.structuredNameToDisplayName( + getContext(), structuredNameMap); + if (!TextUtils.isEmpty(displayName)) { + return displayName; + } + } else { + final String displayName = valuesDelta.getDisplayName(); + if (!TextUtils.isEmpty(displayName)) { + return displayName; + } } } - final Map<String, String> structuredNameMap = valuesToStructuredNameMap(valuesDelta); - final String displayName = NameConverter.structuredNameToDisplayName( - getContext(), structuredNameMap); - if (!TextUtils.isEmpty(displayName)) { - return displayName; - } - // The name may have been passed to the compact editor and not written to the underlying - // data structure. return valuesDelta.getDisplayName(); } @Override + public boolean isEmpty() { + return TextUtils.isEmpty(getDisplayName()); + } + + @Override protected Parcelable onSaveInstanceState() { SavedState state = new SavedState(super.onSaveInstanceState()); state.mChanged = mChanged; |