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

Commit a9242e14 authored by Wenyi Wang's avatar Wenyi Wang
Browse files

Make photo selection handler available and pass photo URI on rotation

The root cause is that if we rotate screen before photo is taken/picked from
album, mPhotoSelectionHandler will be null after rotation. In addition, we
also need to restore photo URI after rotation to avoid opening Photos app
with a null URI.

Bug: 25895614

Change-Id: I625af9932a2c7f7b6c4531cc2e52973ff6c5efc7
parent 17294e1a
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity impl
    private static final String STATE_PHOTO_MODE = "photo_mode";
    private static final String STATE_IS_PHOTO_SELECTION = "is_photo_selection";
    private static final String STATE_ACTION_BAR_TITLE = "action_bar_title";
    private static final String STATE_PHOTO_URI = "photo_uri";

    /**
     * Displays a PopupWindow with photo edit options.
@@ -147,6 +148,7 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity impl
            mPhotoMode = savedState.getInt(STATE_PHOTO_MODE);
            mIsPhotoSelection = savedState.getBoolean(STATE_IS_PHOTO_SELECTION);
            mActionBarTitleResId = savedState.getInt(STATE_ACTION_BAR_TITLE);
            mPhotoUri = Uri.parse(savedState.getString(STATE_PHOTO_URI));

            // Show/hide the editor and photo selection fragments (w/o animations)
            mFragment = (CompactContactEditorFragment) getFragmentManager()
@@ -179,12 +181,16 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity impl
        outState.putInt(STATE_PHOTO_MODE, mPhotoMode);
        outState.putBoolean(STATE_IS_PHOTO_SELECTION, mIsPhotoSelection);
        outState.putInt(STATE_ACTION_BAR_TITLE, mActionBarTitleResId);
        outState.putString(STATE_PHOTO_URI,
                mPhotoUri != null ? mPhotoUri.toString() : Uri.EMPTY.toString());
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (mPhotoSelectionHandler != null &&
                mPhotoSelectionHandler.handlePhotoActivityResult(requestCode, resultCode, data)) {
        if (mPhotoSelectionHandler == null) {
            mPhotoSelectionHandler = (CompactPhotoSelectionHandler) getPhotoSelectionHandler();
        }
        if (mPhotoSelectionHandler.handlePhotoActivityResult(requestCode, resultCode, data)) {
            return;
        }
        super.onActivityResult(requestCode, resultCode, data);