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

Commit 1594c6f3 authored by Tingting Wang's avatar Tingting Wang
Browse files

Hide account container in compact editor.

Show account container when editing ME profile.
Hide account container when linking a writable contact with
a readonly one in editor. Also, showing unlink menu in this case.

BUG 25231329

Change-Id: Ia8cb59b93e0a3e46bcfa265d2d16518b3900204a
parent 2f94e320
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -756,10 +756,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
@@ -796,9 +796,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) {
@@ -813,12 +813,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