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

Commit 48ed982e authored by Isaac Katzenelson's avatar Isaac Katzenelson
Browse files

Allow local profile editing with an existing profile

Bug: 5244792 Can not create local offline profile if
     Google+ profile has already been synced in

Change-Id: Icb818098588f27bab54515d8a554fe77a08569ca
parent 104ee375
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -479,9 +479,26 @@ public class ContactEditorFragment extends Fragment implements

        // For user profile, change the contacts query URI
        mIsUserProfile = data.isUserProfile();
        boolean localProfileExists = false;

        if (mIsUserProfile) {
            for (EntityDelta state : mState) {
                // For profile contacts, we need a different query URI
                state.setProfileQueryUri();
                // Try to find a local profile contact
                if (state.getValues().getAsString(RawContacts.ACCOUNT_TYPE) == null) {
                    localProfileExists = true;
                }
            }
            // Editor should always present a local profile for editing
            if (!localProfileExists) {
                final ContentValues values = new ContentValues();
                values.putNull(RawContacts.ACCOUNT_NAME);
                values.putNull(RawContacts.ACCOUNT_TYPE);
                values.putNull(RawContacts.DATA_SET);
                EntityDelta insert = new EntityDelta(ValuesDelta.fromAfter(values));
                insert.setProfileQueryUri();
                mState.add(insert);
            }
        }
        mRequestFocus = true;