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

Commit 36d24d7e authored by Dave Santoro's avatar Dave Santoro
Browse files

Avoid showing error if contact removed on save.

Because removing all data from a local contact can actually cause
the raw contact and contact to be deleted, we need to track that
case so that the caller does not consider the lack of a lookup
URI to be an error.

Also made "Me" header all-caps for no-profile case.

Bug 5346614
Bug 5354364

Change-Id: If1e1d67da9c14eb8782be05b2e39ece19b5ac026
parent 763305a8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class ContactSaveService extends IntentService {
    public static final String EXTRA_CONTACT_STATE = "state";
    public static final String EXTRA_SAVE_MODE = "saveMode";
    public static final String EXTRA_SAVE_IS_PROFILE = "saveIsProfile";
    public static final String EXTRA_SAVE_SUCCEEDED = "saveSucceeded";

    public static final String ACTION_CREATE_GROUP = "createGroup";
    public static final String ACTION_RENAME_GROUP = "renameGroup";
@@ -345,6 +346,10 @@ public class ContactSaveService extends IntentService {
                    lookupUri = RawContacts.getContactLookupUri(resolver, rawContactUri);
                }
                Log.v(TAG, "Saved contact. New URI: " + lookupUri);
                // Mark the intent to indicate that the save was successful (even if the lookup URI
                // is now null).  For local contacts or the local profile, it's possible that the
                // save triggered removal of the contact, so no lookup URI would exist..
                callbackIntent.putExtra(EXTRA_SAVE_SUCCEEDED, true);
                break;

            } catch (RemoteException e) {
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.contacts.activities;

import com.android.contacts.ContactSaveService;
import com.android.contacts.ContactsActivity;
import com.android.contacts.R;
import com.android.contacts.editor.ContactEditorFragment;
@@ -115,6 +116,7 @@ public class ContactEditorActivity extends ContactsActivity
        } else if (ACTION_SAVE_COMPLETED.equals(action)) {
            mFragment.onSaveCompleted(true,
                    intent.getIntExtra(ContactEditorFragment.SAVE_MODE_EXTRA_KEY, SaveMode.CLOSE),
                    intent.getBooleanExtra(ContactSaveService.EXTRA_SAVE_SUCCEEDED, false),
                    intent.getData());
        } else if (ACTION_JOIN_COMPLETED.equals(action)) {
            mFragment.onJoinCompleted(intent.getData());
+8 −8
Original line number Diff line number Diff line
@@ -979,7 +979,7 @@ public class ContactEditorFragment extends Fragment implements

        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
        if (!EntityModifier.hasChanges(mState, accountTypes)) {
            onSaveCompleted(false, saveMode, mLookupUri);
            onSaveCompleted(false, saveMode, mLookupUri != null, mLookupUri);
            return true;
        }

@@ -1041,14 +1041,14 @@ public class ContactEditorFragment extends Fragment implements
    }

    public void onJoinCompleted(Uri uri) {
        onSaveCompleted(false, SaveMode.RELOAD, uri);
        onSaveCompleted(false, SaveMode.RELOAD, uri != null, uri);
    }

    public void onSaveCompleted(boolean hadChanges, int saveMode, Uri contactLookupUri) {
        boolean success = contactLookupUri != null;
    public void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
            Uri contactLookupUri) {
        Log.d(TAG, "onSaveCompleted(" + saveMode + ", " + contactLookupUri);
        if (hadChanges) {
            if (success) {
            if (saveSucceeded) {
                if (saveMode != SaveMode.JOIN) {
                    Toast.makeText(mContext, R.string.contactSavedToast, Toast.LENGTH_SHORT).show();
                }
@@ -1060,7 +1060,7 @@ public class ContactEditorFragment extends Fragment implements
            case SaveMode.CLOSE:
            case SaveMode.HOME:
                final Intent resultIntent;
                if (success && contactLookupUri != null) {
                if (saveSucceeded && contactLookupUri != null) {
                    final String requestAuthority =
                            mLookupUri == null ? null : mLookupUri.getAuthority();

@@ -1091,7 +1091,7 @@ public class ContactEditorFragment extends Fragment implements

            case SaveMode.RELOAD:
            case SaveMode.JOIN:
                if (success && contactLookupUri != null) {
                if (saveSucceeded && contactLookupUri != null) {
                    // If it was a JOIN, we are now ready to bring up the join activity.
                    if (saveMode == SaveMode.JOIN) {
                        showJoinAggregateActivity(contactLookupUri);
+3 −2
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment
    private View mProfileHeader;
    private Button mProfileMessage;
    private FrameLayout mMessageContainer;
    private View mProfileTitle;
    private TextView mProfileTitle;

    private View mPaddingView;

@@ -273,7 +273,8 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment
        mProfileHeaderContainer = new FrameLayout(inflater.getContext());
        mProfileHeader = inflater.inflate(R.layout.user_profile_header, null, false);
        mCounterHeaderView = (TextView) mProfileHeader.findViewById(R.id.contacts_count);
        mProfileTitle = mProfileHeader.findViewById(R.id.profile_title);
        mProfileTitle = (TextView) mProfileHeader.findViewById(R.id.profile_title);
        mProfileTitle.setAllCaps(true);
        mProfileHeaderContainer.addView(mProfileHeader);
        list.addHeaderView(mProfileHeaderContainer, null, false);