From ae9c9ec49c460d34f7c649c3a3bf684fc5ef262d Mon Sep 17 00:00:00 2001 From: Walter Jang Date: Tue, 7 Jul 2015 16:10:41 -0700 Subject: Hide all empty email and phone KindSectionViews expect the last Bug 22331611 Change-Id: I5c4544ed3cc82982f159f7c1758a1e6cd8868c48 --- .../android/contacts/editor/CompactRawContactsEditorView.java | 11 ++++++++++- src/com/android/contacts/editor/KindSectionView.java | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/contacts/editor/CompactRawContactsEditorView.java b/src/com/android/contacts/editor/CompactRawContactsEditorView.java index d1159a469..6b7df6768 100644 --- a/src/com/android/contacts/editor/CompactRawContactsEditorView.java +++ b/src/com/android/contacts/editor/CompactRawContactsEditorView.java @@ -666,7 +666,7 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O final List 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 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O } // 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 bf456d5ff..5837ab1aa 100644 --- a/src/com/android/contacts/editor/KindSectionView.java +++ b/src/com/android/contacts/editor/KindSectionView.java @@ -326,6 +326,16 @@ public class KindSectionView extends LinearLayout implements EditorListener { 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(); } -- cgit v1.2.3