Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3182c2d authored by Tingting Wang's avatar Tingting Wang Committed by Android (Google) Code Review
Browse files

Merge "Hide Group editor if account has no groups." into ub-contactsdialer-a-dev

parents 2955d702 6dc36b01
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -449,12 +449,14 @@ public class CompactKindSectionView extends LinearLayout {
            // 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()) {
                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
            if (mHideIfEmpty) {
                setVisibility(GONE);
+11 −3
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ public class GroupMembershipView extends LinearLayout

    private RawContactDelta mState;
    private Cursor mGroupMetaData;
    private boolean mAccountHasGroups;
    private String mAccountName;
    private String mAccountType;
    private String mDataSet;
@@ -207,6 +208,14 @@ public class GroupMembershipView extends LinearLayout
        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 @@ public class GroupMembershipView extends LinearLayout
            return;
        }

        boolean accountHasGroups = false;
        mFavoritesGroupId = 0;
        mDefaultGroupId = 0;

@@ -244,7 +252,7 @@ public class GroupMembershipView extends LinearLayout
                            && 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 @@ public class GroupMembershipView extends LinearLayout
            }
        }

        if (!accountHasGroups) {
        if (!mAccountHasGroups) {
            setVisibility(GONE);
            return;
        }