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

Commit aebf3206 authored by Gary Mai's avatar Gary Mai
Browse files

Remove support for custom edit activities

Test:
Tested the following editor scenarios:
  1) new contact
  2) edit other contact
  3) edit writable raw contact
  4) edit read-only raw contact (joins a new writable raw contact to it)
  5) edit aggregate w/ 1 writable and 1 read-only raw contact
  6) edit aggregate w/ 2 writable raw contacts
  7) edit local me raw contact
  8) edit local me raw contact joined with a read-only raw contact

Bug:31682268
Bug:31088704

Change-Id: I4000b4cef0d3c7beaa05cdef51ebdf978288c80f
parent 72f71b6b
Loading
Loading
Loading
Loading
+0 −57
Original line number Diff line number Diff line
@@ -23,9 +23,7 @@ import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.QuickContact;
import android.provider.ContactsContract.RawContacts;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -34,10 +32,7 @@ import com.android.contacts.ContactSaveService;
import com.android.contacts.ContactsActivity;
import com.android.contacts.R;
import com.android.contacts.common.activity.RequestPermissionsActivity;
import com.android.contacts.common.model.AccountTypeManager;
import com.android.contacts.common.model.RawContactDeltaList;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.common.util.ImplicitIntentsUtil;
import com.android.contacts.detail.PhotoSelectionHandler;
import com.android.contacts.editor.CompactContactEditorFragment;
@@ -319,58 +314,6 @@ public class CompactContactEditorActivity extends ContactsActivity implements
                            CompactContactEditorActivity.this, intent);
                    finish();
                }

                @Override
                public void onCustomCreateContactActivityRequested(AccountWithDataSet account,
                        Bundle intentExtras) {
                    final AccountTypeManager accountTypes =
                            AccountTypeManager.getInstance(CompactContactEditorActivity.this);
                    final AccountType accountType = accountTypes.getAccountType(
                            account.type, account.dataSet);

                    Intent intent = new Intent();
                    intent.setClassName(accountType.syncAdapterPackageName,
                            accountType.getCreateContactActivityClassName());
                    intent.setAction(Intent.ACTION_INSERT);
                    intent.setType(Contacts.CONTENT_ITEM_TYPE);
                    if (intentExtras != null) {
                        intent.putExtras(intentExtras);
                    }
                    intent.putExtra(RawContacts.ACCOUNT_NAME, account.name);
                    intent.putExtra(RawContacts.ACCOUNT_TYPE, account.type);
                    intent.putExtra(RawContacts.DATA_SET, account.dataSet);
                    intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
                            | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                    startActivity(intent);
                    finish();
                }

                @Override
                public void onCustomEditContactActivityRequested(AccountWithDataSet account,
                        Uri rawContactUri, Bundle intentExtras, boolean redirect) {
                    final AccountTypeManager accountTypes =
                            AccountTypeManager.getInstance(CompactContactEditorActivity.this);
                    final AccountType accountType = accountTypes.getAccountType(
                            account.type, account.dataSet);

                    Intent intent = new Intent();
                    intent.setClassName(accountType.syncAdapterPackageName,
                            accountType.getEditContactActivityClassName());
                    intent.setAction(Intent.ACTION_EDIT);
                    intent.setData(rawContactUri);
                    if (intentExtras != null) {
                        intent.putExtras(intentExtras);
                    }

                    if (redirect) {
                        intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
                                | Intent.FLAG_ACTIVITY_FORWARD_RESULT);
                        startActivity(intent);
                        finish();
                    } else {
                        startActivity(intent);
                    }
                }
            };

    @Override
+0 −22
Original line number Diff line number Diff line
@@ -138,28 +138,6 @@ public abstract class AccountType {
     */
    public abstract boolean areContactsWritable();

    /**
     * Returns an optional custom edit activity.
     *
     * Only makes sense for non-embedded account types.
     * The activity class should reside in the sync adapter package as determined by
     * {@link #syncAdapterPackageName}.
     */
    public String getEditContactActivityClassName() {
        return null;
    }

    /**
     * Returns an optional custom new contact activity.
     *
     * Only makes sense for non-embedded account types.
     * The activity class should reside in the sync adapter package as determined by
     * {@link #syncAdapterPackageName}.
     */
    public String getCreateContactActivityClassName() {
        return null;
    }

    /**
     * Returns an optional custom invite contact activity.
     *
+1 −19
Original line number Diff line number Diff line
@@ -70,8 +70,6 @@ public class ExternalAccountType extends BaseAccountType {
    private static final String TAG_CONTACTS_DATA_KIND = "ContactsDataKind";
    private static final String TAG_EDIT_SCHEMA = "EditSchema";

    private static final String ATTR_EDIT_CONTACT_ACTIVITY = "editContactActivity";
    private static final String ATTR_CREATE_CONTACT_ACTIVITY = "createContactActivity";
    private static final String ATTR_INVITE_CONTACT_ACTIVITY = "inviteContactActivity";
    private static final String ATTR_INVITE_CONTACT_ACTION_LABEL = "inviteContactActionLabel";
    private static final String ATTR_VIEW_CONTACT_NOTIFY_SERVICE = "viewContactNotifyService";
@@ -88,8 +86,6 @@ public class ExternalAccountType extends BaseAccountType {

    private final boolean mIsExtension;

    private String mEditContactActivityClassName;
    private String mCreateContactActivityClassName;
    private String mInviteContactActivity;
    private String mInviteActionLabelAttribute;
    private int mInviteActionLabelResId;
@@ -258,16 +254,6 @@ public class ExternalAccountType extends BaseAccountType {
        return mHasContactsMetadata;
    }

    @Override
    public String getEditContactActivityClassName() {
        return mEditContactActivityClassName;
    }

    @Override
    public String getCreateContactActivityClassName() {
        return mCreateContactActivityClassName;
    }

    @Override
    public String getInviteContactActivityClassName() {
        return mInviteContactActivity;
@@ -337,11 +323,7 @@ public class ExternalAccountType extends BaseAccountType {
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, attr + "=" + value);
                }
                if (ATTR_EDIT_CONTACT_ACTIVITY.equals(attr)) {
                    mEditContactActivityClassName = value;
                } else if (ATTR_CREATE_CONTACT_ACTIVITY.equals(attr)) {
                    mCreateContactActivityClassName = value;
                } else if (ATTR_INVITE_CONTACT_ACTIVITY.equals(attr)) {
                if (ATTR_INVITE_CONTACT_ACTIVITY.equals(attr)) {
                    mInviteContactActivity = value;
                } else if (ATTR_INVITE_CONTACT_ACTION_LABEL.equals(attr)) {
                    mInviteActionLabelAttribute = value;
+9 −59
Original line number Diff line number Diff line
@@ -262,23 +262,6 @@ public class CompactContactEditorFragment extends Fragment implements
        void onEditOtherContactRequested(Uri contactLookupUri,
                ArrayList<ContentValues> contentValues);

        /**
         * Contact is being created for an external account that provides its own
         * new contact activity.
         */
        void onCustomCreateContactActivityRequested(AccountWithDataSet account,
                Bundle intentExtras);

        /**
         * The edited raw contact belongs to an external account that provides
         * its own edit activity.
         *
         * @param redirect indicates that the current editor should be closed
         *                 before the custom editor is shown.
         */
        void onCustomEditContactActivityRequested(AccountWithDataSet account, Uri rawContactUri,
                Bundle intentExtras, boolean redirect);

        /**
         * User has requested that contact be deleted.
         */
@@ -1145,14 +1128,8 @@ public class CompactContactEditorFragment extends Fragment implements
        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
        final AccountType accountType = accountTypes.getAccountTypeForAccount(account);

        if (accountType.getCreateContactActivityClassName() != null) {
            if (mListener != null) {
                mListener.onCustomCreateContactActivityRequested(account, mIntentExtras);
            }
        } else {
        setStateForNewContact(account, accountType, isEditingUserProfile());
    }
    }

    //
    // Data binding
@@ -1167,26 +1144,6 @@ public class CompactContactEditorFragment extends Fragment implements

        mRawContacts = contact.getRawContacts();

        // See if this edit operation needs to be redirected to a custom editor
        if (mRawContacts.size() == 1) {
            RawContact rawContact = mRawContacts.get(0);
            String type = rawContact.getAccountTypeString();
            String dataSet = rawContact.getDataSet();
            AccountType accountType = rawContact.getAccountType(mContext);
            if (accountType.getEditContactActivityClassName() != null &&
                    !accountType.areContactsWritable()) {
                if (mListener != null) {
                    String name = rawContact.getAccountName();
                    long rawContactId = rawContact.getId();
                    mListener.onCustomEditContactActivityRequested(
                            new AccountWithDataSet(name, type, dataSet),
                            ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
                            mIntentExtras, true);
                }
                return;
            }
        }

        String readOnlyDisplayName = null;
        // Check for writable raw contacts.  If there are none, then we need to create one so user
        // can edit.  For the user profile case, there is already an editable contact.
@@ -1439,12 +1396,6 @@ public class CompactContactEditorFragment extends Fragment implements
        AccountType oldAccountType = accountTypes.getAccountTypeForAccount(oldAccount);
        AccountType newAccountType = accountTypes.getAccountTypeForAccount(newAccount);

        if (newAccountType.getCreateContactActivityClassName() != null) {
            Log.w(TAG, "external activity called in rebind situation");
            if (mListener != null) {
                mListener.onCustomCreateContactActivityRequested(newAccount, mIntentExtras);
            }
        } else {
        mExistingContactDataReady = false;
        mNewContactDataReady = false;
        mState = new RawContactDeltaList();
@@ -1455,7 +1406,6 @@ public class CompactContactEditorFragment extends Fragment implements
                    mRawContacts);
        }
    }
    }

    //
    // ContactEditor