am 9a3cdb14: am ad4e4d9c: am 4b1634de: am 4ee224b7: Merge "Hide all empty email and phone KindSectionViews expect the last" into mnc-dev
* commit '9a3cdb1454846137cc75eb300cf72173788c3233':
Hide all empty email and phone KindSectionViews expect the last
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();
}