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

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

Merge "Hide account container in compact editor." into ub-contactsdialer-a-dev

parents 35f32206 1594c6f3
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -748,10 +748,10 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
            if (accounts.size() > 1) {
                addAccountSelector(accountInfo, rawContactDelta);
            } else {
                addAccountHeader(accountInfo, rawContactDeltas);
                addAccountHeader(accountInfo);
            }
        } else {
            addAccountHeader(accountInfo, rawContactDeltas);
        } else if (mIsUserProfile || !shouldHideAccountContainer(rawContactDeltas)) {
            addAccountHeader(accountInfo);
        }

        // The raw contact selector should only display linked raw contacts that can be edited in
@@ -788,9 +788,9 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        return result;
    }

    // Returns true if there're multiple writable and no read only, or there're both writable and
    // read only. For ME profile, return false if there's a read only contact and unsaved local one.
    private boolean shouldHideAccountHeader(RawContactDeltaList rawContactDeltas) {
    // Returns true if there are multiple writable rawcontacts and no read-only ones,
    // or there are both writable and read-only rawcontacts.
    private boolean shouldHideAccountContainer(RawContactDeltaList rawContactDeltas) {
        int writable = 0;
        int readonly = 0;
        for (RawContactDelta rawContactDelta : rawContactDeltas) {
@@ -805,12 +805,8 @@ public class CompactRawContactsEditorView extends LinearLayout implements View.O
        return (writable > 1 || (writable > 0 && readonly > 0));
    }

    private void addAccountHeader(Pair<String,String> accountInfo,
            RawContactDeltaList rawContactDeltas) {
    private void addAccountHeader(Pair<String,String> accountInfo) {
        mAccountHeaderContainer.setVisibility(View.VISIBLE);
        if (shouldHideAccountHeader(rawContactDeltas)) {
            mAccountHeaderContainer.setVisibility(View.GONE);
        }

        // Set the account name
        final String accountName = TextUtils.isEmpty(accountInfo.first)
+2 −0
Original line number Diff line number Diff line
@@ -1140,6 +1140,8 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
            selectAccountAndCreateContact();

            readOnlyDisplayName = contact.getDisplayName();
        } else {
            mHasNewContact = false;
        }

        // This also adds deltas to list.  If readOnlyDisplayName is null at this point it is