Hide Group editor if account has no groups.
BUG 25695708
Change-Id: If0ab5576287e4501a4f7b6e68ef1f40db0d629d8
diff --git a/src/com/android/contacts/editor/CompactKindSectionView.java b/src/com/android/contacts/editor/CompactKindSectionView.java
index c1e659f..bab6fe3 100644
--- a/src/com/android/contacts/editor/CompactKindSectionView.java
+++ b/src/com/android/contacts/editor/CompactKindSectionView.java
@@ -449,10 +449,12 @@
// Check whether metadata has been bound for all group views
for (int i = 0; i < mEditors.getChildCount(); i++) {
final View view = mEditors.getChildAt(i);
- if (view instanceof GroupMembershipView
- && !((GroupMembershipView) view).wasGroupMetaDataBound()) {
- setVisibility(GONE);
- return;
+ if (view instanceof GroupMembershipView) {
+ final GroupMembershipView groupView = (GroupMembershipView) view;
+ if (!groupView.wasGroupMetaDataBound() || !groupView.accountHasGroups()) {
+ setVisibility(GONE);
+ return;
+ }
}
}
// Check that the user has selected to display all fields
diff --git a/src/com/android/contacts/editor/GroupMembershipView.java b/src/com/android/contacts/editor/GroupMembershipView.java
index b13da62..cb66b73 100644
--- a/src/com/android/contacts/editor/GroupMembershipView.java
+++ b/src/com/android/contacts/editor/GroupMembershipView.java
@@ -134,6 +134,7 @@
private RawContactDelta mState;
private Cursor mGroupMetaData;
+ private boolean mAccountHasGroups;
private String mAccountName;
private String mAccountType;
private String mDataSet;
@@ -207,6 +208,14 @@
return mGroupMetaData != null;
}
+ /**
+ * Return true if the account has groups to edit group membership for contacts
+ * belong to the account.
+ */
+ public boolean accountHasGroups() {
+ return mAccountHasGroups;
+ }
+
public void setState(RawContactDelta state) {
mState = state;
mAccountType = mState.getAccountType();
@@ -224,7 +233,6 @@
return;
}
- boolean accountHasGroups = false;
mFavoritesGroupId = 0;
mDefaultGroupId = 0;
@@ -244,7 +252,7 @@
&& mGroupMetaData.getInt(GroupMetaDataLoader.AUTO_ADD) != 0) {
mDefaultGroupId = groupId;
} else {
- accountHasGroups = true;
+ mAccountHasGroups = true;
}
// Exclude favorites from the list - they are handled with special UI (star)
@@ -262,7 +270,7 @@
}
}
- if (!accountHasGroups) {
+ if (!mAccountHasGroups) {
setVisibility(GONE);
return;
}