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

Commit 05ba2eca authored by Walter Jang's avatar Walter Jang Committed by Android Git Automerger
Browse files

am 24498d61: Merge "Distinguish between editor back button presses and...

am 24498d61: Merge "Distinguish between editor back button presses and framework stopage" into mnc-dev

* commit '24498d61':
  Distinguish between editor back button presses and framework stopage
parents cb5599c9 24498d61
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.contacts.common.model.RawContactDelta;
import com.android.contacts.common.model.RawContactDeltaList;
import com.android.contacts.common.model.RawContactModifier;
import com.android.contacts.common.model.account.AccountWithDataSet;
import com.android.contacts.editor.ContactEditorFragment;
import com.android.contacts.util.ContactPhotoUtils;

import com.google.common.collect.Lists;
@@ -300,7 +301,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);
                callbackActivity, callbackAction, bundle, /* backPressed =*/ false);
    }

    /**
@@ -309,11 +310,13 @@ 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) {
            Bundle updatedPhotos, boolean backPressed) {
        Intent serviceIntent = new Intent(
                context, ContactSaveService.class);
        serviceIntent.setAction(ContactSaveService.ACTION_SAVE_CONTACT);
@@ -333,6 +336,8 @@ public class ContactSaveService extends IntentService {
            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;
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity {
    @Override
    public void onBackPressed() {
        if (mFragment != null) {
            mFragment.save(ContactEditor.SaveMode.CLOSE);
            mFragment.save(ContactEditor.SaveMode.CLOSE, /* backPressed =*/ true);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public class ContactEditorActivity extends ContactEditorBaseActivity
    @Override
    public void onBackPressed() {
        if (mFragment != null) {
            mFragment.save(ContactEditor.SaveMode.COMPACT);
            mFragment.save(ContactEditor.SaveMode.COMPACT, /* backPressed =*/ true);
        }
    }
}
+14 −5
Original line number Diff line number Diff line
@@ -153,14 +153,17 @@ 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 save(int saveMode, boolean backPressed);

        /**
         * Invoked after the contact is saved.
         */
        void onSaveCompleted(boolean hadChanges, int saveMode, boolean saveSucceeded,
                Uri contactLookupUri, Bundle updatedPhotos);
                Uri contactLookupUri, Bundle updatedPhotos, boolean backPressed);

        /**
         * Invoked after the contact is joined.
@@ -238,7 +241,9 @@ abstract public class ContactEditorBaseActivity extends ContactsActivity
                            ContactEditor.SaveMode.CLOSE),
                    intent.getBooleanExtra(ContactSaveService.EXTRA_SAVE_SUCCEEDED, false),
                    intent.getData(),
                    (Bundle) intent.getParcelableExtra(ContactSaveService.EXTRA_UPDATED_PHOTOS));
                    (Bundle) intent.getParcelableExtra(ContactSaveService.EXTRA_UPDATED_PHOTOS),
                    intent.getBooleanExtra(ContactEditorFragment.INTENT_EXTRA_SAVE_BACK_PRESSED,
                            false));
        } else if (ACTION_JOIN_COMPLETED.equals(action)) {
            mFragment.onJoinCompleted(intent.getData());
        }
@@ -268,12 +273,16 @@ 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();
        }

+4 −4
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl

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

@@ -297,12 +297,12 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
    }

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

        return true;
@@ -350,7 +350,7 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl
            mShowToastAfterSave = false;

            // Save whatever is in the form
            save(SaveMode.RELOAD);
            save(SaveMode.RELOAD, /* backPressed =*/ false);
        }

        // Prepare an Intent to start the expanded editor
Loading