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

Commit 28a27279 authored by Walter Jang's avatar Walter Jang
Browse files

Revert moving between the compact and full editors (E5)

We are reverting most of the changes made to fix
b/19624360 in MNC.  The reason to do this is to reduce
the massive complexity moving between the two editors
introduced.

Since the compact editor now expands in place, the full
editor will likely only used to view read-only raw
contacts now.

Bug 23589603

Change-Id: Idfcc07d8aae65295d4b3f0a0e3e7f5eb701a46c4
parent f5dfea4a
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -313,7 +313,7 @@ public class ContactSaveService extends IntentService {
        Bundle bundle = new Bundle();
        bundle.putParcelable(String.valueOf(rawContactId), updatedPhotoPath);
        return createSaveContactIntent(context, state, saveModeExtraKey, saveMode, isProfile,
                callbackActivity, callbackAction, bundle, /* backPressed =*/ false);
                callbackActivity, callbackAction, bundle);
    }

    /**
@@ -322,13 +322,11 @@ public class ContactSaveService extends IntentService {
     * This variant is used when multiple contacts' photos may be updated, as in the
     * Contact Editor.
     * @param updatedPhotos maps each raw-contact's ID to the file-path of the new photo.
     * @param backPressed whether the save was initiated as a result of a back button press
     *         or because the framework stopped the editor Activity
     */
    public static Intent createSaveContactIntent(Context context, RawContactDeltaList state,
            String saveModeExtraKey, int saveMode, boolean isProfile,
            Class<? extends Activity> callbackActivity, String callbackAction,
            Bundle updatedPhotos, boolean backPressed) {
            Bundle updatedPhotos) {
        Intent serviceIntent = new Intent(
                context, ContactSaveService.class);
        serviceIntent.setAction(ContactSaveService.ACTION_SAVE_CONTACT);
@@ -347,11 +345,6 @@ public class ContactSaveService extends IntentService {
            Intent callbackIntent = new Intent(context, callbackActivity);
            callbackIntent.putExtra(saveModeExtraKey, saveMode);
            callbackIntent.setAction(callbackAction);
            if (updatedPhotos != null) {
                callbackIntent.putExtra(EXTRA_UPDATED_PHOTOS, (Parcelable) updatedPhotos);
            }
            callbackIntent.putExtra(ContactEditorFragment.INTENT_EXTRA_SAVE_BACK_PRESSED,
                    backPressed);
            serviceIntent.putExtra(ContactSaveService.EXTRA_CALLBACK_INTENT, callbackIntent);
        }
        return serviceIntent;
+0 −7
Original line number Diff line number Diff line
@@ -56,11 +56,4 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity {
        final Uri uri = Intent.ACTION_EDIT.equals(action) ? getIntent().getData() : null;
        mFragment.load(action, uri, getIntent().getExtras());
    }

    @Override
    public void onBackPressed() {
        if (mFragment != null) {
            mFragment.revert();
        }
    }
}
+0 −7
Original line number Diff line number Diff line
@@ -50,11 +50,4 @@ public class ContactEditorActivity extends ContactEditorBaseActivity
                || Intent.ACTION_EDIT.equals(action) ? getIntent().getData() : null;
        mFragment.load(action, uri, getIntent().getExtras());
    }

    @Override
    public void onBackPressed() {
        if (mFragment != null) {
            mFragment.save(ContactEditor.SaveMode.COMPACT, /* backPressed =*/ true);
        }
    }
}
+12 −18
Original line number Diff line number Diff line
@@ -155,11 +155,8 @@ abstract public class ContactEditorBaseActivity extends ContactsActivity
        /**
         * Saves or creates the contact based on the mode, and if successful
         * finishes the activity.
         *
         * @param backPressed whether the save was initiated as a result of a back button press
         *         or because the framework stopped the editor Activity
         */
        boolean save(int saveMode, boolean backPressed);
        boolean save(int saveMode);

        /**
         * If there are no unsaved changes, just close the editor, otherwise the user is prompted
@@ -171,8 +168,7 @@ abstract public class ContactEditorBaseActivity extends ContactsActivity
         * Invoked after the contact is saved.
         */
        void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
                Uri contactLookupUri, Bundle updatedPhotos, boolean backPressed, long photoId,
                long nameId);
                Uri contactLookupUri);

        /**
         * Invoked after the contact is joined.
@@ -259,12 +255,7 @@ abstract public class ContactEditorBaseActivity extends ContactsActivity
                    intent.getIntExtra(ContactEditorFragment.SAVE_MODE_EXTRA_KEY,
                            ContactEditor.SaveMode.CLOSE),
                    intent.getBooleanExtra(ContactSaveService.EXTRA_SAVE_SUCCEEDED, false),
                    intent.getData(),
                    (Bundle) intent.getParcelableExtra(ContactSaveService.EXTRA_UPDATED_PHOTOS),
                    intent.getBooleanExtra(ContactEditorFragment.INTENT_EXTRA_SAVE_BACK_PRESSED,
                            false),
                    intent.getLongExtra(ContactEditorFragment.INTENT_EXTRA_PHOTO_ID, -1),
                    intent.getLongExtra(ContactEditorFragment.INTENT_EXTRA_NAME_ID, -1));
                    intent.getData());
        } else if (ACTION_JOIN_COMPLETED.equals(action)) {
            mFragment.onJoinCompleted(intent.getData());
        }
@@ -279,6 +270,13 @@ abstract public class ContactEditorBaseActivity extends ContactsActivity
        return null;
    }

    @Override
    public void onBackPressed() {
        if (mFragment != null) {
            mFragment.save(ContactEditor.SaveMode.CLOSE);
        }
    }

    protected final ContactEditorBaseFragment.Listener  mFragmentListener =
            new ContactEditorBaseFragment.Listener() {

@@ -294,16 +292,12 @@ abstract public class ContactEditorBaseActivity extends ContactsActivity

        @Override
        public void onSaveFinished(Intent resultIntent) {
            final boolean backPressed = resultIntent == null ? false : resultIntent.getBooleanExtra(
                    ContactEditorBaseFragment.INTENT_EXTRA_SAVE_BACK_PRESSED, false);
            if (mFinishActivityOnSaveCompleted) {
                setResult(resultIntent == null ? RESULT_CANCELED : RESULT_OK, resultIntent);
            } else if (resultIntent != null) {
                if (backPressed) {
                ImplicitIntentsUtil.startActivityInApp(ContactEditorBaseActivity.this,
                        resultIntent);
            }
            }
            finish();
        }

+8 −38
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import com.android.contacts.common.model.RawContactDeltaList;
import com.android.contacts.common.model.ValuesDelta;
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.util.ContactPhotoUtils;

@@ -52,6 +51,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl

    private static final String KEY_PHOTO_URI = "photo_uri";
    private static final String KEY_PHOTO_RAW_CONTACT_ID = "photo_raw_contact_id";
    private static final String KEY_UPDATED_PHOTOS = "updated_photos";

    /**
     * Displays a PopupWindow with photo edit options.
@@ -80,10 +80,6 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
                }
                getContent().setPhoto(bitmap);

                // Clear any previously saved full resolution photos under negative raw contact IDs
                // so that we will use the newly selected photo, instead of an old one on rotations.
                removeNewRawContactPhotos();

                // If a new photo was chosen but not yet saved,
                // we need to update the UI immediately
                mUpdatedPhotos.putParcelable(String.valueOf(mPhotoRawContactId), uri);
@@ -142,6 +138,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
    private PhotoHandler mPhotoHandler;
    private Uri mPhotoUri;
    private long mPhotoRawContactId;
    private Bundle mUpdatedPhotos = new Bundle();

    @Override
    public void onCreate(Bundle savedState) {
@@ -150,6 +147,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
        if (savedState != null) {
            mPhotoUri = savedState.getParcelable(KEY_PHOTO_URI);
            mPhotoRawContactId = savedState.getLong(KEY_PHOTO_RAW_CONTACT_ID);
            mUpdatedPhotos = savedState.getParcelable(KEY_UPDATED_PHOTOS);
        }
    }

@@ -167,6 +165,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
    public void onSaveInstanceState(Bundle outState) {
        outState.putParcelable(KEY_PHOTO_URI, mPhotoUri);
        outState.putLong(KEY_PHOTO_RAW_CONTACT_ID, mPhotoRawContactId);
        outState.putParcelable(KEY_UPDATED_PHOTOS, mUpdatedPhotos);
        super.onSaveInstanceState(outState);
    }

@@ -188,7 +187,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl

        // If anything was left unsaved, save it now
        if (!getActivity().isChangingConfigurations() && mStatus == Status.EDITING) {
            save(SaveMode.RELOAD, /* backPressed =*/ false);
            save(SaveMode.RELOAD);
        }
    }

@@ -218,19 +217,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
        // Set up the photo widget
        mPhotoHandler = createPhotoHandler();
        mPhotoRawContactId = editorView.getPhotoRawContactId();
        if (mPhotoRawContactId < 0) {
            // Since the raw contact IDs for new contacts are random negative numbers
            // we consider any negative key a match
            for (String key : mUpdatedPhotos.keySet()) {
                try {
                    if (Integer.parseInt(key) < 0) {
                        editorView.setFullSizePhoto((Uri) mUpdatedPhotos.getParcelable(key));
                        break;
                    }
                } catch (NumberFormatException ignored) {
                }
            }
        } else if (mUpdatedPhotos.containsKey(String.valueOf(mPhotoRawContactId))) {
        if (mUpdatedPhotos.containsKey(String.valueOf(mPhotoRawContactId))) {
            editorView.setFullSizePhoto((Uri) mUpdatedPhotos.getParcelable(
                    String.valueOf(mPhotoRawContactId)));
        }
@@ -309,12 +296,11 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
    }

    @Override
    protected boolean doSaveAction(int saveMode, boolean backPressed) {
        // Save contact. No need to pass the palette since we are finished editing after the save.
    protected boolean doSaveAction(int saveMode) {
        final Intent intent = ContactSaveService.createSaveContactIntent(mContext, mState,
                SAVE_MODE_EXTRA_KEY, saveMode, isEditingUserProfile(),
                ((Activity) mContext).getClass(),
                CompactContactEditorActivity.ACTION_SAVE_COMPLETED, mUpdatedPhotos, backPressed);
                CompactContactEditorActivity.ACTION_SAVE_COMPLETED, mUpdatedPhotos);
        mContext.startService(intent);

        return true;
@@ -368,22 +354,6 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
        rebindEditorsForNewContact(oldState, oldAccount, newAccount);
    }

    @Override
    public String getDisplayName() {
        final StructuredNameEditorView structuredNameEditorView =
                getContent().getStructuredNameEditorView();
        return structuredNameEditorView == null
                ? null : structuredNameEditorView.getDisplayName();
    }

    @Override
    public String getPhoneticName() {
        final PhoneticNameEditorView phoneticNameEditorView =
                getContent().getFirstPhoneticNameEditorView();
        return phoneticNameEditorView == null
                ? null : phoneticNameEditorView.getPhoneticName();
    }

    private CompactRawContactsEditorView getContent() {
        return (CompactRawContactsEditorView) mContent;
    }
Loading