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

Commit b1c2c2ca authored by Wenyi Wang's avatar Wenyi Wang Committed by Android (Google) Code Review
Browse files

Merge "Revert "Show check mark when none is primary in photo picker"" into ub-contactsdialer-b-dev

parents 1d86a67a c41a1e5f
Loading
Loading
Loading
Loading
+0 −6
Original line number Original line Diff line number Diff line
@@ -22,7 +22,6 @@ import com.android.contacts.common.model.RawContactDeltaList;
import com.android.contacts.detail.PhotoSelectionHandler;
import com.android.contacts.detail.PhotoSelectionHandler;
import com.android.contacts.editor.CompactContactEditorFragment;
import com.android.contacts.editor.CompactContactEditorFragment;
import com.android.contacts.editor.CompactPhotoSelectionFragment;
import com.android.contacts.editor.CompactPhotoSelectionFragment;
import com.android.contacts.editor.ContactEditorBaseFragment;
import com.android.contacts.editor.PhotoSourceDialogFragment;
import com.android.contacts.editor.PhotoSourceDialogFragment;


import android.app.FragmentTransaction;
import android.app.FragmentTransaction;
@@ -139,7 +138,6 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity impl
            // Create the editor and photo selection fragments
            // Create the editor and photo selection fragments
            mFragment = new CompactContactEditorFragment();
            mFragment = new CompactContactEditorFragment();
            mPhotoSelectionFragment = new CompactPhotoSelectionFragment();
            mPhotoSelectionFragment = new CompactPhotoSelectionFragment();
            mPhotoSelectionFragment.setArguments(getIntent().getExtras());
            getFragmentManager().beginTransaction()
            getFragmentManager().beginTransaction()
                    .add(R.id.fragment_container, getEditorFragment(), TAG_COMPACT_EDITOR)
                    .add(R.id.fragment_container, getEditorFragment(), TAG_COMPACT_EDITOR)
                    .add(R.id.fragment_container, mPhotoSelectionFragment, TAG_PHOTO_SELECTION)
                    .add(R.id.fragment_container, mPhotoSelectionFragment, TAG_PHOTO_SELECTION)
@@ -157,10 +155,6 @@ public class CompactContactEditorActivity extends ContactEditorBaseActivity impl
                    .findFragmentByTag(TAG_COMPACT_EDITOR);
                    .findFragmentByTag(TAG_COMPACT_EDITOR);
            mPhotoSelectionFragment = (CompactPhotoSelectionFragment) getFragmentManager()
            mPhotoSelectionFragment = (CompactPhotoSelectionFragment) getFragmentManager()
                    .findFragmentByTag(TAG_PHOTO_SELECTION);
                    .findFragmentByTag(TAG_PHOTO_SELECTION);
            final Bundle bundle = mPhotoSelectionFragment.getArguments();
            bundle.putString(ContactEditorBaseFragment.INTENT_EXTRA_PHOTO_URI,
                    getIntent().getExtras().getString(
                            ContactEditorBaseFragment.INTENT_EXTRA_PHOTO_URI));
            final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
            final FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
            if (mIsPhotoSelection) {
            if (mIsPhotoSelection) {
                fragmentTransaction.hide(getEditorFragment()).show(mPhotoSelectionFragment);
                fragmentTransaction.hide(getEditorFragment()).show(mPhotoSelectionFragment);
+5 −28
Original line number Original line Diff line number Diff line
@@ -50,8 +50,6 @@ public class CompactPhotoSelectionFragment extends Fragment {


    private static final String STATE_PHOTOS = "photos";
    private static final String STATE_PHOTOS = "photos";
    private static final String STATE_PHOTO_MODE = "photoMode";
    private static final String STATE_PHOTO_MODE = "photoMode";
    private static final String STATE_HAS_PRIMARY = "hasPrimary";
    private static final String STATE_PHOTO_URI = "photoUri";
    private final int VIEW_TYPE_TAKE_PHOTO = 0;
    private final int VIEW_TYPE_TAKE_PHOTO = 0;
    private final int VIEW_TYPE_ALL_PHOTOS = 1;
    private final int VIEW_TYPE_ALL_PHOTOS = 1;
    private final int VIEW_TYPE_IMAGE = 2;
    private final int VIEW_TYPE_IMAGE = 2;
@@ -225,18 +223,16 @@ public class CompactPhotoSelectionFragment extends Fragment {
            }
            }


            final Photo photo = mPhotos.get(position);
            final Photo photo = mPhotos.get(position);
            Uri photoUri = Uri.EMPTY;


            // Bind the photo
            // Bind the photo
            final ImageView imageView = (ImageView) photoItemView.findViewById(R.id.image);
            final ImageView imageView = (ImageView) photoItemView.findViewById(R.id.image);
            if (photo.updatedPhotoUri != null) {
            if (photo.updatedPhotoUri != null) {
                photoUri = photo.updatedPhotoUri;
                EditorUiUtils.loadPhoto(ContactPhotoManager.getInstance(mContext),
                EditorUiUtils.loadPhoto(ContactPhotoManager.getInstance(mContext),
                        imageView, photoUri);
                        imageView, photo.updatedPhotoUri);
            } else {
            } else {
                final Long photoFileId = EditorUiUtils.getPhotoFileId(photo.valuesDelta);
                final Long photoFileId = EditorUiUtils.getPhotoFileId(photo.valuesDelta);
                if (photoFileId != null) {
                if (photoFileId != null) {
                    photoUri = ContactsContract.DisplayPhoto.CONTENT_URI.buildUpon()
                    final Uri photoUri = ContactsContract.DisplayPhoto.CONTENT_URI.buildUpon()
                            .appendPath(photoFileId.toString()).build();
                            .appendPath(photoFileId.toString()).build();
                    EditorUiUtils.loadPhoto(ContactPhotoManager.getInstance(mContext),
                    EditorUiUtils.loadPhoto(ContactPhotoManager.getInstance(mContext),
                            imageView, photoUri);
                            imageView, photoUri);
@@ -253,9 +249,7 @@ public class CompactPhotoSelectionFragment extends Fragment {


            // Display a check icon over the primary photo
            // Display a check icon over the primary photo
            final ImageView checkImageView = (ImageView) photoItemView.findViewById(R.id.check);
            final ImageView checkImageView = (ImageView) photoItemView.findViewById(R.id.check);
            checkImageView.setVisibility(
            checkImageView.setVisibility(photo.primary ? View.VISIBLE : View.GONE);
                    photo.primary || photoUri.toString().equals(mEditorPhotoUri)
                            ? View.VISIBLE : View.GONE);


            photoItemView.setContentDescription(photo.contentDescription);
            photoItemView.setContentDescription(photo.contentDescription);


@@ -267,8 +261,6 @@ public class CompactPhotoSelectionFragment extends Fragment {
    private int mPhotoMode;
    private int mPhotoMode;
    private Listener mListener;
    private Listener mListener;
    private GridView mGridView;
    private GridView mGridView;
    private String mEditorPhotoUri;
    private boolean mHasPrimary;


    public void setListener(Listener listener) {
    public void setListener(Listener listener) {
        mListener = listener;
        mListener = listener;
@@ -278,13 +270,6 @@ public class CompactPhotoSelectionFragment extends Fragment {
        mPhotos = photos;
        mPhotos = photos;
        mPhotoMode = photoMode;
        mPhotoMode = photoMode;
        mGridView.setAccessibilityDelegate(new View.AccessibilityDelegate() {});
        mGridView.setAccessibilityDelegate(new View.AccessibilityDelegate() {});
        mHasPrimary = false;
        for (Photo photo : mPhotos) {
            if (photo.primary) {
                mHasPrimary = true;
                break;
            }
        }
    }
    }


    @Override
    @Override
@@ -293,12 +278,6 @@ public class CompactPhotoSelectionFragment extends Fragment {
        if (savedInstanceState != null) {
        if (savedInstanceState != null) {
            mPhotos = savedInstanceState.getParcelableArrayList(STATE_PHOTOS);
            mPhotos = savedInstanceState.getParcelableArrayList(STATE_PHOTOS);
            mPhotoMode = savedInstanceState.getInt(STATE_PHOTO_MODE, 0);
            mPhotoMode = savedInstanceState.getInt(STATE_PHOTO_MODE, 0);
            mEditorPhotoUri = savedInstanceState.getString(STATE_PHOTO_URI);
            mHasPrimary = savedInstanceState.getBoolean(STATE_HAS_PRIMARY);
        }
        if (TextUtils.isEmpty(mEditorPhotoUri)) {
            mEditorPhotoUri = getArguments().getString(
                    ContactEditorBaseFragment.INTENT_EXTRA_PHOTO_URI);
        }
        }
    }
    }


@@ -336,8 +315,8 @@ public class CompactPhotoSelectionFragment extends Fragment {
        display.getMetrics(outMetrics);
        display.getMetrics(outMetrics);


        // portrait -- 3 columns; landscape -- 5 columns.
        // portrait -- 3 columns; landscape -- 5 columns.
        mNumberOfColumns = outMetrics.heightPixels > outMetrics.widthPixels
        mNumberOfColumns = outMetrics.heightPixels > outMetrics.widthPixels ?
                ? NUMBER_OF_COLUMNS_PORTRAIT : NUMBER_OF_COLUMNS_LANDSCAPE;
                NUMBER_OF_COLUMNS_PORTRAIT : NUMBER_OF_COLUMNS_LANDSCAPE;
        final int paddingWidth = (int) getResources().getDimension(R.dimen
        final int paddingWidth = (int) getResources().getDimension(R.dimen
                .photo_picker_column_padding_width);
                .photo_picker_column_padding_width);
        float density  = getResources().getDisplayMetrics().density;
        float density  = getResources().getDisplayMetrics().density;
@@ -368,8 +347,6 @@ public class CompactPhotoSelectionFragment extends Fragment {
    public void onSaveInstanceState(Bundle outState) {
    public void onSaveInstanceState(Bundle outState) {
        outState.putParcelableArrayList(STATE_PHOTOS, mPhotos);
        outState.putParcelableArrayList(STATE_PHOTOS, mPhotos);
        outState.putInt(STATE_PHOTO_MODE, mPhotoMode);
        outState.putInt(STATE_PHOTO_MODE, mPhotoMode);
        outState.putString(STATE_PHOTO_URI, mEditorPhotoUri);
        outState.putBoolean(STATE_HAS_PRIMARY, mHasPrimary);
        super.onSaveInstanceState(outState);
        super.onSaveInstanceState(outState);
    }
    }


+0 −5
Original line number Original line Diff line number Diff line
@@ -190,11 +190,6 @@ abstract public class ContactEditorBaseFragment extends Fragment implements
     */
     */
    public static final String INTENT_EXTRA_PHOTO_ID = "photo_id";
    public static final String INTENT_EXTRA_PHOTO_ID = "photo_id";


    /**
     * Intent key to pass the URI of the photo to display on the editor.
     */
    public static final String INTENT_EXTRA_PHOTO_URI = "photo_uri";

    /**
    /**
     * Intent key to pass the ID of the raw contact id that should be displayed in the full editor
     * Intent key to pass the ID of the raw contact id that should be displayed in the full editor
     * by itself.
     * by itself.
+1 −8
Original line number Original line Diff line number Diff line
@@ -46,11 +46,10 @@ public class EditorIntents {
     * existing contact.
     * existing contact.
     */
     */
    public static Intent createCompactEditContactIntent(Uri contactLookupUri,
    public static Intent createCompactEditContactIntent(Uri contactLookupUri,
            MaterialPalette materialPalette, long photoId, String photoUri) {
            MaterialPalette materialPalette, long photoId) {
        final Intent intent = new Intent(Intent.ACTION_EDIT, contactLookupUri);
        final Intent intent = new Intent(Intent.ACTION_EDIT, contactLookupUri);
        putMaterialPalette(intent, materialPalette);
        putMaterialPalette(intent, materialPalette);
        putPhotoId(intent, photoId);
        putPhotoId(intent, photoId);
        putPhotoUri(intent, photoUri);
        return intent;
        return intent;
    }
    }


@@ -160,12 +159,6 @@ public class EditorIntents {
        }
        }
    }
    }


    private static void putPhotoUri(Intent intent, String photoUri) {
        if (!Uri.EMPTY.toString().equals(photoUri)) {
            intent.putExtra(ContactEditorBaseFragment.INTENT_EXTRA_PHOTO_URI, photoUri);
        }
    }

    private static void putRawContactDeltaValues(Intent intent,
    private static void putRawContactDeltaValues(Intent intent,
            RawContactDeltaList rawContactDeltaList, String displayName, String phoneticName) {
            RawContactDeltaList rawContactDeltaList, String displayName, String phoneticName) {
        // Pass on all the data that has been entered so far
        // Pass on all the data that has been entered so far
+1 −2
Original line number Original line Diff line number Diff line
@@ -2643,8 +2643,7 @@ public class QuickContactActivity extends ContactsActivity
                mContactData.getLookupUri(),
                mContactData.getLookupUri(),
                mHasComputedThemeColor
                mHasComputedThemeColor
                        ? new MaterialPalette(mColorFilterColor, mStatusBarColor) : null,
                        ? new MaterialPalette(mColorFilterColor, mStatusBarColor) : null,
                mContactData.getPhotoId(),
                mContactData.getPhotoId());
                mContactData.getPhotoUri());
    }
    }


    private void editContact() {
    private void editContact() {