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

Commit e86b928b authored by Megha Joshi's avatar Megha Joshi
Browse files

Prevents empty focus contacts without photo from being created.

Bug: 2133257
Dr No: TS
parent 8e55e0da
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -85,7 +85,10 @@ public class EntityModifier {

        if (!hasChild && kind != null) {
            // Create child when none exists and valid kind
            insertChild(state, kind);
            final ValuesDelta child = insertChild(state, kind);
            if (kind.mimeType.equals(Photo.CONTENT_ITEM_TYPE)) {
                child.setFromTemplate(true);
            }
        }
    }

@@ -321,7 +324,6 @@ public class EntityModifier {
    public static ValuesDelta insertChild(EntityDelta state, DataKind kind, EditType type) {
        // Bail early if invalid kind
        if (kind == null) return null;

        final ContentValues after = new ContentValues();

        // Our parent CONTACT_ID is provided later
@@ -385,6 +387,7 @@ public class EntityModifier {
                        state.getValues().getAsString(RawContacts.ACCOUNT_TYPE));
                final boolean isPhoto = TextUtils.equals(Photo.CONTENT_ITEM_TYPE, kind.mimeType);
                final boolean isGooglePhoto = isPhoto && isGoogleSource;

                if (EntityModifier.isEmpty(entry, kind) && !isGooglePhoto) {
                    // TODO: remove this verbose logging
                    Log.w(TAG, "Trimming: " + entry.toString());
@@ -394,7 +397,6 @@ public class EntityModifier {
                }
            }
        }

        if (!hasValues) {
            // Trim overall entity if no children exist
            state.markDeleted();
+3 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ public class PhotoEditorView extends ImageView implements Editor, OnClickListene
                setImageBitmap(photo);
		setEnabled(!readOnly);
                mHasSetPhoto = true;
                mEntry.setFromTemplate(false);
            } else {
                resetDefault();
            }
@@ -125,6 +126,7 @@ public class PhotoEditorView extends ImageView implements Editor, OnClickListene
            mEntry.put(Photo.PHOTO, out.toByteArray());
            setImageBitmap(photo);
            mHasSetPhoto = true;
            mEntry.setFromTemplate(false);
        } catch (IOException e) {
            Log.w(TAG, "Unable to serialize photo: " + e.toString());
        }
@@ -135,6 +137,7 @@ public class PhotoEditorView extends ImageView implements Editor, OnClickListene
        setScaleType(ImageView.ScaleType.CENTER);
        setImageResource(R.drawable.ic_menu_add_picture);
        mHasSetPhoto = false;
        mEntry.setFromTemplate(true);
    }

    /** {@inheritDoc} */