Hide all empty email and phone KindSectionViews expect the last
Bug 22331611
Change-Id: I5c4544ed3cc82982f159f7c1758a1e6cd8868c48
diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
index d1159a4..6b7df67 100644
--- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java
+++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java
@@ -666,7 +666,7 @@
final List<ValuesDelta> valuesDeltas = getNonEmptyValuesDeltas(
rawContactDelta, Nickname.CONTENT_ITEM_TYPE, dataKind);
if (valuesDeltas != null && !valuesDeltas.isEmpty()) {
- for (ValuesDelta valuesDelta : valuesDeltas){
+ for (ValuesDelta valuesDelta : valuesDeltas) {
mNicknames.addView(inflateNicknameEditorView(
mNicknames, dataKind, valuesDelta, rawContactDelta));
}
@@ -744,6 +744,15 @@
}
// Only the last editor should show an empty editor
if (lastVisibleKindSectionView != null) {
+ // Hide all empty kind sections except the last one
+ for (int i = 0; i < viewGroup.getChildCount(); i++) {
+ final KindSectionView kindSectionView = (KindSectionView) viewGroup.getChildAt(i);
+ if (kindSectionView != lastVisibleKindSectionView
+ && kindSectionView.areAllEditorsEmpty()) {
+ kindSectionView.setVisibility(View.GONE);
+ }
+ }
+ // Set the last editor to show empty editor fields
lastVisibleKindSectionView.setShowOneEmptyEditor(true);
lastVisibleKindSectionView.updateEmptyEditors(/* shouldAnimate =*/ false);
}
diff --git a/src/com/android/contacts/editor/KindSectionView.java b/src/com/android/contacts/editor/KindSectionView.java
index bf456d5..5837ab1 100644
--- a/src/com/android/contacts/editor/KindSectionView.java
+++ b/src/com/android/contacts/editor/KindSectionView.java
@@ -326,6 +326,16 @@
return emptyEditorViews;
}
+ public boolean areAllEditorsEmpty() {
+ for (int i = 0; i < mEditors.getChildCount(); i++) {
+ final View view = mEditors.getChildAt(i);
+ if (!((Editor) view).isEmpty()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
public int getEditorCount() {
return mEditors.getChildCount();
}